Jpeg images not proper in MAC
hi
i am saving a component to a jpeg image with the code line
ImageIO.write( image, "jpg", file );
this code works fine when component is saved in windows but in case of Mac the image created becomes black. Can anyone tell me where the problem is or is there something else i should do while saving in mac
ps: i tried with following code too but same result
JPEGImageEncoder jpgencoder = JPEGCodec.createJPEGEncoder(out);
jpgencoder.encode(image);
[495 byte] By [
Trushanta] at [2007-10-3 3:46:56]

Odd. Have you tried cycling through all the available JPEG encoders, if there's more than one available, and writing a differently-named file from each, to see if it's just one failing or all of them?
Anything unusual about the image? What's the transfer type, color model, how are you obtaining it? For example using transparency might cause an issue, since it's not supported by JPEG.
there is panel from which i create a buffered image and the buffered image is written ...the following code is what i use
BufferedImage image = (BufferedImage)_component.createImage( _component
.getWidth(), _component.getHeight() );
Graphics2D g = (Graphics2D)image.getGraphics();
if( g.getClipBounds() != null)
{
g.setClip( 0, 0, _component.getWidth(), _component.getHeight() );
}
_component.paint( g );
ImageIO.write( image, "jpg", file );
Hi
I got the soultion. Instead of converting component to buffered image directly ... convert the component to image and then the image to buffered image. THis way the image get created correctly.
Image image = (Image)_component.createImage( _component.getWidth(),
_component.getHeight() );
//image converted to buffered image
BufferedImage bufferedImage = new BufferedImage ( _component.getWidth(),
_component.getHeight() , BufferedImage.TYPE_INT_BGR );
Graphics2D g = (Graphics2D)image.getGraphics();
_component.paint( g ); // draw the component on image
bufferedImage.createGraphics().drawImage( image, 0, 0, null);
ImageIO.write( bufferedImage, "jpg", file );