Why can't I resize jpg images in the applet?

I used this code to display images in an html page. One applet for one image. But out of the 8 images I loaded, 6 adjusted themselves to 320x240 automatically, 1 randomly jumps around to certain parts of the image every 250millisecs, and 1 just cuts the top left hand part of 320x240. How can .jpg files give 3 different situations? I tried using the resize() method in the code but it doesn't do anything! How can I size those .jpg images to the size I want?
/**This video stream applet loads a new image every 250ms
import java.applet.*;
import java.awt.*;
import java.net.*;
import java.io.*;
import java.awt.event.*;
public class Video extends Applet implements Runnable{
private Image img,buffer;
private Thread video = null;
private URL url;
private MediaTracker tracker;
public synchronized void init(){
tracker = new MediaTracker(this);
try{url = new URL(getCodeBase(),"Camera1.jpg");}
catch(MalformedURLException e){}
img = getImage(url);
tracker.addImage(img, 0);
buffer = createImage(320,240);
resize(320,240);
if(video!=null)return;
video = new Thread(this,"VideoStream");
video.start();
public synchronized void destroy(){
if(video!=null)video=null;
public void run(){
while(!Thread.interrupted()){
// Load new image.
try{tracker.waitForID(0);}
catch(InterruptedException e){}
// Draw new Image.
repaint();
// Remove old image & add new one.
tracker.removeImage(img,0);
img.flush();
tracker.addImage(img,0);
// Sleep
try{Thread.sleep(250);}
catch(InterruptedException e){}
public synchronized void update(Graphics g){
Graphics bufGraph = buffer.getGraphics();
bufGraph.drawImage(img,0,0,this);
paint(bufGraph);
g.drawImage(buffer,0,0,this);
public void paint(Graphics g){
g.drawImage(buffer,0,0,this);
Also how can I add more than 1 .jpg in an applet since the applet tag for html is
<applet code = Video.class width =... height = ...>
<param name = "buffer" value = "Camera1.jpg"> ...and I can only put
</applet> one file for "value
Thanks a lot for ur help!

you may try the function getScaledInstance(int,int,int) in Class Image.
the first and second parameters are the width and height you want,the third parameter is hints-flags to indicate the type of algorithm to use for image resampling.

Similar Messages

  • Why can't I resize jpg in applet?

    I used this code to display images in an html page. One applet for one image. But out of the 8 images I loaded, 6 adjusted themselves to 320x240 automatically, 1 randomly jumps around to certain parts of the image every 250millisecs, and 1 just cuts the top left hand part of 320x240. How can .jpg files give 3 different situations? I tried using the resize() method in the code but it doesn't do anything! How can I size those .jpg images to the size I want?
    /**This video stream applet loads a new image every 250ms
    import java.applet.*;
    import java.awt.*;
    import java.net.*;
    import java.io.*;
    import java.awt.event.*;
    public class Video extends Applet implements Runnable{
    private Image img,buffer;
    private Thread video = null;
    private URL url;
    private MediaTracker tracker;
    public synchronized void init(){
    tracker = new MediaTracker(this);
    try{url = new URL(getCodeBase(),"Camera1.jpg");}
    catch(MalformedURLException e){}
    img = getImage(url);
    tracker.addImage(img, 0);
    buffer = createImage(320,240);
    resize(320,240);
    if(video!=null)return;
    video = new Thread(this,"VideoStream");
    video.start();
    public synchronized void destroy(){
    if(video!=null)video=null;
    public void run(){
    while(!Thread.interrupted()){
    // Load new image.
    try{tracker.waitForID(0);}
    catch(InterruptedException e){}
    // Draw new Image.
    repaint();
    // Remove old image & add new one.
    tracker.removeImage(img,0);
    img.flush();
    tracker.addImage(img,0);
    // Sleep
    try{Thread.sleep(250);}
    catch(InterruptedException e){}
    public synchronized void update(Graphics g){
    Graphics bufGraph = buffer.getGraphics();
    bufGraph.drawImage(img,0,0,this);
    paint(bufGraph);
    g.drawImage(buffer,0,0,this);
    public void paint(Graphics g){
    g.drawImage(buffer,0,0,this);
    Also how can I add more than 1 .jpg in an applet since the applet tag for html is
    <applet code = Video.class width =... height = ...>
    <param name = "buffer" value = "Camera1.jpg"> ...and I can only put
    </applet> one file for "value
    Thanks a lot for ur help!

    Try getScaledInstance(), search for it. Also, you can do anything in an Applet that you can do in an app. Check out the code samples, or the Java2D demo that comes with the JDK. There is tons of code for this, as well as a million threads you can search through.

  • Why can't I see still images in the playback monitor when editing a video?

    Why can't I see still images in the playback monitor when editing a video? I have rendered the images in the project.  I checked my system to make sure it meets all the requirements for the software, no problem there.  When I "share" the project and save it as an MPEG, the images show up in WMP just fine.  But I need to be able to see what I'm doing to the stills while I am editing.  Help!

    Gordon
    Many thanks for the reply with the details.
    But, the key is missing...what version of Premiere Elements are you using? Are you using Premiere Elements 10?
    I hope not in this case, but if you are, we will tell you what needs to be done. The following is a copy/paste of the Announcement
    at the top of this forum about the Premiere Elements 10/NVIDIA GeForce issue.
    Premiere Elements 10 NVIDIA Video Card Driver Roll Back
    If you are a Premiere Elements 10 user whose Windows computer uses a NVIDIA GeForce video card and you are experiencing
    Premiere Elements 10 display and/or unexplained program behavior, then your first line of troubleshooting needs to be rolling
    back the video card driver version instead of assuring that it is up to date.
    Since October 2013 to the present, there have been a growing number of reports about display and unexplained workflow
    glitches specific to the Premiere Elements 10 user whose Windows computer has a NVIDIA GeForce video card. If this applies
    to you, then the “user to user” remedy is to roll back the NVIDIA GeForce video card driver as far as is necessary to get rid of
    the problems. The typical driver roll back has gone back as far as March – July 2013 in order to get a working Premiere
    Elements 10. Neither NVIDIA nor Adobe has taken any corrective action in this regard to date, and none is expected moving forward.
    Since October 2013, the following thread has tried to keep up with the Premiere Elements 10 NVIDIA reports
    http://forums.adobe.com/thread/1317675
    Older NVIDIA GeForce drivers can be found
    http://www.nvidia.com/Download/Find.aspx?lang=en-us
    A February 2014 overview of the situation as well as how to use the older NVIDIA GeForce drivers for the driver roll back
    can be found
    http://atr935.blogspot.com/2014/02/pe10-nvidia-video-card-roll-back.html
    Looking forward to your reply.
    Thank you.
    ATR

  • Why can't I save an image off the net into the folder of my choice?

    I've used a PC all my life until two days ago when I bought my MacBook. I absolutely love it, but there are a few PC/Mac differences bugging me, and one of them is what I'm asking you all about:
    When I save an image off the internet and the pop-up asks me where to save it, it suggests only a few folders for me and I can't choose the folder I actually want to save the image in. Is there any way to change this? No one else seems to have asked about this on here before, but I hope someone can help me out.

    Ah, it's so simple! Thank you.

  • How can I import RW2 files into Lightroom 4?Also why can`t I see jpgs related to the same RW2 files?

    I tried ti import my RW2 camera (Lumix) raw files into Lightroom 4.4 and simply couldn`t do it. Also I had jpgs in the same folder and Lightroom didn`t bring them in at all.
    What can I do? Is there any ways or settings? Does Lightroom 5 see RW2?
    Thanks

    What Jim said.
    Either:
    Upgrade to Lightroom 5 then open the RW2 files in LR5, or
    Download the free Adobe DNG converter, convert all RW2 files to DNGs then edit the DNGs in Lightroom 4
    http://www.adobe.com/products/photoshop/extend.displayTab2.html

  • Why can't I insert an image into the header in Pages 5.0.1?

    In previouis versions of Pages, I was able to insert an image into a Header or Footer.
    This action does not appear an option in Pages 5.0.1.
    Am I missing something?
    I must say, I do not like the NEW interface. Much has been lost with the transition to the Cloud.
    I like the concept of using my iPad Air and my desktop, however functionality has been tossed out for deference to the Tablet.

    KT,
    Use a "Floating Graphic" and send it to the Section Master in the Arrange > Section Master menu. Floating is called Stays With Page now. Don't worry about it not being in the Header field. It will serve the purpose.
    Jerry

  • In the new iphoto app, why can't i save multiple images to camera roll at once?

    why can't i save multiple images to camera roll at once? it seems i can only save one at a time and its very frustrating..
    the options seem to be there, they are just greyed out and i cant click on them.
    at first i thought its because the images were too big, so i tried it with smaller images but same thing.
    APPLE HELP!

    I can confirm @khaniff's original post the option in iPhoto for iOS is greyed out in conflict with the referenced article that follows:
    Save to the Camera Roll
    Tap a photo, album, or event and tap .
    Tap Camera Roll.
    Confirm or change the photos you want to share by tapping an option.
    Select all the photos in an album or event: Tap All.
    Select a range of photos: Tap Choose, tap Range, tap the first and last photos in the range, and tap Next.
    To use your photo in another app, open the app and select the Camera Roll album.

  • Why can I no longer open images with Photoshop CS3, running on Mac OS 10.4.11?

    Why can I no longer open images with Photoshop CS3, running on Mac OS 10.4.11?

    You may be able to drag and drop the icons from one toolbar onto another, you can then hide the toolbar that you no longer need. For details on how to do that see https://support.mozilla.com/kb/How+to+customize+the+toolbar

  • Why can I not open raw images in bridge after down loading raw plug-in for my new Canon 70D?

    Why can I not open raw images in bridge after down loading raw plug-in for my new Canon 70D dozens of times?  I have never had any where near this amout of trouble with all my other Canon digital cameras. 
    <Removed by Moderator>

    http://helpx.adobe.com/creative-suite/kb/camera-raw-plug-supported-cameras.html
    http://helpx.adobe.com/x-productkb/global/camera-raw-compatible-applications.html
    Mylenium

  • I imported 635 images into an iPhoto album so that I can share them via a photo-stream. However, iPhoto says there are only 600. When I try to add the missing images it says they are already there. Why can i not see these images in iPhoto?

    I imported 635 images into an iPhoto album so that I can share them via a photo-stream. However, iPhoto says there are only 600. When I try to add the missing images it says they are already there. Why can i not see these images in iPhoto?

    Generally I would not use Facebook for sharing any photos, it compresses the photos substantially, and when you have shadows and dark colours you get visible "bands" where there should be subtle gradients, ie at sunsets and sunrises.
    It sounds like you are using two methods to upload to Facebook:
    1. Sharing from within Aperture, which basically syncs Facebook with your Aperture album, so any changes made at either end gets synced, hence the deletions from Albums, although the original file should still be in your library, just removed rom the album. It is like a playlist in iTunes.
    2. Exporting pics and uploading to Facebook from the browser.
    I am not sure how method 1 gets compressed, but I know that uploading hi-res jpegs to Facebook using method 2 results in poor quality images.
    I wouldn't even bother comparing option 1 or 2, and they will both be poor images once you view them on Facebook, as opposed to viewing uploaded images on proper image sharing / hosting sites.
    Your problem is not with Aperture, it is using Facebook for showing your work.
    If you export pics form Aperture at high res jpegs or TIFFs your images will be fine.
    If you insist to use Facebook as your way to share your work, then your workflow should be this:
    1. Right click images you want to share.
    2. Select Export version.
    3. Export as 100% size and ensure the export settings are set at 100% quality.
    4. Upload this pic into Facebook.
    This will get you the best image size and resolution on Facebook.
    See how you go.

  • I use firefox 9, why can not I save as image on google image?

    I use firefox 9, why can not I save as image on google image?

    Try the Firefox SafeMode to see how it works there. <br />
    ''A troubleshooting mode, which disables most Add-ons.'' <br />
    ''(If you're not using it, switch to the Default Theme.)''
    * You can open the Firefox 4/5/6/7 SafeMode by holding the '''Shft''' key when you use the Firefox desktop or Start menu shortcut.
    * Or use the Help menu item, click on '''Restart with Add-ons Disabled...''' while Firefox is running. <br />
    ''Don't select anything right now, just use "Continue in SafeMode."''
    ''To exit the Firefox Safe Mode, just close Firefox and wait a few seconds before using the Firefox shortcut (without the Shft key) to open it again.''
    '''''If it is good in the Firefox SafeMode''''', your problem is probably caused by an extension, and you need to figure out which one. <br />
    http://support.mozilla.com/en-US/kb/troubleshooting+extensions+and+themes
    ''When you figure out what is causing that, please let us know. It might help other user's who have that problem.''

  • Why can't I copy an image or vector from Illustrator CC and paste to Fireworks CS6?

    Why can't I copy an image or vector from Illustrator CC and paste to Fireworks CS6? This was possible with Illustrator CS6. I know they are different versions but since there is no Fireworks CC, is there a fix update???

    Yes, other users have complained about that. Unfortunately, Fireworks' development was halted a year ago, and I would be surprised if Adobe spends any money or time to fix bugs and interoperability issues in Fireworks. I would not expect any real updates or fixes.
    Tough to swallow, but FW is dead in the water and EOL'ed.

  • Why can't I  access Canon Image Gateway?

    Why can't I  access Canon Image Gateway?  It freezes on my screen after asking permission to allow storage on my computer (which it doesn't let me accept or deny)

    Mac or Win?

  • Why can't I import raw images from camera to lightroom 5.7.1?

    why can't I import raw images from camera to lightroom 5.7.1?

    You can visit the Lightroom Journal to see the new features of LR6/CC, including new cameras supported in this release:
    Lightroom Journal | Tips and advice straight from the Lightroom team.
    And yes, as DJ confirmed, the Nikon D7200 is listed.
    The the full list of supported cameras is here (Lightroom and Camera Raw have compatible engines and identical support):
    Camera Raw plug-in | Supported cameras
    Mike

  • Why can't we resize log buffers??

    Why can't we resize log buffers??
    Regards
    Vijay

    chronicscorpion wrote:
    Hi Aman,
    I have read in Oracle Docs . Will you please tell me where you have read that it can be changed? Please tell me also.
    Regards,
    VijayIf you are talking about Redo logs
    Check out http://www.oracle-dba-online.com/managing_redo_logfiles.htm
    or look at this question that was asked before in this forum
    Oracle 10g R2 Database Redo Log Files
    Check posting by Betty
    (If you have set your FAST_START_MTTR_TARGET parameter
    SQL> alter system set FAST_START_MTTR_TARGET=300;
    SQL> select optimal_logfile_size from v$instance_recovery;
    Based on the current log switch checkpointing, good estimate as you should
    at least perform 3-4 log switches per hour based on the increased size of your
    redo logfiles and do not forget to multiplex the redo logfiles onto faster
    hard drives as Mr Burleson would say in his book SSD (Solid State Drives)
    SQL> select * from v$log; (how many many members do you have 1, 2 or 3)
    SQL> select group#,member from v$logfile;
    Cheers
    Justin Miles

Maybe you are looking for