bool CxImage::AlphaPaletteSplit(CxImage *dest) { if (!AlphaPaletteIsValid() || !dest) return false; CxImage tmp(head.biWidth,head.biHeight,8); for(long y=0; y<head.biHeight; y++){ for(long x=0; x<head.biWidth; x++){ tmp.SetPixelIndex(x,y,GetPixelColor(x,y).rgbReserved); } } tmp.SetGrayPalette(); dest->Transfer(tmp); return true; }
/** * Blends the alpha channel and the alpha palette with the pixels. The result is a 24 bit image. * The background color can be selected using SetTransColor(). */ void CxImage::AlphaStrip() { bool bAlphaPaletteIsValid = AlphaPaletteIsValid(); bool bAlphaIsValid = AlphaIsValid(); if (!(bAlphaIsValid || bAlphaPaletteIsValid)) return; RGBQUAD c; long a, a1; if (head.biBitCount==24){ for(long y=0; y<head.biHeight; y++){ for(long x=0; x<head.biWidth; x++){ c = BlindGetPixelColor(x,y); if (bAlphaIsValid) a=(BlindAlphaGet(x,y)*info.nAlphaMax)/255; else a=info.nAlphaMax; a1 = 256-a; c.rgbBlue = (BYTE)((c.rgbBlue * a + a1 * info.nBkgndColor.rgbBlue)>>8); c.rgbGreen = (BYTE)((c.rgbGreen * a + a1 * info.nBkgndColor.rgbGreen)>>8); c.rgbRed = (BYTE)((c.rgbRed * a + a1 * info.nBkgndColor.rgbRed)>>8); BlindSetPixelColor(x,y,c); } } AlphaDelete(); } else {
/** * Blends the alpha channel and the alpha palette with the pixels. The result is a 24 bit image. * The background color can be selected using SetTransColor(). */ void CxImage::AlphaStrip() { bool bAlphaPaletteIsValid = AlphaPaletteIsValid(); bool bAlphaIsValid = AlphaIsValid(); if (!(bAlphaIsValid || bAlphaPaletteIsValid)) return; RGBQUAD c; long a, a1; if (head.biBitCount==24){ for(long y=0; y<head.biHeight; y++){ for(long x=0; x<head.biWidth; x++){ c=GetPixelColor(x,y); if (bAlphaIsValid) a=(AlphaGet(x,y)*info.nAlphaMax)/255; else a=info.nAlphaMax; a1 = 255-a; c.rgbBlue = (BYTE)((c.rgbBlue * a + a1 * info.nBkgndColor.rgbBlue)/255); c.rgbGreen = (BYTE)((c.rgbGreen * a + a1 * info.nBkgndColor.rgbGreen)/255); c.rgbRed = (BYTE)((c.rgbRed * a + a1 * info.nBkgndColor.rgbRed)/255); SetPixelColor(x,y,c); } } AlphaDelete(); } else { CxImage tmp(head.biWidth,head.biHeight,24); if (!tmp.IsValid()) return; for(long y=0; y<head.biHeight; y++){ for(long x=0; x<head.biWidth; x++){ c=GetPixelColor(x,y); if (bAlphaIsValid) a=(AlphaGet(x,y)*info.nAlphaMax)/255; else a=info.nAlphaMax; if (bAlphaPaletteIsValid) a=(c.rgbReserved*a)/255; a1 = 255-a; c.rgbBlue = (BYTE)((c.rgbBlue * a + a1 * info.nBkgndColor.rgbBlue)/255); c.rgbGreen = (BYTE)((c.rgbGreen * a + a1 * info.nBkgndColor.rgbGreen)/255); c.rgbRed = (BYTE)((c.rgbRed * a + a1 * info.nBkgndColor.rgbRed)/255); tmp.SetPixelColor(x,y,c); } } Transfer(tmp); } return; }