PDA

View Full Version : Three images to load and set transparency set for each



augusbas
29th October 2010, 12:42
Hi all,

I have three images of QImage type, all the three images to be placed one on top of each and transparency should be enabled to see all the images. (I am using QLabel to place my image)

Out of three two will be a static images i.e it remains as constant image.

The third image which is the top of all will be changed at a certain rate. so i need to update the third one at some milliseconds period.

How do i enable transparency of all images and update only the top image. That is only in timer update i need to update or paint the top one and the other images will be there as constant

I tried composition modes, overlay gives transparency but the update of the static image is not perfect as it skips some updates while painting.




/**********Creating a image and all the images to be drawn into it********************/

QImage resultImage;
resultImage = QImage(resultSize,QImage::Format_ARGB32_Premultipl ied);
QPainter painter(&resultImage);

/*************************Top Image ************************************************** **/

QImage image_Radar(get_bmap,512,512,QImage::Format_ARGB32 _Premultiplied);
painter.drawImage(162,68,image_Radar);

painter.setCompositionMode(QPainter::CompositionMo de_Overlay);

/************************Middle Image **************************************/
painter.setPen(QPen(Qt::yellow,3,Qt::SolidLine));
painter.drawEllipse(646,538,90,90);
painter.setPen(QPen(Qt::magenta,3,Qt::SolidLine));
painter.drawEllipse(586,478,210,210);
painter.setPen(QPen(Qt::darkGray,3,Qt::SolidLine)) ;
painter.drawEllipse(526,418,340,340);
painter.setPen(QPen(Qt::green,3,Qt::SolidLine));
painter.drawEllipse(466,358,460,460);
painter.setPen(QPen(Qt::blue,3,Qt::SolidLine));
painter.drawEllipse(406, 298,580,580);
painter.setPen(QPen(Qt::cyan,3,Qt::SolidLine));
painter.drawEllipse(346,238,700,700);
painter.setPen(QPen(Qt::lightGray,3,Qt::SolidLine) );
painter.drawEllipse(286,178,820,820);
painter.setPen(QPen(Qt::darkRed,3,Qt::SolidLine));
painter.drawEllipse(226,118,940,940);
painter.setPen(QPen(Qt::green,3,Qt::SolidLine));
painter.drawEllipse(166,58,1060,1060);
painter.setPen(QPen(Qt::red,3,Qt::SolidLine));
painter.drawEllipse(106,-2,1180,1180);


/**********************Bottom Image **********************************/
QImage image_src;
image_src.load("/aegean-60km.bmp");
painter.drawImage(0, 0, image_src);
/************************************************** ****************/
painter.end();

label->setBackgroundRole(QPalette::Base);
label->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
label->setPixmap(QPixmap::fromImage(resultImage));
label->setScaledContents(true); */