[SOLVED] DrawEllipse and save image problem
-
Hi to all,
I'm trying to draw an ellipse and save it in a PNG file.
The image is really simple, but I've a problem because the image saved is not clear (it has something like noise...).@ QImage *placemark = new QImage(QSize(16,16),QImage::Format_ARGB32);
QPainter p;
p.begin(placemark);
p.setPen(c);
p.setBrush(QBrush(c));
p.drawEllipse(QRectF(4,4,8,8));
p.end();placemark->save(QString("./images/%1.png").arg(name), "PNG")<< endl;
@The variable c is a QColor.
The result is this "image":http://dl.dropbox.com/u/3894235/BOAT.png -
Have you tried to clear the image first?
It will contain random bits after construction. Cleaning them up takes time and an idea which color the user will want as a background.
If you are going to draw each pixel anyway, then that clean-up time as also wasted.
-
Thank you so much Tobias!
I've solved by cleaning the image.
I've used this code:@ painter.setCompositionMode(QPainter::CompositionMode_Source)
painter.fillRect(0,0,image->width(),image->height(), Qt::transparent);
@
Now it is ok!!