123456789101112131415161718192021222324252627282930313233 |
- #include "game.h"
- /** Loads a PNG file and creates VGImage using the 32bit image data.
- */
- VGImage loadVGImage(const char *filename)
- {
- QImage texture;
- if(!texture.load(filename))
- {
- qDebug("loadVGImage cannot load '%s'", filename);
- return VG_INVALID_HANDLE;
- }
- // make sure we have 32bit format
- texture = texture.convertToFormat(QImage::Format_ARGB32);
- int w=texture.width();
- int h=texture.height();
- qDebug("loadVGImage '%s' %dx%d", filename, w, h);
- VGImage image = vgCreateImage(VG_sARGB_8888, w, h, VG_IMAGE_QUALITY_FASTER);
- qDebug("vgCreateImage handle %x", image);
- if(image==VG_INVALID_HANDLE)
- {
- VGErrorCode err = vgGetError();
- qDebug("loadVGImage '%s' error 0x%x", filename, err);
- }
- vgImageSubData(image, (QRgb*)texture.bits(), w*4, VG_sARGB_8888, 0, 0, w, h);
- return image;
- }
|