Hi,
I am biginner in C++ and I tried to combine two memory buffers of TIFF image data to one so that to save it as one image. ie: left half image + right half image = a full image. That was not successfull. The code part is:
char * buf1 = (char *)malloc(imagel eft.width * image1.length); // for left image
char * buf2 = (char *)malloc(imager ight.width * image2.length); // for right image
// for final image
char * buf3 = (char *)malloc(imagel eft.width + imageright.widt h * imageleft.lengt h+imageright.le ngth);
buf1 = getImage("image left");// left image
buf1 = getImage("image right");// right image
// now need to merge the two buffers on widthwise
// ie: buf1 (left half image) + buf2 (right half image) = buf3 (final image)
//image_height is same for all images
int image_height=im ageleft.half;
for (int y = 0; y < image_height; y++) {
memcpy(buf3+ y * imageleft.width , buf1, y*imageleft.wid th );
memcpy(buf3+ y * imageleft.width +imageright.wid th , buf2, y*imageleft.wid th+imageright.w idth );
}
//.... Now this gives unexpected result. What is wrong with this pls?
madhavan
I am biginner in C++ and I tried to combine two memory buffers of TIFF image data to one so that to save it as one image. ie: left half image + right half image = a full image. That was not successfull. The code part is:
char * buf1 = (char *)malloc(imagel eft.width * image1.length); // for left image
char * buf2 = (char *)malloc(imager ight.width * image2.length); // for right image
// for final image
char * buf3 = (char *)malloc(imagel eft.width + imageright.widt h * imageleft.lengt h+imageright.le ngth);
buf1 = getImage("image left");// left image
buf1 = getImage("image right");// right image
// now need to merge the two buffers on widthwise
// ie: buf1 (left half image) + buf2 (right half image) = buf3 (final image)
//image_height is same for all images
int image_height=im ageleft.half;
for (int y = 0; y < image_height; y++) {
memcpy(buf3+ y * imageleft.width , buf1, y*imageleft.wid th );
memcpy(buf3+ y * imageleft.width +imageright.wid th , buf2, y*imageleft.wid th+imageright.w idth );
}
//.... Now this gives unexpected result. What is wrong with this pls?
madhavan
Comment