/* Dither RGB files down to 8 bit palette or reduce palettes * to the number of colors available on your screen. */ if (color_type & PNG_COLOR_MASK_COLOR) { png_uint_32 num_palette; png_colorp palette; /* This reduces the image to the application supplied palette */ if (/* we have our own palette */) { /* An array of colors to which the image should be dithered */ png_color std_color_cube[MAX_SCREEN_COLORS]; png_set_dither(png_ptr, std_color_cube, MAX_SCREEN_COLORS, MAX_SCREEN_COLORS, NULL, 0); } /* This reduces the image to the palette supplied in the file */ else if (png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette)) { png_color16p histogram; png_get_hIST(png_ptr, info_ptr, &histogram); png_set_dither(png_ptr, palette, num_palette, max_screen_colors, histogram, 0); } }