IMG_xpm.c
changeset 453 c0132bb6251a
parent 451 48116d511e5d
child 473 65f1bb7a3eb2
equal deleted inserted replaced
452:b72e4038e532 453:c0132bb6251a
   176  */
   176  */
   177 static int color_to_rgb(char *spec, int speclen, Uint32 *rgb)
   177 static int color_to_rgb(char *spec, int speclen, Uint32 *rgb)
   178 {
   178 {
   179     /* poor man's rgb.txt */
   179     /* poor man's rgb.txt */
   180     static struct { char *name; Uint32 rgb; } known[] = {
   180     static struct { char *name; Uint32 rgb; } known[] = {
   181         { "none",                 0xFFFFFF },
   181         { "none",                 0xFFFFFFFF },
   182         { "black",                0x000000 },
   182         { "black",                0x000000 },
   183         { "white",                0xFFFFFF },
   183         { "white",                0xFFFFFF },
   184         { "red",                  0xFF0000 },
   184         { "red",                  0xFF0000 },
   185         { "green",                0x00FF00 },
   185         { "green",                0x00FF00 },
   186         { "blue",                 0x0000FF },
   186         { "blue",                 0x0000FF },
   890         buf[6] = '\0';
   890         buf[6] = '\0';
   891         *rgb = strtol(buf, NULL, 16);
   891         *rgb = strtol(buf, NULL, 16);
   892         return 1;
   892         return 1;
   893     } else {
   893     } else {
   894         int i;
   894         int i;
   895         for (i = 0; i < SDL_arraysize(known); i++)
   895         for (i = 0; i < SDL_arraysize(known); i++) {
   896             if (SDL_strncasecmp(known[i].name, spec, speclen) == 0) {
   896             if (SDL_strncasecmp(known[i].name, spec, speclen) == 0) {
   897                 *rgb = known[i].rgb;
   897                 *rgb = known[i].rgb;
   898                 return 1;
   898                 return 1;
   899             }
   899             }
       
   900         }
   900         return 0;
   901         return 0;
   901     }
   902     }
   902 }
   903 }
   903 
   904 
   904 #ifndef MAX
   905 #ifndef MAX