BufferedImage & createScreenCapture produces wrong colors

前端 未结 1 1031
误落风尘
误落风尘 2021-01-06 10:31

In my Java program I need to analyze a color of a pixel in given coordinates. Because of the fact that I need to do it often, first I capture a part of the screen, and then

相关标签:
1条回答
  • 2021-01-06 11:19

    It is most likely due to the color model.

    According to this code it uses a DirectColorModel (see below) regardless of your color depth of your screen.

    /*
     * Fix for 4285201
     * Create a DirectColorModel equivalent to the default RGB ColorModel,
     * except with no Alpha component.
     */
    screenCapCM = new DirectColorModel(24,
                     /* red mask */    0x00FF0000,
                     /* green mask */  0x0000FF00,
                     /* blue mask */   0x000000FF);
    
    0 讨论(0)
提交回复
热议问题