Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix color when decoding image 4444 #10

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ public static BufferedImage decodeImage4444(final byte[] data, final int offset,
for (int y = 0; y < targetHeight; y++) {
for (int x = 0; x < targetWidth; x++) {
final int pixel = buffer.getShort() & 0xffff;
final int r = ((pixel & 0xF)) * 16;
final int b = ((pixel & 0xF)) * 16;
final int g = ((pixel & 0xF0) >> 4) * 16;
final int b = ((pixel & 0xF00) >> 8) * 16;
final int r = ((pixel & 0xF00) >> 8) * 16;
final int a = ((pixel & 0xF000) >> 12) * 16;
p += 2;
img.setRGB(x, y, new Color(r, g, b, a).getRGB());
Expand Down Expand Up @@ -82,7 +82,7 @@ public static BufferedImage decodeImage4444split(final byte[] data, final int of
for (int y = 0; y < targetHeight; y++) {
for (int x = 0; x < targetWidth; x++) {
final int pixel = buffer.getShort() & 0xffff;
final int r = 255 - ((pixel & 0xF)) * 16;
final int r = 255 - ((pixel & 0xF)) * 16; //potential bug: red and blue may be inverted
final int g = 255 - ((pixel & 0xF0) >> 4) * 16;
final int b = 255 - ((pixel & 0xF00) >> 8) * 16;
final int a = 255 - ((pixel & 0xF000) >> 12) * 16;
Expand All @@ -107,7 +107,7 @@ public static BufferedImage decodeImage4444split1channel(final byte[] data, fina
buffer.position(offset);

int p = 0;
final int r = 0;
final int r = 0; //potential bug: red and blue may be inverted
final int g = 0;
final int b = 0;
switch (channel) {
Expand Down Expand Up @@ -716,4 +716,4 @@ private ImageDecoding() throws InstantiationException {
throw new InstantiationException();
}

}
}