// ClearRGBA() // Clear the buffer to the given color. The inputs default to 0 // (black, solid alpha, closest palette match). // Mode Effect // RGB all pixels become r,g,b // RGBA all pixels become r,g,b; Alpha becomes a // GREY all pixels become the value of r,g,b // INDEXED all pixels become the closest palette match to r,g,b void ImageClass::ClearRGBA( IMG_BYTE r, IMG_BYTE g, IMG_BYTE b, IMG_BYTE a ) { unsigned long i; unsigned long num_bytes = (width * height * pixel_size); switch( type ) { case IMAGE_INDEXED: ClearIndexed( FindPaletteIndex( r, g, b ) ); break; case IMAGE_RGB: ClearRGB( r, g, b ); break; case IMAGE_RGBA: IMG_BYTE * pixel; for( i=0; i < num_bytes; i += pixel_size ) { pixel = &(image[i]); pixel[0] = r; pixel[1] = g; pixel[2] = b; pixel[3] = a; } break; case IMAGE_GREY: ClearGrey( GetValueOfRGB( r, g, b ) ); break; } }
// Clear() // Clear the buffer to the given color. The inputs default to 0 // (black, solid alpha, closest palette match). // Mode Effect // RGB all pixels become r,g,b // RGBA all pixels become r,g,b; Alpha becomes a // GREY all pixels become the value of r,g,b // INDEXED all pixels become the closest palette match to r,g,b void ImageClass::Clear( IMG_BYTE r, IMG_BYTE g, IMG_BYTE b, IMG_BYTE a ) { switch( type ) { case IMAGE_INDEXED: ClearIndexed( FindPaletteIndex( r, g, b ) ); break; case IMAGE_RGB: ClearRGB( r, g, b ); break; case IMAGE_RGBA: ClearRGBA( r, g, b, a ); break; case IMAGE_GREY: ClearGrey( ImageClass::GetValueOfRGB( r, g, b ) ); break; } }
// ClearGrey() // Clears the alpha to the given value. Defaults to 0 // (black, or the closest palette index) // Mode Effect // RGB clears buffer to value // RGBA clears buffer to value; Alpha is untouched // GREY clears buffer to value // INDEXED clears buffer to closest match to value void ImageClass::ClearGrey( IMG_BYTE value ) { unsigned long i; unsigned long num_bytes = (width * height * pixel_size); switch( type ) { case IMAGE_INDEXED: ClearIndexed( FindPaletteIndex( value, value, value ) ); break; case IMAGE_RGB: case IMAGE_RGBA: ClearRGB( value, value, value ); break; case IMAGE_GREY: for( i=0; i < num_bytes; i += pixel_size ) image[i] = value; break; } }
static BOOL CheckPaletteEntry(LOGPALETTE *pal, int index, BYTE r, BYTE g, BYTE b) { PALETTEENTRY *entry; BOOL moved = 0; entry = &pal->palPalEntry[index]; if ( entry->peRed != r || entry->peGreen != g || entry->peBlue != b ) { int found = FindPaletteIndex(pal, r, g, b); if ( found >= 0 ) { pal->palPalEntry[found] = *entry; } entry->peRed = r; entry->peGreen = g; entry->peBlue = b; moved = 1; } entry->peFlags = 0; return moved; }