Skip to content

Commit

Permalink
GH-314 optimize encoding.
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Corless committed Feb 3, 2024
1 parent b5aef05 commit 357b96b
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,17 +170,23 @@ public static void encodeColorKeyMask(ImageStream imageStream) {
maskMinGreen = maskMinRGB[1];
maskMinBlue = maskMinRGB[2];
}
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
int argb = image.getRGB(x, y);

int[] srcBand = new int[width];
// iterate over each band to apply the mask
for (int i = 0; i < height; i++) {
image.getRGB(0, i, width, 1, srcBand, 0, width);
// apply the soft mask blending
for (int j = 0; j < width; j++) {
int argb = srcBand[j];
int alpha = ((argb >> 24) & 0xFF);
if (alpha == 0x00) {
argb = maskMinRed << 16
| maskMinGreen << 8
| maskMinBlue;
image.setRGB(x, y, argb);
srcBand[j] = argb;
}
}
image.setRGB(0, i, width, 1, srcBand, 0, width);
}
imageStream.setDecodedImage(image);
}
Expand Down

0 comments on commit 357b96b

Please sign in to comment.