Skip to content

Commit

Permalink
try
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Oct 7, 2023
1 parent 35b95df commit 9e75715
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Tests/test_lib_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from PIL import Image

mode_names = (
"BGR;15",
"BGR;16",
"BGR;24",
)

Expand Down
11 changes: 9 additions & 2 deletions src/_imaging.c
Original file line number Diff line number Diff line change
Expand Up @@ -3760,9 +3760,10 @@ _compare_pixels(
// Fortunately, all of the modes that have extra bytes in their pixels use four bytes for their pixels.
UINT32 mask = 0xffffffff;
if (
!strcmp(mode, "RGB") || !strcmp(mode, "YCbCr") ||
!strcmp(mode, "HSV") || !strcmp(mode, "LAB")
!strcmp(mode, "RGB") || !strcmp(mode, "BGR;24") ||
!strcmp(mode, "YCbCr") || !strcmp(mode, "HSV") || !strcmp(mode, "LAB")
) {
printf("threeinfour\n");
// These modes have three channels in four bytes,
// so we have to ignore the last byte.
#ifdef WORDS_BIGENDIAN
Expand All @@ -3774,13 +3775,17 @@ _compare_pixels(
// These modes have two channels in four bytes,
// so we have to ignore the middle two bytes.
mask = 0xff0000ff;
printf("twoinfour\n");
} else {
printf("else\n");
}

if (mask == 0xffffffff) {
// If we aren't masking anything we can use memcmp.
int y;
for (y = 0; y < ysize; y++) {
if (memcmp(pixels_a[y], pixels_b[y], linesize)) {
printf("full fail\n");
return 1;
}
}
Expand All @@ -3792,11 +3797,13 @@ _compare_pixels(
UINT32 *line_b = (UINT32*)pixels_b[y];
for (x = 0; x < xsize; x++, line_a++, line_b++) {
if ((*line_a & mask) != (*line_b & mask)) {
printf("mask fail linea %d lineb %d mask %d lineamask %d linebmask %d\n", *line_a, *line_b, mask, *line_a & mask, *line_b & mask);
return 1;
}
}
}
}
printf("success %d\n", mask);
return 0;
}

Expand Down

0 comments on commit 9e75715

Please sign in to comment.