c++ - Qt- How to merge four images in single rounded image -


i tried show avatar image in rounded form. working good.

qimage image(":/images/person1.png");  if (image.width() != cglobalzone::avatar_width_m ||         image.height() != cglobalzone::avatar_height_m)     image = image.scaled(qsize(cglobalzone::avatar_width_m , cglobalzone::avatar_height_m ),                          qt::keepaspectratiobyexpanding, qt::smoothtransformation);  qimage roundedimage(cglobalzone::avatar_width_m, cglobalzone::avatar_height_m, qimage::format_argb32);  roundedimage.fill(qt::transparent);  qbrush brush(image); qpainter painter(&roundedimage); qpen pen(qcolor(176, 216, 242), 1);  painter.setpen(pen); painter.setrenderhint(qpainter::antialiasing); painter.setbrush(brush); painter.drawellipse(1.0, 1.0, cglobalzone::avatar_width_m - 2, cglobalzone::avatar_height_m - 2);  m_defaultavatar = qpixmap::fromimage(roundedimage); 

avatar_width_m & avatar_height_m public variables.
here result of lines:
enter image description here
, want change rounded image merging 4 photos. i've changed line

    image.height() != cglobalzone::avatar_height_m) image = image.scaled(qsize(cglobalzone::avatar_width_m , cglobalzone::avatar_height_m ),                      qt::keepaspectratiobyexpanding, qt::smoothtransformation); 

to this:

   image.height() != cglobalzone::avatar_height_m) image = image.scaled(qsize(cglobalzone::avatar_width_m / 2, cglobalzone::avatar_height_m /2),                      qt::keepaspectratiobyexpanding, qt::smoothtransformation); 

and result :
enter image description here
me it's not enough. target using 4 different images in rounded avatar instead of single image. how change above codes merge
qimage image(":/images/person1.png");
,
qimage image2(":/images/person2.png");
,
qimage image(":/images/person3.png");
and
qimage image4(":/images/person4.png");

why not merging 4 images first , rounding merged image?

// create merged image qimage mergedimage(2*avatar_width_m, avatar_height_m ,qimage::format_rgb32); qpainter painter; painter.begin(&combinedimage); painter.drawimage(0, 0, image.scaled(avatar_width_m,avatar_height_m)); painter.drawimage(avatar_width_m, 0, image2.scaled(avatar_width_m,avatar_height_m)); painter.drawimage(0, avatar_height_m, image3.scaled(avatar_width_m,avatar_height_m)); painter.drawimage(avatar_width_m, avatar_height_m, image4.scaled(avatar_width_m,avatar_height_m));     painter.end();  // round merged image... 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -