rEFIt_UEFI/libeg/lodepng.cpp
/*allocates palette memory if needed, and initializes all colors to black*/
allocates palette memory if needed, and initializes all colors to black
allocates palette memory if needed and initializes all colors to black
static void lodepng_color_mode_alloc_palette(LodePNGColorMode* info) {
  size_t i;
  if(!info->palette) info->palette = (unsigned char*)lodepng_malloc(1024);
  if(!info->palette) return; 
  for(i = 0; i != 256; ++i) {
    info->palette[i * 4 + 0] = 0;
    info->palette[i * 4 + 1] = 0;
    info->palette[i * 4 + 2] = 0;
    info->palette[i * 4 + 3] = 255;
  }
}
static void lodepng_color_mode_alloc_palette ( LodePNGColorMode * info ) { size_t i ; if ( ! info -> palette ) info -> palette = ( unsigned char * ) lodepng_malloc ( 1024 ) ; if ( ! info -> palette ) return ; for ( i = 0 ; i != 256 ; ++ i ) { info -> palette [ i * 4 + 0 ] = 0 ; info -> palette [ i * 4 + 1 ] = 0 ; info -> palette [ i * 4 + 2 ] = 0 ; info -> palette [ i * 4 + 3 ] = 255 ; } }
allocates palette memory if needed, and initializes all colors to black
allocates palette memory if needed and initializes all colors to black
/*if the palette is already allocated, it will have size 1024 so no reallocation needed in that case*/ /*the palette must have room for up to 256 colors with 4 bytes each.*/ /*alloc fail*/ /*Initialize all unused colors with black, the value used for invalid palette indices.
    This is an error according to the PNG spec, but common PNG decoders make it black instead.
    That makes color conversion slightly faster due to no error handling needed.*/