What is the data in aegea.png, because it is this you are manipulating (you discard the unitialised Format_ARGB32 QImage)? Are you doing anything with the QImage other than loading the file? If not, then why not just load the QPixmap directly?
My example image is identified (ImageMagick) as:
$ identify -verbose plane.png
Image: plane.png
Format: PNG (Portable Network Graphics)
Class: DirectClass
Geometry: 1040x138+0+0
Resolution: 72x72
Print size: 14.4444x1.91667
Units: Undefined
Type: TrueColorMatte
Endianess: Undefined
Colorspace: RGB
Depth: 8-bit
Channel depth:
red: 8-bit
green: 8-bit
blue: 8-bit
alpha: 8-bit
...
$ identify -verbose plane.png
Image: plane.png
Format: PNG (Portable Network Graphics)
Class: DirectClass
Geometry: 1040x138+0+0
Resolution: 72x72
Print size: 14.4444x1.91667
Units: Undefined
Type: TrueColorMatte
Endianess: Undefined
Colorspace: RGB
Depth: 8-bit
Channel depth:
red: 8-bit
green: 8-bit
blue: 8-bit
alpha: 8-bit
...
To copy to clipboard, switch view to plain text mode
and is a mostly transparent banner of an aircraft with partial transparency of the spinning propeller. This code:
// Your code with adjustment for static method
bool loaded = overlay_image.load ("plane.png", 0 );
QPixmap overlay_map
= QPixmap::fromImage ( overlay_image,Qt
::AutoColor );
qDebug() << loaded;
qDebug() << overlay_map.size() << overlay_map.depth() << overlay_map.hasAlphaChannel();
// Load the PNG directly
overlay_map.load("plane.png");
qDebug() << overlay_map.size() << overlay_map.depth() << overlay_map.hasAlphaChannel();
// Your code with adjustment for static method
QImage overlay_image(768,768,QImage::Format_ARGB32);
bool loaded = overlay_image.load ("plane.png", 0 );
QPixmap overlay_map = QPixmap::fromImage ( overlay_image,Qt::AutoColor );
qDebug() << loaded;
qDebug() << overlay_map.size() << overlay_map.depth() << overlay_map.hasAlphaChannel();
// Load the PNG directly
overlay_map.load("plane.png");
qDebug() << overlay_map.size() << overlay_map.depth() << overlay_map.hasAlphaChannel();
To copy to clipboard, switch view to plain text mode
outputs
true
true
QSize(1040, 138) 32 true
QSize(1040, 138) 32 true
To copy to clipboard, switch view to plain text mode
on Linux, Qt 4.7.2.
Bookmarks