0

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)

mrgloom
  • 20,061
  • 36
  • 171
  • 301
  • There is no such thing like "pointer to data stored on disk". You still need to explain better what you want to do. – Alex F Nov 27 '13 at 11:40
  • @AlexFarber add example. – mrgloom Nov 27 '13 at 11:59
  • Looks like classic XY problem: http://meta.stackexchange.com/questions/66377/what-is-the-xy-problem I am afraid that nobody can help unless you rephrase the question. – Alex F Nov 27 '13 at 12:10
  • @AlexFarber 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. – mrgloom Nov 27 '13 at 12:19
  • Have you tried writing it with Tiles? Each tile is compressed individually. – BitBank Dec 09 '13 at 18:57

0 Answers0