2828 wb * (b1 - b2) * (b1 - b2)) / \
2929 255.0)
3030
31- // TODO: once things are fully ported, consolidate PXM_GET_PIXELVALS
32- // and PXM_GET_PIXELVALS_1 back into GET_PIXELVALS and GET_PIXELVALS_1
33- // from surface.h
34- #define PXM_GET_PIXELVALS (_sR , _sG , _sB , _sA , px , fmt , palette , ppa ) \
35- PG_GetRGBA(px, fmt, palette, &(_sR), &(_sG), &(_sB), &(_sA)); \
36- if (!ppa) { \
37- _sA = 255; \
38- }
39-
40- #define PXM_GET_PIXELVALS_1 (sr , sg , sb , sa , _src , _palette ) \
41- sr = _palette->colors[*((Uint8 *)(_src))].r; \
42- sg = _palette->colors[*((Uint8 *)(_src))].g; \
43- sb = _palette->colors[*((Uint8 *)(_src))].b; \
44- sa = 255;
45-
4631#define WR_NTSC 0.299
4732#define WG_NTSC 0.587
4833#define WB_NTSC 0.114
@@ -422,7 +407,7 @@ _replace_color(pgPixelArrayObject *array, PyObject *args, PyObject *kwds)
422407 for (x = 0 ; x < dim0 ; ++ x ) {
423408 px_p = pixel_p ;
424409 if (distance != 0.0 ) {
425- PXM_GET_PIXELVALS_1 (r2 , g2 , b2 , a2 , px_p , palette );
410+ GET_PIXELVALS_1 (r2 , g2 , b2 , a2 , px_p , palette );
426411 if (COLOR_DIFF_RGB (wr , wg , wb , r1 , g1 , b1 , r2 , g2 ,
427412 b2 ) <= distance ) {
428413 * px_p = (Uint8 )rcolor ;
@@ -446,8 +431,8 @@ _replace_color(pgPixelArrayObject *array, PyObject *args, PyObject *kwds)
446431 for (x = 0 ; x < dim0 ; ++ x ) {
447432 px_p = (Uint16 * )pixel_p ;
448433 if (distance != 0.0 ) {
449- PXM_GET_PIXELVALS (r2 , g2 , b2 , a2 , (Uint32 )* px_p ,
450- format , palette , ppa );
434+ GET_PIXELVALS (r2 , g2 , b2 , a2 , (Uint32 )* px_p , format ,
435+ palette , ppa );
451436 if (COLOR_DIFF_RGB (wr , wg , wb , r1 , g1 , b1 , r2 , g2 ,
452437 b2 ) <= distance ) {
453438 * px_p = (Uint16 )rcolor ;
@@ -482,8 +467,8 @@ _replace_color(pgPixelArrayObject *array, PyObject *args, PyObject *kwds)
482467 ((Uint32 )pixel_p [Goffset ] << 8 ) +
483468 ((Uint32 )pixel_p [Boffset ]));
484469 if (distance != 0.0 ) {
485- PXM_GET_PIXELVALS (r2 , g2 , b2 , a2 , pxcolor , format ,
486- palette , ppa );
470+ GET_PIXELVALS (r2 , g2 , b2 , a2 , pxcolor , format , palette ,
471+ ppa );
487472 if (COLOR_DIFF_RGB (wr , wg , wb , r1 , g1 , b1 , r2 , g2 ,
488473 b2 ) <= distance ) {
489474 pixel_p [Roffset ] = (Uint8 )(rcolor >> 16 );
@@ -512,8 +497,8 @@ _replace_color(pgPixelArrayObject *array, PyObject *args, PyObject *kwds)
512497 for (x = 0 ; x < dim0 ; ++ x ) {
513498 px_p = (Uint32 * )pixel_p ;
514499 if (distance != 0.0 ) {
515- PXM_GET_PIXELVALS (r2 , g2 , b2 , a2 , * px_p , format ,
516- palette , ppa );
500+ GET_PIXELVALS (r2 , g2 , b2 , a2 , * px_p , format , palette ,
501+ ppa );
517502 if (COLOR_DIFF_RGB (wr , wg , wb , r1 , g1 , b1 , r2 , g2 ,
518503 b2 ) <= distance ) {
519504 * px_p = rcolor ;
@@ -632,7 +617,7 @@ _extract_color(pgPixelArrayObject *array, PyObject *args, PyObject *kwds)
632617 for (x = 0 ; x < dim0 ; ++ x ) {
633618 px_p = pixel_p ;
634619 if (distance != 0.0 ) {
635- PXM_GET_PIXELVALS_1 (r2 , g2 , b2 , a2 , px_p , palette );
620+ GET_PIXELVALS_1 (r2 , g2 , b2 , a2 , px_p , palette );
636621 if (COLOR_DIFF_RGB (wr , wg , wb , r1 , g1 , b1 , r2 , g2 ,
637622 b2 ) <= distance ) {
638623 * px_p = (Uint8 )white ;
@@ -659,8 +644,8 @@ _extract_color(pgPixelArrayObject *array, PyObject *args, PyObject *kwds)
659644 for (x = 0 ; x < dim0 ; ++ x ) {
660645 px_p = (Uint16 * )pixel_p ;
661646 if (distance != 0.0 ) {
662- PXM_GET_PIXELVALS (r2 , g2 , b2 , a2 , (Uint32 )* px_p ,
663- format , palette , ppa );
647+ GET_PIXELVALS (r2 , g2 , b2 , a2 , (Uint32 )* px_p , format ,
648+ palette , ppa );
664649 if (COLOR_DIFF_RGB (wr , wg , wb , r1 , g1 , b1 , r2 , g2 ,
665650 b2 ) <= distance ) {
666651 * px_p = (Uint16 )white ;
@@ -704,8 +689,8 @@ _extract_color(pgPixelArrayObject *array, PyObject *args, PyObject *kwds)
704689 ((Uint32 )pixel_p [Goffset ] << 8 ) +
705690 ((Uint32 )pixel_p [Boffset ]));
706691 if (distance != 0.0 ) {
707- PXM_GET_PIXELVALS (r2 , g2 , b2 , a2 , pxcolor , format ,
708- palette , ppa );
692+ GET_PIXELVALS (r2 , g2 , b2 , a2 , pxcolor , format , palette ,
693+ ppa );
709694 if (COLOR_DIFF_RGB (wr , wg , wb , r1 , g1 , b1 , r2 , g2 ,
710695 b2 ) <= distance ) {
711696 pixel_p [Roffset ] = white_r ;
@@ -744,8 +729,8 @@ _extract_color(pgPixelArrayObject *array, PyObject *args, PyObject *kwds)
744729 for (x = 0 ; x < dim0 ; ++ x ) {
745730 px_p = (Uint32 * )pixel_p ;
746731 if (distance != 0.0 ) {
747- PXM_GET_PIXELVALS (r2 , g2 , b2 , a2 , * px_p , format ,
748- palette , ppa );
732+ GET_PIXELVALS (r2 , g2 , b2 , a2 , * px_p , format , palette ,
733+ ppa );
749734 if (COLOR_DIFF_RGB (wr , wg , wb , r1 , g1 , b1 , r2 , g2 ,
750735 b2 ) <= distance ) {
751736 * px_p = white ;
@@ -888,9 +873,9 @@ _compare(pgPixelArrayObject *array, PyObject *args, PyObject *kwds)
888873 pixel_p = byte_p ;
889874 other_pixel_p = other_byte_p ;
890875 if (distance != 0.0 ) {
891- PXM_GET_PIXELVALS_1 (r1 , g1 , b1 , a1 , pixel_p , palette );
892- PXM_GET_PIXELVALS_1 (r2 , g2 , b2 , a2 , other_pixel_p ,
893- other_palette );
876+ GET_PIXELVALS_1 (r1 , g1 , b1 , a1 , pixel_p , palette );
877+ GET_PIXELVALS_1 (r2 , g2 , b2 , a2 , other_pixel_p ,
878+ other_palette );
894879 if (COLOR_DIFF_RGB (wr , wg , wb , r1 , g1 , b1 , r2 , g2 ,
895880 b2 ) <= distance ) {
896881 * pixel_p = (Uint8 )white ;
@@ -925,11 +910,10 @@ _compare(pgPixelArrayObject *array, PyObject *args, PyObject *kwds)
925910 pixel_p = (Uint16 * )byte_p ;
926911 other_pixel_p = (Uint16 * )other_byte_p ;
927912 if (distance != 0.0 ) {
928- PXM_GET_PIXELVALS (r1 , g1 , b1 , a1 , (Uint32 )* pixel_p ,
929- format , palette , ppa );
930- PXM_GET_PIXELVALS (r2 , g2 , b2 , a2 ,
931- (Uint32 )* other_pixel_p , other_format ,
932- other_palette , other_ppa );
913+ GET_PIXELVALS (r1 , g1 , b1 , a1 , (Uint32 )* pixel_p , format ,
914+ palette , ppa );
915+ GET_PIXELVALS (r2 , g2 , b2 , a2 , (Uint32 )* other_pixel_p ,
916+ other_format , other_palette , other_ppa );
933917 if (COLOR_DIFF_RGB (wr , wg , wb , r1 , g1 , b1 , r2 , g2 ,
934918 b2 ) <= distance ) {
935919 * pixel_p = (Uint16 )white ;
@@ -1029,11 +1013,10 @@ _compare(pgPixelArrayObject *array, PyObject *args, PyObject *kwds)
10291013 pixel_p = (Uint32 * )byte_p ;
10301014 other_pixel_p = (Uint32 * )other_byte_p ;
10311015 if (distance != 0.0 ) {
1032- PXM_GET_PIXELVALS (r1 , g1 , b1 , a1 , * pixel_p , format ,
1033- palette , ppa );
1034- PXM_GET_PIXELVALS (r2 , g2 , b2 , a2 , * other_pixel_p ,
1035- other_format , other_palette ,
1036- other_ppa );
1016+ GET_PIXELVALS (r1 , g1 , b1 , a1 , * pixel_p , format ,
1017+ palette , ppa );
1018+ GET_PIXELVALS (r2 , g2 , b2 , a2 , * other_pixel_p ,
1019+ other_format , other_palette , other_ppa );
10371020 if (COLOR_DIFF_RGB (wr , wg , wb , r1 , g1 , b1 , r2 , g2 ,
10381021 b2 ) <= distance ) {
10391022 * pixel_p = white ;
0 commit comments