Commit 665783a6 authored by Oleg Korshul's avatar Oleg Korshul

palette alpha

parent 0b15c314
......@@ -179,7 +179,7 @@ void CBgraFrame::CxImageToMediaFrame( CxImage& img )
int nStride = img.GetEffWidth();
BYTE* pBuffer = img.GetBits();
RGBQUAD* pPalette = img.GetPalette();
bool bIsAlphaPalettePresent = false;//img.GetPaletteAlphaEnabled();
bool bIsAlphaPalettePresent = img.AlphaPaletteIsEnabled();
bool bIsAlphaApplied = false;
if( 1 == nBitsPerPixel )
......@@ -263,6 +263,10 @@ void CBgraFrame::CxImageToMediaFrame( CxImage& img )
BYTE* src = pBuffer;
BYTE* dst = pPixels;
int nTransIndex = img.GetTransIndex();
if (bIsAlphaApplied)
nTransIndex = -1;
for( int nRow = 0; nRow < nHeight; ++nRow, src += nStride )
{
for( int nPos = 0; nPos < nWidth; ++nPos, dst += 4 )
......@@ -271,9 +275,22 @@ void CBgraFrame::CxImageToMediaFrame( CxImage& img )
dst[0] = pPalette[index].rgbBlue;
dst[1] = pPalette[index].rgbGreen;
dst[2] = pPalette[index].rgbRed;
if (bIsAlphaPalettePresent)
dst[3] = pPalette[index].rgbReserved;
else if (-1 != nTransIndex)
{
if (index == nTransIndex)
dst[3] = pPalette[index].rgbReserved;
else
dst[3] = 255;
}
}
}
if (-1 != nTransIndex || bIsAlphaPalettePresent)
bIsAlphaApplied = true;
}
else
if( 8 == nBitsPerPixel )
{
......@@ -282,9 +299,11 @@ void CBgraFrame::CxImageToMediaFrame( CxImage& img )
nStride -= nWidth;
int nTransIndex = img.GetTransIndex();
if (bIsAlphaApplied)
nTransIndex = -1;
if( pPalette )
{
if (bIsAlphaPalettePresent)
{
for( int nRow = 0; nRow < nHeight; ++nRow, src += nStride )
{
......@@ -294,24 +313,21 @@ void CBgraFrame::CxImageToMediaFrame( CxImage& img )
dst[0] = pPalette[index].rgbBlue;
dst[1] = pPalette[index].rgbGreen;
dst[2] = pPalette[index].rgbRed;
if (bIsAlphaPalettePresent)
dst[3] = pPalette[index].rgbReserved;
}
}
bIsAlphaApplied = true;
}
else
else if (-1 != nTransIndex)
{
for( int nRow = 0; nRow < nHeight; ++nRow, src += nStride )
{
for( int nPos = 0; nPos < nWidth; ++nPos, src += 1, dst += 4 )
{
int index = src[0];
dst[0] = pPalette[index].rgbBlue;
dst[1] = pPalette[index].rgbGreen;
dst[2] = pPalette[index].rgbRed;
if (index == nTransIndex)
dst[3] = pPalette[index].rgbReserved;
else
dst[3] = 255;
}
}
}
if (-1 != nTransIndex || bIsAlphaPalettePresent)
bIsAlphaApplied = true;
}
else
{
......
......@@ -41,15 +41,23 @@
#include "../include/ASCSVGWriter.h"
#include "../../DesktopEditor/raster/Metafile/MetaFile.h"
#include "../../DesktopEditor/raster/BgraFrame.h"
#define RASTER_TEST
//#define METAFILE_TEST
//#define ONLINE_WORD_TO_PDF
//#define TO_PDF
#define TO_HTML_RENDERER
//#define TO_PDF//#define TO_HTML_RENDERER
//#define ONLY_TEXT
int main(int argc, char *argv[])
{
#ifdef RASTER_TEST
CBgraFrame oFrame;
oFrame.OpenFile(L"D:\\22.png");
oFrame.SaveFile(L"D:\\oleg.png", 4);
return 0;
#endif
CApplicationFonts oFonts;
oFonts.Initialize();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment