uchar* ui32t; QImage* ImageImaget = new QImage(128,128,32); ImageImaget->setAlphaBuffer(TRUE); bool t=ImageImaget->load("2.png","PNG"); int nb=ImageImaget->numBytes(); ui32t=ImageImaget->scanLine(0); QPixmap pm; pm.loadFromData(ui32t,nb,"PNG",(int)0); textLabelMovie->setPixmap(pm);
QPixmap pm; pm.load("2.png","PNG",0); textLabelMovie->setPixmap(pm);
QPixmap pm("2.png");
static const unsigned char image_bmp_data[] = { 0x42,0x4d,0xc2,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x42,0x00,0x00,0x00, 0x28,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x01,0x00, 0x04,0x00,0x00,0x00,0x00,0x00,0x80,0x04,0x00,0x00,0x6d,0x0b,0x00,0x00, 0x6d,0x0b,0x00,0x00,0x03,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00, 0x10,0x00,0xff,0xff,0xff,0x00,0x51,0x61,0x30,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x10,0x10,0x10,0x10,0x10,0x10, 0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10, 0x10,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x00,0x10, 0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x01,0x00,0x10,0x10,0x10, 0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x01,0x01,0x01,0x01,0x01,0x01,........
//ui32t - массив 128*128*4 uchar с нашими данными//nb=128*128*4 QImage* i2 = new QImage(128,128,32); i2->setAlphaBuffer(TRUE); uchar* pi2=i2->scanLine(0); memcpy(pi2,ui32t,nb);
uchar* ui32t; QImage* ImageImaget = new QImage(128,128,32); ImageImaget->setAlphaBuffer(TRUE); bool t=ImageImaget->load("2.png","PNG");
int nb=ImageImaget->numBytes(); ui32t=ImageImaget->scanLine(0); QPixmap pm; pm.loadFromData(ui32t,nb,"PNG",(int)0); textLabelMovie->setPixmap(pm);
QImage::QImage ( uchar * yourdata, int w, int h, int depth, int bpl, QRgb * colortable, int numColors, Endian bitOrder ) Constructs an image that uses an existing memory buffer. The buffer must remain valid for the life of the QImage. The image does not delete the buffer at destruction. The buffer is passed as yourdata. The image's width is w and its height is h. The color depth is depth. bpl specifies the number of bytes per line. If colortable is 0, a color table sufficient for numColors will be allocated (and destructed later). The endianness is specified by bitOrder.
QLabel *l = new QLabel();QPixmap pm(720,576);QByteArray ba;//буфер не пустой и имеет размер 720*576 ba = (char *) buffer;//ba после присваивания в отладчике показывает всего несколько строк - //гораздо меньше, чем исходный буферpm.loadFromData(ba);l->setPixmap(pm);l->show();
QDataStream ds(&ba,QIODevice::WriteOnly);char * cs = (char *) buffer;ds.writeBytes((char *) buffer,720*576);
QLabel *l = new QLabel();QPixmap pm(720,576);const char *cs = (char *) buffer;QByteArray ba = QByteArray::fromRawData(cs,720*576);pm.loadFromData(ba);l->setPixmap(pm);l->show();