Skip to content

Commit 027c912

Browse files
sago35deadprogram
authored andcommitted
pixel: correct RGB555 to RGBA conversion logic
1 parent 5847506 commit 027c912

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

pixel/pixel.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,9 @@ func (c RGB555) BitsPerPixel() int {
161161

162162
func (c RGB555) RGBA() color.RGBA {
163163
color := color.RGBA{
164-
R: uint8(c>>10) << 3,
165-
G: uint8(c>>5) << 3,
166-
B: uint8(c) << 3,
164+
R: (uint8(c) & 0x1F) << 3,
165+
G: (uint8(c>>5) & 0x1F) << 3,
166+
B: (uint8(c>>10) & 0x1F) << 3,
167167
A: 255,
168168
}
169169
// Correct color rounding, so that 0xff roundtrips back to 0xff.

0 commit comments

Comments
 (0)