C++ LibTiff - Read and Save file from and to Memory

前端 未结 3 441
情书的邮戳
情书的邮戳 2021-01-01 19:48

Is there a way in LibTiff how I can read a file from Memory and save it to Memory?

I don\'t want to save the image to the disc first, before opening it with an other

3条回答
  •  一个人的身影
    2021-01-01 20:25

    You should create your own read/write/etc. functions and pass them to TIFFClientOpen (not TIFFOpen) function when creating your TIFF.

    Example:

    TIFF* tif = TIFFClientOpen(
        "Memory", "w", (thandle_t)something_you_will_use_later,
        tiff_Read, tiff_Write, tiff_Seek, tiff_Close, tiff_Size,
        tiff_Map, tiff_Unmap);
    

    And you should also implement following functions (st passed to these functions is the something_you_will_use_later passed to TIFFClientOpen :

    tsize_t tiff_Read(thandle_t st,tdata_t buffer,tsize_t size)
    {
        ...
    };
    
    tsize_t tiff_Write(thandle_t st,tdata_t buffer,tsize_t size)
    {
        ...
    };
    
    int tiff_Close(thandle_t)
    {
        return 0;
    };
    
    toff_t tiff_Seek(thandle_t st,toff_t pos, int whence)
    {
        if (pos == 0xFFFFFFFF)
           return 0xFFFFFFFF;
        ...
    };
    
    toff_t tiff_Size(thandle_t st)
    {
        ...
    };
    
    int tiff_Map(thandle_t, tdata_t*, toff_t*)
    {
        return 0;
    };
    
    void tiff_Unmap(thandle_t, tdata_t, toff_t)
    {
        return;
    };
    

提交回复
热议问题