Skip to content

Commit 10c8fb6

Browse files
committed
Compare actual RGB values when comparing image datas with palette data
For image datas without palette data (direct palettes) the code before worked ok because the getPixel's returned value was the direct color. But for palette images, the getPixel returns the index. When an index is used, you need to call getRGB to get the real data value. Part of #2126
1 parent 8dd8b53 commit 10c8fb6

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/graphics/ImageDataTestHelper.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,9 @@ public static Comparator<ImageData> imageDataComparator() {
223223
.thenComparing((ImageData firstData, ImageData secondData) -> {
224224
for (int x = 0; x < firstData.width; x++) {
225225
for (int y = 0; y < firstData.height; y++) {
226-
if (firstData.getPixel(x, y) != secondData.getPixel(x, y)) {
226+
RGB first = firstData.palette.getRGB(firstData.getPixel(x, y));
227+
RGB second = secondData.palette.getRGB(secondData.getPixel(x, y));
228+
if (!first.equals(second)) {
227229
return -1;
228230
}
229231
if (firstData.getAlpha(x, y) != secondData.getAlpha(x, y)) {

0 commit comments

Comments
 (0)