
Thread
1999.05.17 17:41 "Re: CCITT compressing without writing a file.", by Eric Shapiro
I am currently processing images. They arrive with various types of compression and various bit depths. I reduce them to single-bit-per-pixel, and want to compress them with Group IV CCITT. Currently, I am doing this by writing a new TIFF file, then reading it back in to get the compressed data. Surely there is a way I can compress from memory to memory, avoiding the overhead of having to create a new TIFF image, and the disk activity.
I don't know if this is the easiest way to do this, but...
One thing you can do is to modify the low-level i/o bottlenecks to use memory instead of the file system.
You can allocate a block of RAM and make it look to the TIFF code like it is actually a file.
We did something similar so we can write multiple TIFF files into the middle of one of our document files as a blob.
Basically, you use a private structure that looks something like:
typedef struct
{
char *theMemory;
long allocatedBytes, actualBytesUsed;
long currentOffset;
} MyFakeTIFF;
and return a pointer to one of these from a call to open. (Use the correct TIFF types in the structure, though...I don't have the code in front of me right now and can't remember them)
-Eric
-------------------------------------------------
Eric Shapiro eric@relium.com
Relium Corp. www.relium.com
-------------------------------------------------