PDA

View Full Version : there is a way for qt to image mosaicking?



huifeidmeng
13th January 2016, 01:20
hi , smart qter ! there is two picture a image & b image. and i got the image like c image . is a way for to get it ?
eg:
a image
11638
b image
11639
c image
11640

if there is a way , please tell me !
thks much for your kinds !

by
poor huifeidmeng

d_stranz
13th January 2016, 04:57
It is not clear at all what you are asking. Do you want to take two separate images and put them side-by-side in a single image? Do you want to take a side-by-side image and break it into two separate images? Look at the documentation for QImage.

Vikram.Saralaya
13th January 2016, 08:39
QImage aImage("aImg.png"); // say size = 40x40
QImage bImage("bImg.png"); // say size = 70x40

To mosaick:
1. Create an image with the appropriate size.

QImage cImage(110, 40, QImage::Format_RGB32); // say size = 40x40
2. Read pixel data from aImage and bImage and store it in appropriate positions in cImage. This can be done by scanning line by line using QImage::scanLine().
Example, to copy 0th pixel of a specific row from bImage to cImage:

QRgb* bImgLine = (QRgb*)bImage.scanLine(row);
QRgb* cImgLine = (QRgb*)cImage.scanLine(row);
*(cImgLine+40) = *(bImgLine+0);

yeye_olive
13th January 2016, 09:07
Example, to copy 0th pixel of a specific row from bImage to cImage:

QRgb* bImgLine = (QRgb*)bImage.scanLine(row);
QRgb* cImgLine = (QRgb*)cImage.scanLine(row);
*(cImgLine+40) = *(bImgLine+0);
Be careful, your code assumes that bImage has the same format as cImage (QImage::Format_RGB32). You should convert bImage to that format first.