[SOLVED] Help in Creating Indexed8 image from a buffer
-
wrote on 16 Apr 2012, 13:25 last edited by
Hi,
I am having trouble creating image of the format Indexed8 from a buffer that I have defined...my code is as follows:-
@my_buffer= (uchar*)malloc(xy);
for(i=0;i<xy;i++)
my_buffer[i]=(uchar)qrand()%(255);img= new QImage(my_buffer,x,y,QImage::Format_Indexed8);
for(int i=0;i<256;i++)
{
colors.append());
}img.setColorTable(colors);
scene = new QGraphicsScene;
img3=img.scaledToWidth(500);
pix=QPixmap::fromImage(img3);
item= new QGraphicsPixmapItem(pix);
scene->addItem(item);
view=new QGraphicsView(scene);
view->show();@When I execute this piece of code I can just see a black image. Can someone please help me out what am I doing wrong? here colors is a QVector.
-
wrote on 16 Apr 2012, 13:26 last edited by
oh no my code lost all its formatting...its not even readable now!!
-
wrote on 16 Apr 2012, 14:11 last edited by
[quote author="xenonforlife" date="1334582807"]oh no my code lost all its formatting...its not even readable now!!
[/quote]hit the edit link on the right of it and add the @-tags, that adds formatting to your code.
-
wrote on 17 Apr 2012, 16:04 last edited by
I have updated the code so that it is more readable...I hope someone can help me!!
-
wrote on 17 Apr 2012, 16:26 last edited by
If you had removed the whitespace on the beginning of the lines it would be even more readable...
-
wrote on 17 Apr 2012, 16:40 last edited by
That too is done now...hope someone knows about this issue!!
-
wrote on 23 Apr 2012, 11:55 last edited by
figured it out on my own. Thanks
-
wrote on 23 Apr 2012, 18:46 last edited by
What was the solution? (In case others with the same issue read this thread in the future.)
1/8