|
From: | mathieu dot baron at gmail dot com |
Subject: | [Bug classpath/37126] New: gnu.javax.imageio.bmp.DecodeRGB24.decode() do not decode correcxtly some colors |
Date: | 15 Aug 2008 12:58:35 -0000 |
gnu.javax.imageio.bmp.DecodeRGB24.decode() do not decode some pixels correctly. Current code: for(int x=0;x<w;x++) data[x + y*w] = ((scanline[x*3]) + // Red ((scanline[x*3+1] << 8)) + // Green ((scanline[x*3+2] << 16))); // Blue Example: Fuchsia color (0x00FF00FF) Red --> 0xFF --> (Byte) 0xFF --> -1 Green --> 0x00 --> (Byte) 0x00 --> 0 Blue --> 0xFF --> (Byte) 0xFF --> -1 Current Encode Color Algorithm: Red + (Green << 8) + (Blue << 16) -1 + 0 + -65536 == -65537 = 0xFFFFFEFF The encoded color is not the expected one: 0xFFFFFEFF != (0x00FF00FF) Fuchsia Proposed solution: 1. Use a mask to isolate byte color values 2. Use the OR bitwise operator to merge pixel's RGB values Example: for(int x=0;x<w;x++) data[x + y*w] = ((scanline[x*3] & 0x000000FF) | // Red ((scanline[x*3+1] << 8) & 0x0000FF00) | // Green ((scanline[x*3+2] << 16) & 0x00FF0000)); // Blue -- Summary: gnu.javax.imageio.bmp.DecodeRGB24.decode() do not decode correcxtly some colors Product: classpath Version: 0.97.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: classpath AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: mathieu dot baron at gmail dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37126
[Prev in Thread] | Current Thread | [Next in Thread] |