Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Problem with transparency in png images on Mac OS X

Reply
Thread Tools

Problem with transparency in png images on Mac OS X

 
 
kasper@kau.dk
Guest
Posts: n/a
 
      03-26-2006
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(bufferedI mage, 0, 0, null);

bufferedImages.put(image, bufferedImageOpt);

Does anyone know how to fix this problem?

/Kasper

 
Reply With Quote
 
 
 
 
Steve W. Jackson
Guest
Posts: n/a
 
      03-27-2006
In article <(E-Mail Removed) .com>,
"(E-Mail Removed)" <(E-Mail Removed)> wrote:

> 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(buffe redImage.getWidth(),
> bufferedImage.getHeight(), transparency);
> bufferedImageOpt.getGraphics().drawImage(bufferedI mage, 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 =
--
Steve W. Jackson
Montgomery, Alabama
 
Reply With Quote
 
 
 
 
Oliver Wong
Guest
Posts: n/a
 
      03-27-2006

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> 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(bufferedI mage, 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

 
Reply With Quote
 
steve
Guest
Posts: n/a
 
      03-27-2006
On Mon, 27 Mar 2006 02:43:26 +0800, http://www.velocityreviews.com/forums/(E-Mail Removed) wrote
(in article <(E-Mail Removed) .com>):

> 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(buffe redImage.getWidth(),
> bufferedImage.getHeight(), transparency);
> bufferedImageOpt.getGraphics().drawImage(bufferedI mage, 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

--
NewsGuy.Com 30Gb $9.95 Carry Forward and On Demand Bandwidth
 
Reply With Quote
 
kasper@kau.dk
Guest
Posts: n/a
 
      04-05-2006
Ok, I will do that. It seems to be a bug in the virtual machine for
Mac. I saw a post here:
http://forum.java.sun.com/thread.jspa?messageID=4176658 with the exact
same problem.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating a 24-bit PNG with binary transparency? Leif K-Brooks HTML 7 07-20-2009 09:40 AM
png transparency and IE problem zik Javascript 4 04-10-2008 08:10 PM
png transparency with PIL Robin Becker Python 2 11-23-2007 10:17 PM
PIL 1.1.4 paste PNG's with transparency problem Caleb Hattingh Python 2 12-01-2004 02:39 AM
PNG graphics transparency Jens Lenge HTML 9 10-15-2004 06:48 PM



Advertisments