java buffered image created with red mask

前端 未结 6 1686
忘了有多久
忘了有多久 2020-12-04 02:49

I am having trouble reading an image. If I do the following

URL url = new URL(\"http://tctechcrunch2011.files.wordpress.com/2012/10/gmm.jpg\");
ImageInputSt         


        
6条回答
  •  無奈伤痛
    2020-12-04 03:37

    ImageIcon mySourceImage = new ImageIcon(sourceImageFile.getAbsolutePath());
    BufferedImage sourceImage = new BufferedImage(mySourceImage.getIconWidth(),  mySourceImage.getIconHeight(), BufferedImage.TYPE_3BYTE_BGR);
    Graphics2D g2d2 = (Graphics2D) sourceImage.getGraphics();
    mySourceImage.paintIcon(null, g2d2, 0, 0);
    g2d2.dispose();
    

    The code above DOES NOT use Image.read which (quite probably) contains a bug. It doesn't produce red images. But I'm not sure about colorspace in BufferedImage third parameter.

提交回复
热议问题