Problem with transparency in png images on Mac OS X

Discussion in 'Java' started by kasper@kau.dk, Mar 26, 2006.

  1. Guest

    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
     
    , Mar 26, 2006
    #1
    1. Advertising

  2. In article <>,
    "" <> 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(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 =
    --
    Steve W. Jackson
    Montgomery, Alabama
     
    Steve W. Jackson, Mar 27, 2006
    #2
    1. Advertising

  3. Oliver Wong Guest

    <> wrote in message
    news:...
    > 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
     
    Oliver Wong, Mar 27, 2006
    #3
  4. steve Guest

    On Mon, 27 Mar 2006 02:43:26 +0800, wrote
    (in article <>):

    > 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

    --
    NewsGuy.Com 30Gb $9.95 Carry Forward and On Demand Bandwidth
     
    steve, Mar 27, 2006
    #4
  5. Guest

    , Apr 5, 2006
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jens Lenge

    PNG graphics transparency

    Jens Lenge, Oct 12, 2004, in forum: HTML
    Replies:
    9
    Views:
    436
    Jeffrey Silverman
    Oct 15, 2004
  2. Leif K-Brooks
    Replies:
    7
    Views:
    12,738
    Froggy
    Jul 20, 2009
  3. Caleb Hattingh
    Replies:
    2
    Views:
    2,106
    Caleb Hattingh
    Dec 1, 2004
  4. Robin Becker

    png transparency with PIL

    Robin Becker, Nov 23, 2007, in forum: Python
    Replies:
    2
    Views:
    425
    Robin Becker
    Nov 23, 2007
  5. zik

    png transparency and IE problem

    zik, Apr 9, 2008, in forum: Javascript
    Replies:
    4
    Views:
    138
    Doug Gunnoe
    Apr 10, 2008
Loading...

Share This Page