added colour normalization to PNM handler [backport from HEAD]
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@46311 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -91,6 +91,10 @@ Major new features in 2.8 release
|
||||
2.8.5
|
||||
-----
|
||||
|
||||
All (GUI):
|
||||
|
||||
- Added colour normalization to PNM image handler (Ray Johnston)
|
||||
|
||||
wxMSW:
|
||||
|
||||
- Fix crash when destroying a default button (Tim Kosse)
|
||||
|
@@ -96,6 +96,8 @@ bool wxPNMHandler::LoadFile( wxImage *image, wxInputStream& stream, bool verbose
|
||||
for (wxUint32 i=0; i<size; ++i)
|
||||
{
|
||||
value=text_stream.Read32();
|
||||
if ( maxval != 255 )
|
||||
value = (255 * value)/maxval;
|
||||
*ptr++=(unsigned char)value; // R
|
||||
*ptr++=(unsigned char)value; // G
|
||||
*ptr++=(unsigned char)value; // B
|
||||
@@ -114,6 +116,8 @@ bool wxPNMHandler::LoadFile( wxImage *image, wxInputStream& stream, bool verbose
|
||||
//this is very slow !!!
|
||||
//I wonder how we can make any better ?
|
||||
value=text_stream.Read32();
|
||||
if ( maxval != 255 )
|
||||
value = (255 * value)/maxval;
|
||||
*ptr++=(unsigned char)value;
|
||||
|
||||
if ( !buf_stream )
|
||||
@@ -130,6 +134,8 @@ bool wxPNMHandler::LoadFile( wxImage *image, wxInputStream& stream, bool verbose
|
||||
for (wxUint32 i=0; i<size; ++i)
|
||||
{
|
||||
buf_stream.Read(&value,1);
|
||||
if ( maxval != 255 )
|
||||
value = (255 * value)/maxval;
|
||||
*ptr++=value; // R
|
||||
*ptr++=value; // G
|
||||
*ptr++=value; // B
|
||||
@@ -140,8 +146,16 @@ bool wxPNMHandler::LoadFile( wxImage *image, wxInputStream& stream, bool verbose
|
||||
}
|
||||
}
|
||||
}
|
||||
if (c=='6') // Raw RGB
|
||||
buf_stream.Read( ptr, 3*width*height );
|
||||
|
||||
if ( c=='6' ) // Raw RGB
|
||||
{
|
||||
buf_stream.Read(ptr, 3*width*height);
|
||||
if ( maxval != 255 )
|
||||
{
|
||||
for ( unsigned i = 0; i < 3*width*height; i++ )
|
||||
ptr[i] = (255 * ptr[i])/maxval;
|
||||
}
|
||||
}
|
||||
|
||||
image->SetMask( false );
|
||||
|
||||
|
Reference in New Issue
Block a user