Loading Images jpg, gif, png

What is the most effective way to load an image in my application?
Bellow is how i am currently loading the image:
private void drawMap() {
Graphics g = this.picturePanel.getGraphics();
Image img = Toolkit.getDefaultToolkit().getImage(getClass().getResource("/images/claymonmap.gif"));
g.drawImage(img,0,0,this);
This method works however it takes sometime for the image to show. The method is called from a button action, and the image wont display unless I have pressed the button alteast two times. I do not need to do an manipulation to the image simply display it.
I was hopeing for a more instantaneous result.
Your input would be greatly appreciated.

I changed to using imageicon and i found that its is much quicker thanks.
however i am having troubles with the method bellow. When i click a certain button the focus on a tabbed pane goes to buildingPicturePanel, and the picture flashes up for a microsecond and then the panel goes blank again. The picture wont show till i click the button again.
void getBuildingPic(String id) {
Graphics gBuilding = this.buildingPicturePanel.getGraphics();
ClassLoader cldr = this.getClass().getClassLoader();
String pathBuildPic = "images/"+ id +".jpg";
java.net.URL imageURL = cldr.getResource(pathBuildPic);
ImageIcon img = new ImageIcon(imageURL);
img.paintIcon(this.buildingPicturePanel, gBuilding, 0, 0);
could this be becuase the way i am painting the icon?

Similar Messages

  • Want to smooth loaded images (jpg) in flash8

    i want to smooth loaded images (jpg) in flash8
    let's say that i have one layer, one frame and the following
    AS:
    _root.loadMovie("q.jpg");
    the _root could be an object, but the behavior is the same
    so in flash7 CTRL+ENTER, right click and zoom ---> RESULT:
    zoom with image interpolation (like photoshop bicubic resample)
    but in flash8 CTRL+ENTER, right click and zoom --->
    RESULT: zoom with NO image interpolation (like photoshop nearest
    nei ghbor resample)
    why?????
    i have looked in help but all i can find is somthing refering
    about images in the library. I want external jpgs!!!
    i have done a slideshow with setable tranzitions (fade, blur,
    moving, zoom in/out, external loaded masking)
    here is some the important part of the my code (not important
    for my problem, but I just want to say that i've worked about 1-2
    days and i want to make it better. is frustating that i have blur,
    fade, gradient transparency (blending) and not a smooth image):
    Gtime=getTimer(); //global timmer
    ///////////////////////////////ia datele generale, daca cele
    particulare lipsesk
    /*Ttrans=eval("q.tt")-0;*/
    if(eval("q.tt"+pidx))Ttrans=eval("q.tt"+pidx)-0;
    /*Tfoto=eval("q.tf")-0;*/
    if(eval("q.tf"+pidx))Tfoto=eval("q.tf"+pidx)-0;
    /*sv=eval("q.sv")-0;*/
    if(eval("q.sv"+pidx))sv=eval("q.sv"+pidx)-0;
    /*sk=eval("q.sk")-0;*/
    if(eval("q.sk"+pidx))sk=eval("q.sk"+pidx)-0;
    /*xv=eval("q.xv")-0;*/
    if(eval("q.xv"+pidx))xv=eval("q.xv"+pidx)-0;
    /*yv=eval("q.yv")-0;*/
    if(eval("q.yv"+pidx))yv=eval("q.yv"+pidx)-0;
    /*xk=eval("q.xk")-0;*/
    if(eval("q.xk"+pidx))xk=eval("q.xk"+pidx)-0;
    /*yk=eval("q.yk")-0;*/
    if(eval("q.yk"+pidx))yk=eval("q.yk"+pidx)-0;
    /*rv=eval("q.rv")-0;*/
    if(eval("q.rv"+pidx))rv=eval("q.rv"+pidx)-0;
    /*rk=eval("q.rk")-0;*/
    if(eval("q.rk"+pidx))rk=eval("q.rk"+pidx)-0;
    /*xbk=eval("q.xbk")-0;*/
    if(eval("q.xbk"+pidx))xbk=eval("q.xbk"+pidx)-0;
    /*ybk=eval("q.ybk")-0;*/
    if(eval("q.ybk"+pidx))ybk=eval("q.ybk"+pidx)-0;
    /*xbv=eval("q.xbv")-0;*/
    if(eval("q.xbv"+pidx))xbv=eval("q.xbv"+pidx)-0;
    /*ybv=eval("q.ybv")-0;*/
    if(eval("q.ybv"+pidx))ybv=eval("q.ybv"+pidx)-0;
    /*mask=eval("q.mask");*/
    if(eval("q.mask"+pidx))mask=eval("q.mask"+pidx);
    if(trans==0 && Gtime>Ftime+Tfoto*1000){
    //retain values
    aux2=(Gtime-Ttime)*100/((Ttrans*2+Tfoto)*1000);
    Ttrans2=Ttrans;
    Tfoto2=Ttrans;
    sv2=sv;sk2=sk;
    xv2=xv;yv2=yv;
    xk2=xk;yk2=yk;
    rv2=rv;rk2=rk;
    xbv2=xbv;ybv2=ybv;
    xbk2=xbk;ybk2=ybk;
    //end retain values
    Ttime=Gtime;
    trans=1;//transition
    if(p=="p1"){
    p="p2";pp="p1";
    }else{
    p="p1";pp="p2";
    pidx++;
    if(eval("q.p"+pidx)==undefined){
    end=1;
    //gotoAndStop(6);
    }else{
    p1.swapDepths(p2);
    loadMovie(fotofolder+eval("q.p"+pidx),eval(p+".p.p"));
    eval(p)._xscale=eval(p)._yscale=100;
    eval(p)._rotation=0;
    if(trans==1 && Gtime>Ttime+Ttrans*1000){
    Ftime=Gtime;
    trans=0;//not transition
    //tranzition
    if(trans==1){
    if(mask.length>3)
    eval(p)._alpha=100;
    else
    eval(p)._alpha=(Gtime-Ttime)*100/(Ttrans*1000);
    aux=(Gtime-Ttime)*100/((Ttrans*2+Tfoto)*1000)
    eval(p)._x=xv*aux+xk;
    eval(p)._y=yv*aux+yk;
    eval(p)._xscale=eval(p)._yscale=sv*aux+100+sk;
    eval(p)._rotation=rv*aux+rk;
    blur.blurX=aux*xbv+xbk;
    blur.blurY=aux*ybv+ybk;
    eval(p).p.p.filters = [blur];
    //intarzierea
    aux=aux+aux2;
    eval(pp)._x=xv2*aux+xk2;
    eval(pp)._y=yv2*aux+yk2;
    eval(pp)._xscale=eval(pp)._yscale=sv2*aux+100+sk2;
    eval(pp)._rotation=rv2*aux+rk2;
    if(!end)gotoAndPlay(_currentframe-1);
    ////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////

    See
    http://www.kaourantin.net/2005/12/dynamically-loading-bitmaps-with.html
    danredman wrote:
    > i want to smooth loaded images (jpg) in flash8
    >
    > let's say that i have one layer, one frame and the
    following AS:
    >
    _root.loadMovie("q.jpg");
    >
    > the _root could be an object, but the behavior is the
    same
    >
    > so in flash7 CTRL+ENTER, right click and zoom --->
    RESULT: zoom with image
    > interpolation (like photoshop bicubic resample)
    > but in flash8 CTRL+ENTER, right click and zoom --->
    RESULT: zoom with NO image
    > interpolation (like photoshop nearest nei ghbor
    resample)
    >
    > why?????
    >
    > i have looked in help but all i can find is somthing
    refering about images in
    > the library. I want external jpgs!!!
    > i have done a slideshow with setable tranzitions (fade,
    blur, moving, zoom
    > in/out, external loaded masking)
    >
    >
    > here is some the important part of the my code:
    >
    > Gtime=getTimer(); //global timmer
    >
    > ///////////////////////////////ia datele generale, daca
    cele particulare
    > lipsesk
    > /*Ttrans=eval("q.tt")-0;*/
    if(eval("q.tt"+pidx))Ttrans=eval("q.tt"+pidx)-0;
    > /*Tfoto=eval("q.tf")-0;*/
    if(eval("q.tf"+pidx))Tfoto=eval("q.tf"+pidx)-0;
    > /*sv=eval("q.sv")-0;*/
    if(eval("q.sv"+pidx))sv=eval("q.sv"+pidx)-0;
    > /*sk=eval("q.sk")-0;*/
    if(eval("q.sk"+pidx))sk=eval("q.sk"+pidx)-0;
    > /*xv=eval("q.xv")-0;*/
    if(eval("q.xv"+pidx))xv=eval("q.xv"+pidx)-0;
    > /*yv=eval("q.yv")-0;*/
    if(eval("q.yv"+pidx))yv=eval("q.yv"+pidx)-0;
    > /*xk=eval("q.xk")-0;*/
    if(eval("q.xk"+pidx))xk=eval("q.xk"+pidx)-0;
    > /*yk=eval("q.yk")-0;*/
    if(eval("q.yk"+pidx))yk=eval("q.yk"+pidx)-0;
    > /*rv=eval("q.rv")-0;*/
    if(eval("q.rv"+pidx))rv=eval("q.rv"+pidx)-0;
    > /*rk=eval("q.rk")-0;*/
    if(eval("q.rk"+pidx))rk=eval("q.rk"+pidx)-0;
    > /*xbk=eval("q.xbk")-0;*/
    if(eval("q.xbk"+pidx))xbk=eval("q.xbk"+pidx)-0;
    > /*ybk=eval("q.ybk")-0;*/
    if(eval("q.ybk"+pidx))ybk=eval("q.ybk"+pidx)-0;
    > /*xbv=eval("q.xbv")-0;*/
    if(eval("q.xbv"+pidx))xbv=eval("q.xbv"+pidx)-0;
    > /*ybv=eval("q.ybv")-0;*/
    if(eval("q.ybv"+pidx))ybv=eval("q.ybv"+pidx)-0;
    > /*mask=eval("q.mask");*/
    if(eval("q.mask"+pidx))mask=eval("q.mask"+pidx);
    >
    >
    > /
    >
    >
    > if(trans==0 && Gtime>Ftime+Tfoto*1000){
    > //retain values
    > aux2=(Gtime-Ttime)*100/((Ttrans*2+Tfoto)*1000);
    > Ttrans2=Ttrans;
    > Tfoto2=Ttrans;
    > sv2=sv;sk2=sk;
    > xv2=xv;yv2=yv;
    > xk2=xk;yk2=yk;
    > rv2=rv;rk2=rk;
    > xbv2=xbv;ybv2=ybv;
    > xbk2=xbk;ybk2=ybk;
    > //end retain values
    > Ttime=Gtime;
    > trans=1;//transition
    >
    > if(p=="p1"){
    > p="p2";pp="p1";
    > }else{
    > p="p1";pp="p2";
    > }
    > pidx++;
    > if(eval("q.p"+pidx)==undefined){
    > end=1;
    > //gotoAndStop(6);
    > }else{
    > p1.swapDepths(p2);
    > loadMovie(fotofolder+eval("q.p"+pidx),eval(p+".p.p"));
    > eval(p)._xscale=eval(p)._yscale=100;
    > eval(p)._rotation=0;
    > }
    > }
    > if(trans==1 && Gtime>Ttime+Ttrans*1000){
    > Ftime=Gtime;
    > trans=0;//not transition
    > }
    > //tranzition
    >
    > if(trans==1){
    > if(mask.length>3)
    > eval(p)._alpha=100;
    > else
    > eval(p)._alpha=(Gtime-Ttime)*100/(Ttrans*1000);
    > }
    > aux=(Gtime-Ttime)*100/((Ttrans*2+Tfoto)*1000)
    > eval(p)._x=xv*aux+xk;
    > eval(p)._y=yv*aux+yk;
    > eval(p)._xscale=eval(p)._yscale=sv*aux+100+sk;
    > eval(p)._rotation=rv*aux+rk;
    > blur.blurX=aux*xbv+xbk;
    > blur.blurY=aux*ybv+ybk;
    > eval(p).p.p.filters = [blur];
    > //intarzierea
    > aux=aux+aux2;
    > eval(pp)._x=xv2*aux+xk2;
    > eval(pp)._y=yv2*aux+yk2;
    > eval(pp)._xscale=eval(pp)._yscale=sv2*aux+100+sk2;
    > eval(pp)._rotation=rv2*aux+rk2;
    >
    > if(!end)gotoAndPlay(_currentframe-1);
    >

  • How to show an image(jpg/gif) on a JTabbedPanel

    Hi
    I tried to show an image on a JPanel of a JTabbedPanel.
    I the only way to show it for some time was this:
    in the StateChangedListener I use drawImage when the selected panel is teh one I want to draw the image at.
    Tracing code makes the panel show, burt when I step
    all the way up, the panel will be repainted without my image.
    I use mediatracker to get the image loaded.
    Any Idea
    Hanns

    JTabbedPane has components as its tabs. Using a JPanel is not mandatory. Try using a JLabel instead with an Icon (use ImageIcon) in it.
    JTabbedPane tabbed = new JTabbedPane();
    tabbed.addTab(
        "my image panel",
        new JLabel( new ImageIcon( "images/MyIcon.gif" ) )
    );if your were referring to the image of the little tabs, use this:
    JTabbedPane tabbed = new JTabbedPane();
    tabbed.addTab(
        "my tab",
        new ImageIcon( "images/MyImage.gif" ),
        myPanel // instance of Component, can be a JPanel or any JComponent you want.
    );

  • How to replace wecenter default loading image(ss.gif).

    Hi All ,
    I am working on webcenter customization .
    Can anyone provide me how to replace webcenter default loading image which appears before webcenter content gets loaded .
    Appreciate any prompt response .
    Thanks ,
    Arun.

    If it's the splash screen you speak of, a custom skin defining these selectors may work - af|document::splash-screen, af|document::splash-screen-content, af|document::splash-screen-message and af|document::splash-screen-icon.
    Please note that I have not tried these myself.

  • Why do the file extensions (.jpg .gif .png) no longer appear when I click on a previously saved image to use that image's file name (particularly important when saving a series of images using the same root name)?

    I save a lot of images using firefox, often times from a large batch or series of images. It used to be that I would click on a previously saved image and the entire file name including the file extension (i.e. image_example.jpg) would appear in the "save as" line. Now when I click on a previously saved file, the file name appears without the file extension (i.e. image_example). Which means I have to manually type .jpg every time. For a large collection of images that I am hoping to use the same root file name and then add chronological numbers at the end, this has become incredibly frustrating, especially as it is a previously unnecessary task.
    I am using a new Macbook Pro and maybe there's something Apple related to this...? It did not happen on my old PowerBook G4. I have file extensions turned on in System Preferences.
    It should be noted that I have searched high and low and have even gone into the Apple Genius Bar where they were just confused as I was and of course ended by urging me to use Safari (shocker!) as it has all kinds of new extensions and bells and whistles. I seriously feel alone on an island with this dumb, hard to google problem. Thanks so much for any help anyone out there might have.
    I mean: is this as simple as changing a setting in about:config?
    Your assistance is greatly appreciated.

    Thanks for your response Mylenium, however like I mentioned multiple times, I did change all of my trackpad/scrolling settings in system preferences.  And if I wanted to use a normal mouse (or a tablet), I would've gotten an iMac instead of a MacBook Pro.  I travel often and work all over the place, not always with access to a decently sized workspace that would be required for using a mouse or tablet.

  • Incredibly strange file size discrepancy only appears in image files (jpg, gif, png)!

    I'm creating a bunch of banners for google ads, yahoo ads, ...etc in Photoshop on my Mac OS!
    The .gif files of these banners appear to TRIPLE in size when on the MAC (>150KB), but when transferred to windows; the real file size shows correctly! (<50KB)
    It is not a result of the base2 vs base10 discrepancy since the difference in size is simply too big, and it only happens with files created on Photoshop on my Mac.
    The reason I know that windows is showing the correct size while my Mac OS is displaying the wrong size, is that the file gets approved by google and yahoo ads, even though Mac OS shows that it surpasses the size limit (50KB) three times over!
    This isn't an isolated incident either, all image files created in Photoshop on the MAC continue this weird behaviour! However, files downloaded from the net appear to be consistent on both operating systems!
    One example is the attached screenshot:
    Explanation, please??

    Geez, sorry I offended you Mr. Jobs (incarnate)!
    You came in here with a three ton chip on your shoulders. Did you really expect sunshine and puppies in return?
    No, I expected useful help, and I got it from Jeffrey Jones. Thanks again Jeffrey!
    I mean, when you move or upload it, it loses this data association anyways!
    To a drive which doesn't support Apple's AB tree structure (NTFS, FAT, FAT32, exFAT), yes. To another HFS+ drive, no.
    What about uploading the file to the cloud?? Does it lose this association or not?? And does anyone really care about the data in the Resource fork?
    This "Resource Fork" means nothing to the file owner, only to the OS and the Drive. Therefore, it shouldn't be added to the total. Period. Because its not part of the file, its part of Apple's tree structure! This is really a simple concept, not sure why you are bending over backwords to defend a clearly stupid oversight from apple!
    There's no reason to force me to use the command line to get the real file size of a GIF! There's just no excuse for that!
    If an OS is saying it is fetching file size information for a single file, it should do exactly that! Not add hidden Resource Forks that are part of the OS's internal workings
    OS X is fetching the file size. It's file size, not the way a different OS would report it.
    There is no such thing as it's file size. A file size is a file size, accross all platforms, on the cloud, wherever!
    A GIF file should have the same file size whether its on windows, linux, unix, darwin, freeBSD, or anything else. The only time its weight should vary is in outer space!
    That is why I'm surprised that they are breaking simple UI Design rules.
    The User Interface has nothing to do with the file structure of a drive.
    I don't care about the structure of the drive!! Neither should you, neither should the average user!
    A good UI should NOT concern the user with this! The average user doesn't care about these Resource Forks, and will never try to view them, therefore, there is no logical reason to add up their file sizes to the total size of each file, and then to make things worse, hide that fact! That only creates confusion, and it makes it so much harder for a designer like myself to view the REAL file sizes of my image files! Now, whenever I'm on my MAC, I will have to run command line scripts to be able to see if my GIF files (that I work on EVERYDAY) meet the file size quota, because Mac OS adds up hidden files that I have no use for and gives me the WRONG file size!
    Let's say this again: when you select a file and click get info, you should get the info for the file you selcted. Nothing more, nothing less! I don't care if the file structure creates an entire colony of hidden files, they should be completely hidden to me, and if not, the Get Info dialog box should at least give me two sizes, one is the REAL file size, and the other is the added up file size for the Resource Fork as well (although I can't think of any good reason why it should add up the Resource Fork size anyways)!
    do you think it is at all logical, that when you select 300 or so files, and click Get Info, that it open 300 windows at once each showing separate information for each file? Or does it make a lot more sense, intuitively, to get the total tally of all the files selected added up, without having to hold down shortcut keys when clicking them to do so?
    Yes, it is logical because that's what you, the user, told the OS to do. You wanted the Get Info data on 300 individual items. I don't know about you, but I avoid the menu bar as much as possible (your reference to avoiding shortcut keys). Command+I will always give you singular Get Info dialogue boxes.
    No, that's not what I told the OS to do. I selected 300 files cumulatively, therefore, I should get the cumulative info for all the selected files. That's just common sense. Every other OS seems to get this!
    And I'm hard pressed to find anyone who has found a use for having 300 get info boxes open at the same time. Therefore, that shouldn't be the default.
    Will you start defending apple's decision to stick with the one button mouse for all these years depriving us from the all important context menu as well?? There was absolutely no good reason to do that, just as there is absolutely no good reason to do this!

  • Serverside conversion of PDF to Image (JPEG, GIF, PNG)

    Hello JDCers.....
    I am currently looking for a serverside component (or some info on how to build one).... that will allow on the fly conversion of pdf to an image format on my web server...
    Any help would be greatly appreciated....
    Thanks
    Fahim

    here is some code that does the trick...
    import java.awt.Graphics2D;
    import java.awt.RenderingHints;
    import java.awt.image.BufferedImage;
    import java.awt.image.RenderedImage;
    import java.io.ByteArrayInputStream;
    import java.io.ByteArrayOutputStream;
    import java.io.File;
    import java.util.Vector;
    import javax.imageio.ImageIO;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletResponse;
    import com.sun.media.jai.codec.ImageCodec;
    import com.sun.media.jai.codec.ImageDecoder;
    import com.sun.media.jai.codec.ImageEncoder;
    import com.sun.media.jai.codec.PNGEncodeParam;
    import com.sun.media.jai.codec.SeekableStream;
    import com.sun.media.jai.codec.TIFFDecodeParam;
    import com.sun.media.jai.codec.TIFFDirectory;
    import multivalent.Behavior;
    import multivalent.Context;
    import multivalent.Document;
    import multivalent.Node;
    import multivalent.std.adaptor.pdf.PDF;
    public class PDFToPNG extends HttpServlet {
         private static final long serialVersionUID = 1L;
         public byte[] ConvertToPngImage(byte[] tiffRawData, HttpServletResponse res)
                   throws Exception {
              Vector pngs = new Vector();
              // set stream to the tiff url
              SeekableStream tiffStream = SeekableStream.wrapInputStream(
                        new ByteArrayInputStream(tiffRawData), true);
              // how many pages in one tiff
              int pageNumber = TIFFDirectory.getNumDirectories(tiffStream);
              TIFFDecodeParam decodeParam = new TIFFDecodeParam();
              decodeParam.setDecodePaletteAsShorts(true);
              ImageDecoder tiffDecoder = ImageCodec.createImageDecoder("tiff",
                        tiffStream, decodeParam);
              // for (int p = 0; p < pageNumber; p ++) {
              // render the current page
              RenderedImage tiffPage = tiffDecoder.decodeAsRenderedImage();
              PNGEncodeParam png = PNGEncodeParam.getDefaultEncodeParam(tiffPage);
              // The png stream is outputted to a file. Change the directory
              // accordingly.
              ByteArrayOutputStream baos = new ByteArrayOutputStream();
              // Gets a PNG encoder.
              ImageEncoder pngEncoder = ImageCodec.createImageEncoder("PNG", baos,png);
              // Encodes the RenderedImage object.
              pngEncoder.encode(tiffPage);
              byte[] content = baos.toByteArray();
              baos.close();
              return content;
         public static void main(String args[]) {
              File outfile = new File("c:\\file.png");
              try {
                   PDF pdf = (PDF) Behavior.getInstance("AdobePDF", "AdobePDF", null,
                             null, null);
                   File file = new File("c:\\somepdf.pdf");
                   pdf.setInput(file);
                   Document doc = new Document("doc", null, null);
                   pdf.parse(doc);
                   doc.clear();
                   doc.putAttr(Document.ATTR_PAGE, Integer.toString(1));
                   pdf.parse(doc);
                   Node top = doc.childAt(0);
                   doc.formatBeforeAfter(200, 200, null);
                   int w = top.bbox.width;
                   int h = top.bbox.height;
                   BufferedImage img = new BufferedImage(w, h,
                             BufferedImage.TYPE_INT_RGB);
                   Graphics2D g = img.createGraphics();
                   g.setClip(0, 0, w, h);
                   g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
                             RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
                   g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                             RenderingHints.VALUE_ANTIALIAS_ON);
                   g.setRenderingHint(RenderingHints.KEY_RENDERING,
                             RenderingHints.VALUE_RENDER_QUALITY);
                   Context cx = doc.getStyleSheet().getContext(g, null);
                   top.paintBeforeAfter(g.getClipBounds(), cx);
                   ImageIO.write(img, "png", outfile);
                   doc.removeAllChildren();
                   cx.reset();
                   g.dispose();
                   pdf.getReader().close();
                   outfile = null;
                   doc = null;
              } catch (Exception e) {
    }

  • Optimial file format - gif, jpg, or png automatic?

    Is there a way to have photoshop to easily and automatically determine and save a file in the format that is the smallest file size?  I upload dozens of files to my web site each day, and instead of saving as each format to see which one is smaller, I'd like photoshop, or another program, to automatically determine which format will result in the smallest file.
    Thanks,
    DownAndOut

    It seems odd to me is that more image editing programs do not offer the functionality that I am inquiring about. I found hundreds of posts accross the internet that say "save as .jpg/.gif/.png to see which one is the smallest". This seems time consuming when a program (when saving) could display the size that the file would save in each format, allowing the user to select which format they wish to save in.
    The "general" rule that photographic type images save smaller as .jpg may be the case in general, but does not apply on our web site http://www.mysavings.com. Our content editors upload 300x250 and 120x60 (thumbnails) of the same image. Even when the images are of photographic nature, the 120x60 seem to usually 50% smaller as .gifs, while the same image as 300x250 are 25% smaller .jpg. 50% on is large and really affects loadt ime when we are talking about 2 images on the page. So we are having to adopt a general rule that save the 120x60 as .gif and the 300x250 as .jpg, regardless of the content of the picture. Our image editors do not have the time to save in both formats just to see which is smaller. 
    It just seems logical that a program could show you the resulting file sizes for each format when saving so you can choose which is smaller. Regardless of affecting quality, because I see no noticeable difference in quality when I just save these images as a .jpg or .gif, the only difference I notice is the file size.

  • Jpg,gif, and gui's

    hey guys, I just started learning to code gui's... but my book is vague about inserting jpg or gif.....
    I was using:
    ImageIcon b = new ImageIcon("board.jpg");
    I keep getting a blank canvas..
    Can someone help me with siimple code for making a gui with just a picture in it
    thx

    @OP...
    1) The convention used in your sample code assumes
    that the image source file is in the executing
    directory or classpath.... if not you will need to
    provide the full path...
    eg: "C:/Some
    Directory/SomeOtherDir/Myimage.jpg/.gif/,png"or in a directory off the root:
    root-
    /images
    /classes
    /com
    /whatever
    Then ImageIcon icon = new ImageIcon("images/myImage.gif"); will load
    >
    2) If the Image is large, (not in size only, btw),
    you need to use an ImageTracker or you could resort
    to the
    Toolkit.getDefaultToolkit().getImage("somePath")
    method to ensure that the Image is loaded to
    completion prior to the gui being rendered.. any
    delays will see the ImageIcon being updated after the
    gui is rendered, naturally producing no image.....
    ImageIcon uses a ImageTracker to load images

  • Method to load images while blocking thread

    Hi!
    I'm new to Java and have been researching how to do the following for hours with no real success:
    I need a way to load an image (jpg/gif/what have you) while blocking the thread it is running in.
    I do not really want to use MediaTracker because it feels much too complicated for what I need. Here is a code snippet:
    private Thread getImages = new Thread(
              new Runnable(){
                   public void run() {
                        while(!imgNameList.isEmpty()){
    String imagePath = imgNameList.remove(0);
                             ImageIcon image = new ImageIcon(getDocumentBase(), imagePath);
                             if(image.getImageLoadStatus() == java.awt.MediaTracker.COMPLETE) {
                                  imgList.add(image);
                             This thread is initiated by my applet, and I just want it to do something very simple. I want it to load ALL the images from the URLs in imgNameList ArrayList<String> and if they are valid images, add them to the imgList ArrayList<ImageIcon>.
    I do not understand why my code does not work.
    I have read in multiple places that ImageIcon blocks the thread. But the condition mage.getImageLoadStatus() == java.awt.MediaTracker.COMPLETE is not ever true.
    I am totally exasperated by this inexplicable behaviour.
    Any advice will be greatly appreciated.
    Many thanks.

    Thanks for the replies.
    The URLs were correct.
    ImageIcon already implements MediaTracker by itself in the background, so I really don't want to have to do it myself.
    The status was always 4.. ERRORED.. even if the image loaded just fine anyway, as in I could display it after.
    I suspect it may be some strange thing due to Applet permissions or something of that sort. Eventually I gave up, so I just did as follows:
    ImageIcon to load the image.
    Get the height of the ImageIcon to do two things:
    A) Make sure that the image is actually loaded (not just returning right away like GetImage)
    B) Make sure it's a valid image (i.e. height greater than 0)
    When I have some time I'll look over this carefully but for now it works so it'll have to do.

  • Resizing loading image of the portal

    Hello Xperts,
    I have a requirement where I want to resize the loading image loading_ani.gif.
    I was able to replace the default image and put client specific image. Now I want to increase height of the default place holder that holds the image.
    Any helpful suggestion will be highly appreciated.
    Thank you,
    Ashutosh

    Hey Santosh,
    Theme allowed me to change the default image. Which is already done.
    But I did not find a way to specify the size of the image.
    Any idea?
    Ashutosh

  • How to load image data into cube?? Is it possible??

    How to load image data into cube?? Is it possible??
    Any sugession??

    Hi Andre,
    Document will be of ASCII characters right?? but image data will be in binary format. as per database concept it is stored as binary large object. But in datawarehousing the back end is also going to be some database such as Oracle or other DBs.
    which can take blob's. so it would be possible to store the binary data.
    If any one has faced this situation can reply.to this ques.
    can post the step to load image(jpg/bmp or any image format) data in to info cube??
    hi andre if u have done loading image data as you say.pls reply me if you have the steps with you.
    thanks Andre

  • How to convert raster images like( PNG, JPG,GIF, BMP, TIFF etc) into SVG

    Hi Friends!
    With a hope that any Java Guru from SUN Forum can help me to solve my query, I'm posting my thread here.
    I have a project with feature to add image. My requirement is to convert any selected image file like (PNG,JPG,BMP,Tiff) into SVG Formate before adding it to Frame.
    I found one software from the link :
    http://delineate.sourceforge.net/
    Which covert raster to SVG.
    But I don't how can i use it runtime ?
    I want to convert during runtime process. like when user select option for to add Image then it call a procedure to add Image by converting any raster to svg & finally add to Frame.
    Your any help/suggestions wold be appreciated
    Regards
    Kirti

    There are basically two approaches:
    1. Embed the raster image in the SVG
    2. Vectorize the image
    1. Use Batik, or just write the XML yourself. Create some SVG files with embedded images, the syntax isn't to difficult. You could do it with a PrintWriter.
    2. Good luck to you. Writing a good vectorizer is
    - difficult
    - often pointless
    - though a great challenge if you're in to it
    The appllication you mention actually is only a front-end. it doesn't execute the vectorization itself. It uses Potrace and autotrace, which are native applications.

  • Loading transparent background gif on an image

    Hello everyone! I am trying to load a transparent background gif([http://www.aoml.noaa.gov/hrd/tcfaq/graphics/animehurr.gif]) on another image (which is a map). My way is adding two JPanels, each of them will load an image as an ImageIcon, however, the gif will display its transparent background as white. So, I googled the problem, it seems someone has a similar problem([t-681840]). I think the background area is not transparent due to the wrong container under the image, but I have no clue to make it right. I appeciated anyone can post a comment, or give me some advice.
    I attach my code as following.
        jPanel1 = new JPanel();
        getContentPane().add(jPanel1);
        jPanel1.setBounds(12, 10, 647, 358);
        ImageIcon iconMap = new ImageIcon("C:\\1\\com\\lfhsolutions\\trackthis\\images\\Map.JPG"); 
        JLabel label1 = new JLabel(); 
        label1.setIcon(iconMap);  
        jPanel1.add(label1);  
        this.getContentPane().add(jPanel1);
        setVisible(true);
        jPanel2 = new JPanel();
        getContentPane().add(jPanel2);
        jPanel2.setBounds(330, 200, 50, 46);
        ImageIcon iconHurricane = new ImageIcon("C:\\1\\com\\lfhsolutions\\trackthis\\images\\hurricane1.gif");
        JLabel label2 = new JLabel();
        label2.setIcon(iconHurricane);
        jPanel2.add(label2);
        this.getContentPane().add(jPanel2);
        setVisible(true);

    Sorry if my code bothers u, camickr !
    I am a noob for java and thie forum. I am not quite sure how a SSCCE should look at, but I will post code as below.
    import java.awt.BorderLayout;
    import java.awt.Canvas;
    import java.awt.Image;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.List;
    import javax.swing.GroupLayout;
    import javax.swing.ImageIcon;
    import javax.swing.JButton;
    import javax.swing.JComponent;
    import javax.swing.JLabel;
    import javax.swing.JMenu;
    import javax.swing.JMenuBar;
    import javax.swing.JMenuItem;
    import javax.swing.JOptionPane;
    import javax.swing.JPanel;
    import javax.swing.JTextArea;
    import javax.swing.JTextField;
    import javax.swing.LayoutStyle;
    import javax.swing.WindowConstants;
    import javax.swing.SwingUtilities;
    public class NewJFrame1 extends javax.swing.JFrame {
      //Set Look & Feel
      try {
       javax.swing.UIManager.setLookAndFeel("com.jgoodies.looks.plastic.Plastic3DLookAndFeel");
      } catch(Exception e) {
       e.printStackTrace();
    private JPanel jPanel2;
    private JPanel jPanel1;
    * Auto-generated main method to display this JFrame
    public static void main(String[] args) {
      SwingUtilities.invokeLater(new Runnable() {
       public void run() {
        NewJFrame1 inst = new NewJFrame1();
        inst.setLocationRelativeTo(null);
        inst.setVisible(true);
    public NewJFrame1() {
      super("Hurricane Tracker to Oil and Gas Producers");
      initGUI();
    private void initGUI() {
      try {
       setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
       getContentPane().setLayout(null);
        jPanel1 = new JPanel();
        getContentPane().add(jPanel1);
        jPanel1.setBounds(12, 10, 647, 358);
        ImageIcon iconMap = new ImageIcon("C:\\1\\com\\lfhsolutions\\trackthis\\images\\Map.JPG"); 
        JLabel label1 = new JLabel(); 
        label1.setIcon(iconMap);  
        jPanel1.add(label1);  
        this.getContentPane().add(jPanel1);
        setVisible(true);
        jPanel2 = new JPanel();
        getContentPane().add(jPanel2);
        jPanel2.setBounds(330, 200, 50, 46);
        ImageIcon iconHurricane = new ImageIcon("C:\\1\\com\\lfhsolutions\\trackthis\\images\\hurricane1.gif");
        JLabel label2 = new JLabel();
        label2.setIcon(iconHurricane);
        jPanel2.add(label2);
        this.getContentPane().add(jPanel2);
        setVisible(true);
       pack();
       this.setSize(806, 549);
      } catch (Exception e) {
       e.printStackTrace();
    }}

  • Making jpg or png images in Java...

    Hello everyone,
    Can anyone please post a simple class that simply does the following:
    //Create some sort of image
    Graphics g = image.getGraphics();
    g.fillRect(...);
    //Export the image to a jpg file: e.g. a.jpg/a.png
    Thank you

    import java.awt.*;
    import java.awt.geom.Ellipse2D;
    import java.awt.image.BufferedImage;
    import java.io.*;
    import javax.imageio.ImageIO;
    import javax.swing.*;
    public class Imaging {
        public static void main(String[] args) throws IOException {
            BufferedImage image = getImage(200, 200);
            // jpg, png, bmp (j2se 1.5), gif (j2se 1.6)
            String fileName = "imaging.jpg";
            saveImage(image, fileName);
            showImage(fileName);
        private static BufferedImage getImage(int w, int h) {
            int type = BufferedImage.TYPE_INT_RGB;
            BufferedImage image = new BufferedImage(w, h, type);
            Graphics2D g2 = image.createGraphics();
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                                RenderingHints.VALUE_ANTIALIAS_ON);
            g2.setPaint(new GradientPaint(0,0,Color.red,w,h,Color.orange));
            g2.fillRect(0,0,w,h);
            g2.setPaint(Color.cyan);
            double d = Math.min(w, h)/4;
            g2.fill(new Ellipse2D.Double(w/2-d/2, h/2-d/2, d, d));
            g2.dispose();
            return image;
        private static void saveImage(BufferedImage image, String fileName)
                                              throws IOException {
            File file = new File(fileName);
            int dot = fileName.lastIndexOf(".");
            String ext = fileName.substring(dot+1);
            ImageIO.write(image, ext, file);
        private static void showImage(String fileName) throws IOException {
            BufferedImage image = ImageIO.read(new File(fileName));
            JOptionPane.showMessageDialog(null, new ImageIcon(image),
                                          fileName, JOptionPane.PLAIN_MESSAGE);
    }

Maybe you are looking for