user1800825
user1800825

Reputation: 203

distorted color of images in java swing gui

I have for example the following picture displayed in my gui:

http://www.zielpunkt.at/image/produkte/1354097303-airwick.jpg

Unfortunately the colors are distorted (pink background):

My code:

URL pictureURL = new URL(product.getBild()); 
            BufferedImage myPicture = ImageIO.read(pictureURL);
            JLabel picLabel = new JLabel(new ImageIcon( myPicture ));
            c.fill = GridBagConstraints.HORIZONTAL;
            c.gridwidth = 2;
            c.gridx = 0;
            c.gridy = 5;
            panel.add(picLabel,c);

Looking forwart to your answers! Regards,

screenshot

Most of my images look like this, but when I look at the graphic on the url it looks normal.

Upvotes: 1

Views: 362

Answers (1)

trashgod
trashgod

Reputation: 205875

As noted here, the "pinkish tint" may be due to misinterpreted transparency information. As shown here, "one simple expedient is to render the image" into a compatible BufferedImage.

Upvotes: 4

Related Questions