• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Jpeg images not proper in MAC

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi
i am saving a component to a jpeg image(converting component to buffered 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 OS X the image created gets a reddish tint . Can anyone tell me where the problem is or is there something else i should do while saving to jpeg images in mac

ps: i tried with following code too but same result
JPEGImageEncoder jpgencoder = JPEGCodec.createJPEGEncoder(out);
jpgencoder.encode(image);
 
Trushant Patil
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 );
 
You learn how to close your eyes and tell yourself "this just isn't really happening to me." Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic