problem while regenerating jpg file from swing image.

Discussion in 'Java' started by Roja, Jan 7, 2005.

  1. Roja

    Roja Guest

    Hi,

    I am trying to regenerate the jpg file with the image that is
    generated by java swings. But the x,y positions are not matching from
    swing generated image to jpg file generated.Any body worked on the
    similar problem please suggest.

    Thanks in advance.
    Roja, Jan 7, 2005
    #1
    1. Advertising

  2. Roja

    Ann Guest

    "Roja" <> wrote in message
    news:...
    > Hi,
    >
    > I am trying to regenerate the jpg file with the image that is
    > generated by java swings. But the x,y positions are not matching from
    > swing generated image to jpg file generated.Any body worked on the
    > similar problem please suggest.
    >
    > Thanks in advance.


    This is what I use, works great.
    HTH
    Ann...................................................
    I = (BufferedImage)createImage(width, height);
    try
    {
    File dir = new File(".");
    File fn = File.createTempFile("myImage", ".jpg", dir);
    String p = fn.getCanonicalPath();
    FileOutputStream fos = new FileOutputStream(p);
    JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(fos);
    JPEGEncodeParam par = encoder.getDefaultJPEGEncodeParam(I);
    par.setQuality(0.30F, true);
    encoder.setJPEGEncodeParam(par);
    encoder.encode(I);
    fos.flush();
    fos.close();
    }
    catch (FileNotFoundException e)
    {
    System.out.println(e);
    }
    catch (IOException ioe)
    {
    System.out.println(ioe);
    }
    Ann, Jan 7, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. GMartin
    Replies:
    1
    Views:
    383
    Jordan Richard
    May 4, 2005
  2. Roland
    Replies:
    0
    Views:
    1,042
    Roland
    May 12, 2004
  3. Nathan Sokalski

    Regenerating the *.aspx.designer.vb file

    Nathan Sokalski, Jan 31, 2009, in forum: ASP .Net
    Replies:
    0
    Views:
    523
    Nathan Sokalski
    Jan 31, 2009
  4. Nathan Sokalski

    Regenerating the *.aspx.designer.vb file

    Nathan Sokalski, Sep 28, 2009, in forum: ASP .Net
    Replies:
    1
    Views:
    680
    Patrice
    Sep 28, 2009
  5. Vlastimil Brom
    Replies:
    5
    Views:
    297
    Vlastimil Brom
    Nov 19, 2010
Loading...

Share This Page