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

palette alpha

parent 0b15c314
...@@ -179,7 +179,7 @@ void CBgraFrame::CxImageToMediaFrame( CxImage& img ) ...@@ -179,7 +179,7 @@ void CBgraFrame::CxImageToMediaFrame( CxImage& img )
int nStride = img.GetEffWidth(); int nStride = img.GetEffWidth();
BYTE* pBuffer = img.GetBits(); BYTE* pBuffer = img.GetBits();
RGBQUAD* pPalette = img.GetPalette(); RGBQUAD* pPalette = img.GetPalette();
bool bIsAlphaPalettePresent = false;//img.GetPaletteAlphaEnabled(); bool bIsAlphaPalettePresent = img.AlphaPaletteIsEnabled();
bool bIsAlphaApplied = false; bool bIsAlphaApplied = false;
if( 1 == nBitsPerPixel ) if( 1 == nBitsPerPixel )
...@@ -263,6 +263,10 @@ void CBgraFrame::CxImageToMediaFrame( CxImage& img ) ...@@ -263,6 +263,10 @@ void CBgraFrame::CxImageToMediaFrame( CxImage& img )
BYTE* src = pBuffer; BYTE* src = pBuffer;
BYTE* dst = pPixels; BYTE* dst = pPixels;
int nTransIndex = img.GetTransIndex();
if (bIsAlphaApplied)
nTransIndex = -1;
for( int nRow = 0; nRow < nHeight; ++nRow, src += nStride ) for( int nRow = 0; nRow < nHeight; ++nRow, src += nStride )
{ {
for( int nPos = 0; nPos < nWidth; ++nPos, dst += 4 ) for( int nPos = 0; nPos < nWidth; ++nPos, dst += 4 )
...@@ -271,8 +275,21 @@ void CBgraFrame::CxImageToMediaFrame( CxImage& img ) ...@@ -271,8 +275,21 @@ void CBgraFrame::CxImageToMediaFrame( CxImage& img )
dst[0] = pPalette[index].rgbBlue; dst[0] = pPalette[index].rgbBlue;
dst[1] = pPalette[index].rgbGreen; dst[1] = pPalette[index].rgbGreen;
dst[2] = pPalette[index].rgbRed; 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 else
if( 8 == nBitsPerPixel ) if( 8 == nBitsPerPixel )
...@@ -282,36 +299,35 @@ void CBgraFrame::CxImageToMediaFrame( CxImage& img ) ...@@ -282,36 +299,35 @@ void CBgraFrame::CxImageToMediaFrame( CxImage& img )
nStride -= nWidth; nStride -= nWidth;
int nTransIndex = img.GetTransIndex();
if (bIsAlphaApplied)
nTransIndex = -1;
if( pPalette ) if( pPalette )
{ {
if (bIsAlphaPalettePresent) for( int nRow = 0; nRow < nHeight; ++nRow, src += nStride )
{ {
for( int nRow = 0; nRow < nHeight; ++nRow, src += nStride ) for( int nPos = 0; nPos < nWidth; ++nPos, src += 1, dst += 4 )
{ {
for( int nPos = 0; nPos < nWidth; ++nPos, src += 1, dst += 4 ) int index = src[0];
{ dst[0] = pPalette[index].rgbBlue;
int index = src[0]; dst[1] = pPalette[index].rgbGreen;
dst[0] = pPalette[index].rgbBlue; dst[2] = pPalette[index].rgbRed;
dst[1] = pPalette[index].rgbGreen;
dst[2] = pPalette[index].rgbRed; if (bIsAlphaPalettePresent)
dst[3] = pPalette[index].rgbReserved; dst[3] = pPalette[index].rgbReserved;
} else if (-1 != nTransIndex)
}
bIsAlphaApplied = true;
}
else
{
for( int nRow = 0; nRow < nHeight; ++nRow, src += nStride )
{
for( int nPos = 0; nPos < nWidth; ++nPos, src += 1, dst += 4 )
{ {
int index = src[0]; if (index == nTransIndex)
dst[0] = pPalette[index].rgbBlue; dst[3] = pPalette[index].rgbReserved;
dst[1] = pPalette[index].rgbGreen; else
dst[2] = pPalette[index].rgbRed; dst[3] = 255;
} }
} }
} }
if (-1 != nTransIndex || bIsAlphaPalettePresent)
bIsAlphaApplied = true;
} }
else else
{ {
......
...@@ -41,15 +41,23 @@ ...@@ -41,15 +41,23 @@
#include "../include/ASCSVGWriter.h" #include "../include/ASCSVGWriter.h"
#include "../../DesktopEditor/raster/Metafile/MetaFile.h" #include "../../DesktopEditor/raster/Metafile/MetaFile.h"
#include "../../DesktopEditor/raster/BgraFrame.h"
#define RASTER_TEST
//#define METAFILE_TEST //#define METAFILE_TEST
//#define ONLINE_WORD_TO_PDF //#define ONLINE_WORD_TO_PDF
//#define TO_PDF //#define TO_PDF//#define TO_HTML_RENDERER
#define TO_HTML_RENDERER
//#define ONLY_TEXT //#define ONLY_TEXT
int main(int argc, char *argv[]) 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; CApplicationFonts oFonts;
oFonts.Initialize(); 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