@@ -3799,15 +3799,16 @@ Skips unused bytes based on the given mode.
37993799*/
38003800static int
38013801_compare_pixels (
3802- const char * mode , const int ysize , const int linesize ,
3803- const UINT8 * * pixels_a , const UINT8 * * pixels_b
3804- ) {
3805- // Fortunately, all of the modes that have extra bytes in their pixels use four bytes for their pixels.
3802+ const char * mode ,
3803+ const int ysize ,
3804+ const int linesize ,
3805+ const UINT8 * * pixels_a ,
3806+ const UINT8 * * pixels_b ) {
3807+ // Fortunately, all of the modes that have extra bytes in their pixels use four
3808+ // bytes for their pixels.
38063809 UINT32 mask = 0xffffffff ;
3807- if (
3808- !strcmp (mode , "RGB" ) || !strcmp (mode , "YCbCr" ) ||
3809- !strcmp (mode , "HSV" ) || !strcmp (mode , "LAB" )
3810- ) {
3810+ if (!strcmp (mode , "RGB" ) || !strcmp (mode , "YCbCr" ) || !strcmp (mode , "HSV" ) ||
3811+ !strcmp (mode , "LAB" )) {
38113812 // These modes have three channels in four bytes,
38123813 // so we have to ignore the last byte.
38133814#ifdef WORDS_BIGENDIAN
@@ -3833,8 +3834,8 @@ _compare_pixels(
38333834 const int xsize = linesize / 4 ;
38343835 int y , x ;
38353836 for (y = 0 ; y < ysize ; y ++ ) {
3836- UINT32 * line_a = (UINT32 * )pixels_a [y ];
3837- UINT32 * line_b = (UINT32 * )pixels_b [y ];
3837+ UINT32 * line_a = (UINT32 * )pixels_a [y ];
3838+ UINT32 * line_b = (UINT32 * )pixels_b [y ];
38383839 for (x = 0 ; x < xsize ; x ++ , line_a ++ , line_b ++ ) {
38393840 if ((* line_a & mask ) != (* line_b & mask )) {
38403841 return 1 ;
@@ -3861,13 +3862,10 @@ image_richcompare(const ImagingObject *self, const PyObject *other, const int op
38613862 }
38623863
38633864 const Imaging img_a = self -> image ;
3864- const Imaging img_b = ((ImagingObject * )other )-> image ;
3865+ const Imaging img_b = ((ImagingObject * )other )-> image ;
38653866
3866- if (
3867- strcmp (img_a -> mode , img_b -> mode )
3868- || img_a -> xsize != img_b -> xsize
3869- || img_a -> ysize != img_b -> ysize
3870- ) {
3867+ if (strcmp (img_a -> mode , img_b -> mode ) || img_a -> xsize != img_b -> xsize ||
3868+ img_a -> ysize != img_b -> ysize ) {
38713869 if (op == Py_EQ ) {
38723870 Py_RETURN_FALSE ;
38733871 } else {
@@ -3882,18 +3880,14 @@ image_richcompare(const ImagingObject *self, const PyObject *other, const int op
38823880 const UINT8 * palette_b_data = palette_b -> palette ;
38833881 const UINT8 * * palette_a_data_ptr = & palette_a_data ;
38843882 const UINT8 * * palette_b_data_ptr = & palette_b_data ;
3885- if (
3886- !palette_a || !palette_b
3887- || palette_a -> size != palette_b -> size
3888- || strcmp (palette_a -> mode , palette_b -> mode )
3889- || _compare_pixels (
3883+ if (!palette_a || !palette_b || palette_a -> size != palette_b -> size ||
3884+ strcmp (palette_a -> mode , palette_b -> mode ) ||
3885+ _compare_pixels (
38903886 palette_a -> mode ,
38913887 1 ,
38923888 palette_a -> size * 4 ,
38933889 palette_a_data_ptr ,
3894- palette_b_data_ptr
3895- )
3896- ) {
3890+ palette_b_data_ptr )) {
38973891 if (op == Py_EQ ) {
38983892 Py_RETURN_FALSE ;
38993893 } else {
@@ -3902,15 +3896,12 @@ image_richcompare(const ImagingObject *self, const PyObject *other, const int op
39023896 }
39033897 }
39043898
3905- if (
3906- _compare_pixels (
3899+ if (_compare_pixels (
39073900 img_a -> mode ,
39083901 img_a -> ysize ,
39093902 img_a -> linesize ,
39103903 (const UINT8 * * )img_a -> image ,
3911- (const UINT8 * * )img_b -> image
3912- )
3913- ) {
3904+ (const UINT8 * * )img_b -> image )) {
39143905 if (op == Py_EQ ) {
39153906 Py_RETURN_FALSE ;
39163907 } else {
@@ -3932,32 +3923,32 @@ static PyTypeObject Imaging_Type = {
39323923 sizeof (ImagingObject ), /*tp_basicsize*/
39333924 0 , /*tp_itemsize*/
39343925 /* methods */
3935- (destructor )_dealloc , /*tp_dealloc*/
3936- 0 , /*tp_vectorcall_offset*/
3937- 0 , /*tp_getattr*/
3938- 0 , /*tp_setattr*/
3939- 0 , /*tp_as_async*/
3940- 0 , /*tp_repr*/
3941- 0 , /*tp_as_number*/
3942- & image_as_sequence , /*tp_as_sequence*/
3943- 0 , /*tp_as_mapping*/
3944- 0 , /*tp_hash*/
3945- 0 , /*tp_call*/
3946- 0 , /*tp_str*/
3947- 0 , /*tp_getattro*/
3948- 0 , /*tp_setattro*/
3949- 0 , /*tp_as_buffer*/
3950- Py_TPFLAGS_DEFAULT , /*tp_flags*/
3951- 0 , /*tp_doc*/
3952- 0 , /*tp_traverse*/
3953- 0 , /*tp_clear*/
3926+ (destructor )_dealloc , /*tp_dealloc*/
3927+ 0 , /*tp_vectorcall_offset*/
3928+ 0 , /*tp_getattr*/
3929+ 0 , /*tp_setattr*/
3930+ 0 , /*tp_as_async*/
3931+ 0 , /*tp_repr*/
3932+ 0 , /*tp_as_number*/
3933+ & image_as_sequence , /*tp_as_sequence*/
3934+ 0 , /*tp_as_mapping*/
3935+ 0 , /*tp_hash*/
3936+ 0 , /*tp_call*/
3937+ 0 , /*tp_str*/
3938+ 0 , /*tp_getattro*/
3939+ 0 , /*tp_setattro*/
3940+ 0 , /*tp_as_buffer*/
3941+ Py_TPFLAGS_DEFAULT , /*tp_flags*/
3942+ 0 , /*tp_doc*/
3943+ 0 , /*tp_traverse*/
3944+ 0 , /*tp_clear*/
39543945 (richcmpfunc )image_richcompare , /*tp_richcompare*/
3955- 0 , /*tp_weaklistoffset*/
3956- 0 , /*tp_iter*/
3957- 0 , /*tp_iternext*/
3958- methods , /*tp_methods*/
3959- 0 , /*tp_members*/
3960- getsetters , /*tp_getset*/
3946+ 0 , /*tp_weaklistoffset*/
3947+ 0 , /*tp_iter*/
3948+ 0 , /*tp_iternext*/
3949+ methods , /*tp_methods*/
3950+ 0 , /*tp_members*/
3951+ getsetters , /*tp_getset*/
39613952};
39623953
39633954#ifdef WITH_IMAGEDRAW
0 commit comments