
Originally Posted by
wysota
Could you show us the code where you create the pixmap and code where you create the byte array?
Here is the code. I write the QByteArray buffer out to a file, and it is identical whether the pixmap is null or not. When I trace through the code execution, the only difference that I can see is in the call to to qt_display_dc() (defined in qapplication_win.cpp) in QPixmap::init. The HDC returned is bad when pixmap.isNull.
// -----------------------------------------------------------------
QString pgmHeader
( QString( "P5\n%1 %2\n255\n" ).
arg( imageWidth
).
arg( imageHeight
) );
int pgmHeaderSize = pgmHeader.length();
QByteArray buf
( pgmHeaderSize
+ numberOfImagePixels
);
memcpy( buf.data(), pgmHeader.ascii(), pgmHeaderSize );
loadImageData( imageData, ucharptr( buf.data() + pgmHeaderSize ), numberOfImagePixels );
if ( pixmap.isNull() )
{
// report error
return -1;
}
// -----------------------------------------------------------------
// -----------------------------------------------------------------
QString pgmHeader( QString( "P5\n%1 %2\n255\n" ).arg( imageWidth ).arg( imageHeight ) );
int pgmHeaderSize = pgmHeader.length();
QByteArray buf( pgmHeaderSize + numberOfImagePixels );
memcpy( buf.data(), pgmHeader.ascii(), pgmHeaderSize );
loadImageData( imageData, ucharptr( buf.data() + pgmHeaderSize ), numberOfImagePixels );
QPixmap pixmap(buf);
if ( pixmap.isNull() )
{
// report error
return -1;
}
// -----------------------------------------------------------------
To copy to clipboard, switch view to plain text mode
Bookmarks