Problem with transparency in png images on Mac OS X

K

kasper

Hi,

I have a problem with png-24 images on VM 1.4.2 on Mac OS X. The
semitransparent areas in the images does not display correcly on Mac.
Here is the code I use to load the BufferedImages:

BufferedInputStream in = getBufferedInputStream(image);

BufferedImage bufferedImage = ImageIO.read(in);
in.close();

//Optimize buffered image to environment
BufferedImage bufferedImageOpt =
GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration().createCompatibleImage(bufferedImage.getWidth(),
bufferedImage.getHeight(), transparency);
bufferedImageOpt.getGraphics().drawImage(bufferedImage, 0, 0, null);

bufferedImages.put(image, bufferedImageOpt);

Does anyone know how to fix this problem?

/Kasper
 
S

Steve W. Jackson

Hi,

I have a problem with png-24 images on VM 1.4.2 on Mac OS X. The
semitransparent areas in the images does not display correcly on Mac.
Here is the code I use to load the BufferedImages:

BufferedInputStream in = getBufferedInputStream(image);

BufferedImage bufferedImage = ImageIO.read(in);
in.close();

//Optimize buffered image to environment
BufferedImage bufferedImageOpt =
GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().get
DefaultConfiguration().createCompatibleImage(bufferedImage.getWidth(),
bufferedImage.getHeight(), transparency);
bufferedImageOpt.getGraphics().drawImage(bufferedImage, 0, 0, null);

bufferedImages.put(image, bufferedImageOpt);

Does anyone know how to fix this problem?

/Kasper

What problem exactly? It's unclear to me what your code is trying to
do. Java reads PNG natively and, so far as I know, handles its
transparency without issue.

= Steve =
 
O

Oliver Wong

Hi,

I have a problem with png-24 images on VM 1.4.2 on Mac OS X. The
semitransparent areas in the images does not display correcly on Mac.
Here is the code I use to load the BufferedImages:

BufferedInputStream in = getBufferedInputStream(image);

BufferedImage bufferedImage = ImageIO.read(in);
in.close();

//Optimize buffered image to environment
BufferedImage bufferedImageOpt =
GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration().createCompatibleImage(bufferedImage.getWidth(),
bufferedImage.getHeight(), transparency);
bufferedImageOpt.getGraphics().drawImage(bufferedImage, 0, 0, null);

bufferedImages.put(image, bufferedImageOpt);

Does anyone know how to fix this problem?

I can't directly see anything wrong with your code. Are you implying
that you've triedthis on other systems and it works fine? Have you tried
putting your PNG in a JLabel, for example, to test if it handles the
semitransparency correctly? If not, then the problem may be with your VM,
rather than with your code.

Alternatively, post up an SSCCE, and we can try using our own
semi-transparent PNGs and see if it displays correctly on our OSes.

- Oliver
 
S

steve

Hi,

I have a problem with png-24 images on VM 1.4.2 on Mac OS X. The
semitransparent areas in the images does not display correcly on Mac.
Here is the code I use to load the BufferedImages:

BufferedInputStream in = getBufferedInputStream(image);

BufferedImage bufferedImage = ImageIO.read(in);
in.close();

//Optimize buffered image to environment
BufferedImage bufferedImageOpt =
GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().get

DefaultConfiguration().createCompatibleImage(bufferedImage.getWidth(),
bufferedImage.getHeight(), transparency);
bufferedImageOpt.getGraphics().drawImage(bufferedImage, 0, 0, null);

bufferedImages.put(image, bufferedImageOpt);

Does anyone know how to fix this problem?

/Kasper

if it is truly a bug, contact jeff lemas at apple , by filing a bug
report.


Steve
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,754
Messages
2,569,525
Members
44,997
Latest member
mileyka

Latest Threads

Top