Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_java thread: Inquiry


Message #1 by "MUHAMMAD QASIM" <muhammadqasim77@h...> on Thu, 21 Jun 2001 23:47:55 +0500
This might work (but without FileDialog):

import com.sun.image.codec.jpeg.*;

...

    OutputStream out = your output stream;

    Image img = your image;

try {

     // create a BufferedImage

     int w = (int)img.getWidth(null);
     int h = (int)img.getHeight(null);

     BufferedImage buffImg = new BufferedImage(w,h, 
BufferedImage.TYPE_INT_RGB);
     Graphics g = buffImg.createGraphics();

     g.drawImage(img, 0, 0, null);
     g.dispose();

     // save it

     JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
     encoder.encode(buffImg);
     out.close();
}
catch (Exception ex) {
}



>From: "MUHAMMAD QASIM" <muhammadqasim77@h...>
>Reply-To: "Professional Java" <pro_java@p...>
>To: "Professional Java" <pro_java@p...>
>Subject: [pro_java] Inquiry
>Date: Thu, 21 Jun 2001 23:47:55 +0500
>
>Sir,
>    How I can save an image (.jpg or .gif) using FileDialog.
>In other Words ,I have opened the Image using package java.awt,after
>processing the image data I want to save the transformed Image. So how to
>Serialize(Save on Hard Disk) an image in JAVA 2.
>
>from
>
>Qasim
>
>muhammadqasim77@h...
>
>



  Return to Index