test/automated/common/common.c
changeset 3456 6b182cbe38ac
parent 3441 5271ce790fed
child 3476 ab99313951cd
equal deleted inserted replaced
3455:5a7b5760c875 3456:6b182cbe38ac
    45                printf("%d BPP not supported yet.\n",bpp);
    45                printf("%d BPP not supported yet.\n",bpp);
    46                break;
    46                break;
    47 
    47 
    48             case 4:
    48             case 4:
    49                {
    49                {
    50                   int fail;
    50                   int dist = 0;
    51                   Uint8 R, G, B, A;
    51                   Uint8 R, G, B, A;
    52 
    52 
    53                   SDL_GetRGBA(*(Uint32*)p, sur->format, &R, &G, &B, &A);
    53                   SDL_GetRGBA(*(Uint32*)p, sur->format, &R, &G, &B, &A);
    54 
    54 
    55                   if (img->bytes_per_pixel == 3) {
    55                   if (img->bytes_per_pixel == 3) {
    56                      fail = !( (R == pd[0]) &&
    56                      dist += (R-pd[0])*(R-pd[0]);
    57                                (G == pd[1]) &&
    57                      dist += (G-pd[1])*(G-pd[1]);
    58                                (B == pd[2]) );
    58                      dist += (B-pd[2])*(B-pd[2]);
    59                   } else {
    59                   } else {
    60                      fail = !( (R == pd[0]) &&
    60                      dist += (R-pd[0])*(R-pd[0]);
    61                                (G == pd[1]) &&
    61                      dist += (G-pd[1])*(G-pd[1]);
    62                                (B == pd[2]) &&
    62                      dist += (B-pd[2])*(B-pd[2]);
    63                                (A == pd[3]) );
    63                      dist += (A-pd[3])*(A-pd[3]);
    64                   }
    64                   }
    65                   if (fail) {
    65                   /* Allow up to sqrt(32) difference in blending accuracy */
       
    66                   if (dist > 32) {
       
    67                      /*printf("pixel %d,%d varies by %d\n", i, j, dist);*/
    66                      ++ret;
    68                      ++ret;
    67                   }
    69                   }
    68                }
    70                }
    69                break;
    71                break;
    70          }
    72          }