While using 16-bit high color(R:5bit, G:6bit, B:5bit)graphics
due to resource limitation, the background color of panel is specified as
light gray, but the color of repaint area is not drawn by that color. In the
case of background color setting, the value generated by
sun.awt.image.PixelConverter class is used. However, when rendering like
repaint, the value of Ushort565Rgb class which is an inner class of
PixelConverter is used. Due to this difference in the values used, colors do
not match.
The difference between the two values is as follows:
java.awt.image.ColorModel cm = new
java.awt.image.DirectColorModel(16,0xf800,0x7e0,0x1f);
...
A =
sun.awt.image.PixelConverter.instance.rgbToPixel(java.awt.Color.lightGray,cm);
// value of background color
B =
sun.awt.image.PixelConverter.Ushort565Rgb.instance.rgbToPixel(java.awt.Color.l
ightGray,cm); //value of repaint color
A -> #bdf7:10111 101111 10111
B -> #c618:11000 110000 11000
java.awt.Color.lightGray = #c0c0c0:11000000 11000000 11000000
Each one is getting the correct value. 0xbdf7 is set as the background color
of window and 0xc618 is set to the drawing color of fillRect() called by
repaint. Therefore, when part of the Panel is redrawn, the phenomenon occurs
that only the area is different in color.