gwlucastrig commented on a change in pull request #106:
URL: https://github.com/apache/commons-imaging/pull/106#discussion_r522528975



##########
File path: src/main/java/org/apache/commons/imaging/common/ImageBuilder.java
##########
@@ -242,16 +266,29 @@ private BufferedImage makeBufferedImage(
         WritableRaster raster;
         final DataBufferInt buffer = new DataBufferInt(argb, w * h);
         if (useAlpha) {
-            colorModel = new DirectColorModel(32, 0x00ff0000, 0x0000ff00,
-                    0x000000ff, 0xff000000);
-            raster = Raster.createPackedRaster(buffer, w, h,
-                    w, new int[]{0x00ff0000, 0x0000ff00, 0x000000ff,
-                            0xff000000}, null);
+            colorModel = new DirectColorModel(
+                    ColorSpace.getInstance(ColorSpace.CS_sRGB),

Review comment:
       Just finished looking through Java documentation and I got to say I 
cannot believe how complicated this stuff is. Who would of thought something 
like color would have such an elaborate set of support classes.
   
   Anyway, I'm not really sure of the implications of this, but the Java API 
documentation for the Color class says "The default color space for the Java 
2D(tm) API is sRGB, a proposed standard RGB color space. For further 
information on sRGB, see http://www.w3.org/pub/WWW/Graphics/Color/sRGB.html ".  
 That's what led me to use the declaration you saw.  I also ran a quick test 
program to see what was the default used by BufferedImage:
   
          BufferedImage bImage = new BufferedImage(10, 10, 
BufferedImage.TYPE_INT_RGB);
           ColorSpace cSpace = bImage.getColorModel().getColorSpace();
           ColorSpace linearRGB = 
ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB);
           ColorSpace sRGB = ColorSpace.getInstance(ColorSpace.CS_sRGB);
           System.out.println("Compare to Linear RGB " + 
cSpace.equals(linearRGB));  // printed out "false"
           System.out.println("Compare to sRGB       " + cSpace.equals(sRGB));  
     // printed out "true"
   
   




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to