int main (int argc, char** argv)
{
QSize resultSize
(281,
377);
image.load("balloon.jpg");
tmpdi = image.scaled(resultSize,Qt::KeepAspectRatio);
// tmpdi = image.scaled(QSize(resultSize.width()*1.5, resultSize.height()*2.0),Qt::KeepAspectRatio);
painter1.
fillRect(QRect(0,
0,resultSize.
width(),resultSize.
height()), Qt
::transparent);
float ratioPegX = resultSize.width() * 1.0 / pegSize.width();
float ratioPegY = resultSize.height() * 1.0 / pegSize.height();
//draw circle on it
for (int pegi = 0; pegi < pegSize.width(); pegi++)
for (int pegj = 0; pegj <pegSize.height(); pegj++)
{
ratioPegX, ratioPegY);
painter1.drawEllipse(rectf.center(), ratioPegX/2.0, ratioPegY/2.0);
}
displayImage.save("x3.png");
return 0;
}
int main (int argc, char** argv)
{
QSize resultSize(281,377);
QSize pegSize(21,29);
QImage image;
image.load("balloon.jpg");
QImage tmpdi;
tmpdi = image.scaled(resultSize,Qt::KeepAspectRatio);
// tmpdi = image.scaled(QSize(resultSize.width()*1.5, resultSize.height()*2.0),Qt::KeepAspectRatio);
QImage displayImage= QImage(resultSize,QImage::Format_ARGB32_Premultiplied);
QPainter painter1(&displayImage);
painter1.fillRect(QRect(0,0,resultSize.width(),resultSize.height()), Qt::transparent);
float ratioPegX = resultSize.width() * 1.0 / pegSize.width();
float ratioPegY = resultSize.height() * 1.0 / pegSize.height();
//draw circle on it
for (int pegi = 0; pegi < pegSize.width(); pegi++)
for (int pegj = 0; pegj <pegSize.height(); pegj++)
{
QRectF rectf = QRectF( pegi * ratioPegX, pegj * ratioPegY,
ratioPegX, ratioPegY);
painter1.drawEllipse(rectf.center(), ratioPegX/2.0, ratioPegY/2.0);
}
displayImage.save("x3.png");
return 0;
}
To copy to clipboard, switch view to plain text mode
Bookmarks