p.scale(testWidth, testHeight);
image->setNumColors(256);
for(int i = 0; i < 256; i++)
image->setColor(i, QRGB(i,i,i));
//get 8bpp version of test pattern
unsigned char* test8bpp = new unsigned char[testHeight*testWidth];
for(int i = 0; i < (testHeight*testWidth); i++){
test8bpp[i] = testPattern[i] >> 8;
}
for(int i = 0; i < testHeight; i++){
unsigned char* row = image->scanLine(i);
memcpy(row, test8bpp+(i*testWidth), testWidth);
}
p.drawImage(0,0,*image);
delete [] test8bpp;
QPainter p(this);
p.scale(testWidth, testHeight);
QImage* image = new QImage(testWidth, testHeight,
QImage::Format_Indexed8);
image->setNumColors(256);
for(int i = 0; i < 256; i++)
image->setColor(i, QRGB(i,i,i));
//get 8bpp version of test pattern
unsigned char* test8bpp = new unsigned char[testHeight*testWidth];
for(int i = 0; i < (testHeight*testWidth); i++){
test8bpp[i] = testPattern[i] >> 8;
}
for(int i = 0; i < testHeight; i++){
unsigned char* row = image->scanLine(i);
memcpy(row, test8bpp+(i*testWidth), testWidth);
}
p.drawImage(0,0,*image);
delete [] test8bpp;
To copy to clipboard, switch view to plain text mode
Bookmarks