[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: kdelibs/kimgio
From: Maks Orlovich <maksim () kde ! org>
Date: 2005-02-22 16:29:46
Message-ID: 20050222162946.70101ED8A () office ! kde ! org
[Download RAW message or body]
CVS commit by orlovich:
Do not let header.biClrUsed request reading more colors than there are
palette entries.
Do not read any palette if truecolor
Fix the selection predicate to be properly antisymmetric (well, at least
in the size portion)
BUG:99216
M +23 -6 ico.cpp 1.25
--- kdelibs/kimgio/ico.cpp #1.24:1.25
@@ -116,4 +116,6 @@ namespace
if ( std::abs( int( lhs.width - size ) ) <
std::abs( int( rhs.width - size ) ) ) return true;
+ else if ( std::abs( int( lhs.width - size ) ) >
+ std::abs( int( rhs.width - size ) ) ) return false;
else if ( colors == 0 )
{
@@ -147,15 +149,29 @@ namespace
header.biBitCount != 32 ) ) return false;
- unsigned colors = header.biBitCount >= 24 ?
- 0 : header.biClrUsed ?
- header.biClrUsed : 1 << header.biBitCount;
+ unsigned paletteSize, paletteEntries;
+
+ if (header.biBitCount > 8)
+ {
+ paletteEntries = 0;
+ paletteSize = 0;
+ }
+ else
+ {
+ paletteSize = (1 << header.biBitCount);
+ paletteEntries = paletteSize;
+ if (header.biClrUsed && header.biClrUsed < paletteSize)
+ paletteEntries = header.biClrUsed;
+ }
+
// Always create a 32-bit image to get the mask right
+ // Note: this is safe as rec.width, rec.height are bytes
icon.create( rec.width, rec.height, 32 );
if ( icon.isNull() ) return false;
icon.setAlphaBuffer( true );
- QMemArray< QRgb > colorTable( 1 << header.biBitCount );
+ QMemArray< QRgb > colorTable( paletteSize );
+
colorTable.fill( QRgb( 0 ) );
- for ( unsigned i = 0; i < colors; ++i )
+ for ( unsigned i = 0; i < paletteEntries; ++i )
{
unsigned char rgb[ 4 ];
@@ -166,4 +182,5 @@ namespace
unsigned bpl = ( rec.width * header.biBitCount + 31 ) / 32 * 4;
+
unsigned char* buf = new unsigned char[ bpl ];
unsigned char** lines = icon.jumpTable();
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic