So, after simplifying even more this is my code:
void convert16to8mono
(QImage &qimage,
unsigned short *inBuff,
int sizeBytes,
unsigned char *outBuff
) {
qimage.setNumColors(1);
qimage.setColor(0,qRgb(255,0,0));
for(int y=0,i=0;y<960; y++)
for(int x=0; x<1280; x++,i++)
{
qimage.setPixel(x,y,0);
}
}
void convert16to8mono(QImage &qimage,unsigned short *inBuff, int sizeBytes, unsigned char *outBuff)
{
qimage.setNumColors(1);
qimage.setColor(0,qRgb(255,0,0));
for(int y=0,i=0;y<960; y++)
for(int x=0; x<1280; x++,i++)
{
qimage.setPixel(x,y,0);
}
}
To copy to clipboard, switch view to plain text mode
and I use it like that:
convert16to8mono(qimage,buff,size*2,buff8);
if(!qimage.isNull())
pixmap.fromImage(qimage);
ui.lblImage->setPixmap(pixmap);
QPixmap pixmap(1280,960);
QImage qimage(1280,960,QImage::Format_Indexed8);
convert16to8mono(qimage,buff,size*2,buff8);
if(!qimage.isNull())
pixmap.fromImage(qimage);
ui.lblImage->setPixmap(pixmap);
To copy to clipboard, switch view to plain text mode
result is a uniform gray image, instead of a red image....
I am at a loss to what I still might be doing wrong...
EDIT:
I solved it.
As always the problem ist between the chair and keyboard.
I forgot that fromImage returns the new pixmap, and not changing the calling object.
Thanks for helping.
Bookmarks