PDA

View Full Version : grabwidget image capturing problem



prasannach88
10th August 2011, 11:27
I am trying to capture the image of a QGraphicsView . I have used grabwidget to capture this image . I have written a small program and i successfully captured the image . But the problem is when i tried to integrate it with my product the image captured is not clear (dark lines and spots on the image ). Can anyone give me any siggestion on this.

qlands
10th August 2011, 13:53
Hi,

You can also render your Scene to a pixmap and save it. See for example:



QImage *image = new QImage(103,103,QImage::Format_RGB32); //Creates an image of a size 103x103 //Change for the size of your scene
QRgb value;
value = qRgb(255, 255, 255);
image->fill(value); //Fill the image with white
QPainter *painter = new QPainter(image); //Create a new painter based on the image

//Renders the scene to the painter
scene.render(painter);

image.save("/home/cquiros/tnkicono.jpg","JPG"); //Saves the image


Depending on the file format, you will lose some image quality.

Hope it helps.

Carlos

prasannach88
16th August 2011, 05:39
Thanks i tried with render and it worked .