I want to copy many images in one big image in different positions and then save it to .tif, but I don't want to store them in memory all at once, so I need to define tiff file stored on disk, and then write my images one by one.
I'm using Libtiff. The problem that I can't see method that can write pixels to some address with displacement like
RGB* p= init_pointer+dy*width+dx
Is there any solution? (Maybe I should create just binary file and write header by my own, but it's a hard way, maybe libtiff can make it easier?)
So if I rephrase my question: how to obtain raw pointer to tiff data stored on disk for write pixel data?
For example I can create file on disk and write header by hand, and then write my images with offset using raw pointer, something like:
FILE* f = _tfopen(fileName, _T("wb"));
uint64 fileSize = headerSize + (uint64)im.Width() * im.Height() * (grayscale ? 1 : 3);
// Allocate file space
if( _fseeki64(f, fileSize - 1, SEEK_SET) == 0 &&
fputc(0, f) != EOF )
{
_fseeki64(f, 0, SEEK_SET);
// Write header
//write img using pointer with offset
int64 posPixels = headerSize + (rc.top - rcClip.top) * width + (rc.left - rcClip.left);
Once more time: I need to write many images into one image of tiff format like this http://upload.wikimedia.org/wikipedia/commons/a/a0/Rochester_NY.jpg and I must avoid creation of large image in RAM, so I need to write images one by one to file(only one image in RAM in the same time) and I trying to do this using libtiff.
Or another simple example: I have main image M(10000,10000) and I have some image m1(200,200) and I need to write image m1 to M at location (200,300)