added BI_RLE4 implementation
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@17665 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -608,7 +608,7 @@ bool wxBMPHandler::DoLoadDib(wxImage * image, int width, int height,
|
|||||||
for ( line = (height - 1); line >= 0; line-- )
|
for ( line = (height - 1); line >= 0; line-- )
|
||||||
{
|
{
|
||||||
int linepos = 0;
|
int linepos = 0;
|
||||||
for ( column = 0; column < width; )
|
for ( column = 0; column < width ; )
|
||||||
{
|
{
|
||||||
if ( bpp < 16 )
|
if ( bpp < 16 )
|
||||||
{
|
{
|
||||||
@@ -631,11 +631,70 @@ bool wxBMPHandler::DoLoadDib(wxImage * image, int width, int height,
|
|||||||
{
|
{
|
||||||
if ( comp == BI_RLE4 )
|
if ( comp == BI_RLE4 )
|
||||||
{
|
{
|
||||||
if ( verbose )
|
wxUint8 first;
|
||||||
wxLogError(_("DIB Header: Cannot deal with 4bit encoded yet."));
|
first = aByte;
|
||||||
image->Destroy();
|
aByte = stream.GetC();
|
||||||
delete[] cmap;
|
if ( first == 0 )
|
||||||
return FALSE;
|
{
|
||||||
|
if ( aByte == 0 )
|
||||||
|
{
|
||||||
|
if ( column > 0 )
|
||||||
|
column = width;
|
||||||
|
}
|
||||||
|
else if ( aByte == 1 )
|
||||||
|
{
|
||||||
|
column = width;
|
||||||
|
line = -1;
|
||||||
|
}
|
||||||
|
else if ( aByte == 2 )
|
||||||
|
{
|
||||||
|
aByte = stream.GetC();
|
||||||
|
column += aByte;
|
||||||
|
linepos = column * bpp / 4;
|
||||||
|
aByte = stream.GetC();
|
||||||
|
line -= aByte; // upside down
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int absolute = aByte;
|
||||||
|
wxUint8 nibble[2] ;
|
||||||
|
int readBytes = 0 ;
|
||||||
|
for (int k = 0; k < absolute; k++)
|
||||||
|
{
|
||||||
|
if ( !(k % 2 ) )
|
||||||
|
{
|
||||||
|
++readBytes ;
|
||||||
|
aByte = stream.GetC();
|
||||||
|
nibble[0] = ( (aByte & 0xF0) >> 4 ) ;
|
||||||
|
nibble[1] = ( aByte & 0x0F ) ;
|
||||||
|
}
|
||||||
|
ptr[poffset ] = cmap[nibble[k%2]].r;
|
||||||
|
ptr[poffset + 1] = cmap[nibble[k%2]].g;
|
||||||
|
ptr[poffset + 2] = cmap[nibble[k%2]].b;
|
||||||
|
column++;
|
||||||
|
if ( k % 2 )
|
||||||
|
linepos++;
|
||||||
|
}
|
||||||
|
if ( readBytes & 0x01 )
|
||||||
|
aByte = stream.GetC();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wxUint8 nibble[2] ;
|
||||||
|
nibble[0] = ( (aByte & 0xF0) >> 4 ) ;
|
||||||
|
nibble[1] = ( aByte & 0x0F ) ;
|
||||||
|
|
||||||
|
for ( int l = 0; l < first && column < width; l++ )
|
||||||
|
{
|
||||||
|
ptr[poffset ] = cmap[nibble[l%2]].r;
|
||||||
|
ptr[poffset + 1] = cmap[nibble[l%2]].g;
|
||||||
|
ptr[poffset + 2] = cmap[nibble[l%2]].b;
|
||||||
|
column++;
|
||||||
|
if ( l % 2 )
|
||||||
|
linepos++;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user