Hi,
iam trying to take image1 and on image1 at some portion i want to overwrite image2, i did with the following code.
#include <QtGui/QApplication>
#include <QLabel>
#include <QGraphicsView>
#include <stdio.h>
#include <QRect>
#include <QPainter>
#include "lines1.h"
int main(int argc, char *argv[])
{
Lines window;
firstImage.load(":/images/myImage1.png");
secondImage.load(":/images/myImage2.png");
window.show();
return a.exec();
}
{
rect1.setX(0);
rect1.setY(0);
rect1.setHeight(600);
rect1.setWidth(700);
rect2.setX(500);
rect2.setY(200);
rect2.setHeight(50);
rect2.setWidth(50);
painter.drawImage(rect1, firstImage);
painter.drawImage(rect2,secondImage);
}
#include <QtGui/QApplication>
#include <QLabel>
#include <QGraphicsView>
#include <stdio.h>
#include <QRect>
#include <QPainter>
#include "lines1.h"
QImage firstImage;
QImage secondImage;
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Lines window;
firstImage.load(":/images/myImage1.png");
secondImage.load(":/images/myImage2.png");
window.show();
return a.exec();
}
void Lines::paintEvent(QPaintEvent *event)
{
QPainter painter(this);
QRect rect1,rect2;
rect1.setX(0);
rect1.setY(0);
rect1.setHeight(600);
rect1.setWidth(700);
rect2.setX(500);
rect2.setY(200);
rect2.setHeight(50);
rect2.setWidth(50);
painter.drawImage(rect1, firstImage);
painter.drawImage(rect2,secondImage);
}
To copy to clipboard, switch view to plain text mode
my questions are
1. Is it the correct way of doing it or any better method is available to achieve the same?
2. suppose i want to overwrite at a particular part of image how to know the coordinates of those points? right now i am using trial and error method?
thanks in advance,
regards,
satya
Bookmarks