angli232 / tiff

(Experimental) Go package to read and write TIFF or TIFF-like files.
BSD 3-Clause "New" or "Revised" License
2 stars 0 forks source link

Decompression after decoding #1

Open ghost opened 4 years ago

ghost commented 4 years ago

Do i need compress/decompress image before/after encoding/decoding. It seems LZV images after decoding remains compressed.

angli232 commented 4 years ago

This project is still pretty experimental. Currently only some features used by myself are well tested. However, lzw should work, and lzw decompression did pass my unit test. Do you have an example of how you are trying to use this package? And if possible post the output of tiffinfo or tiffdump ran on the tiff file you are trying to deal with.

angli232 commented 4 years ago

To answer your first question. *Image.DecodeImage returns decompressed image data as []uint8 or []uint16. The size of this array is height * width * samplePerPixel, to get a pixel you access buf[samplePerPixel*(width * x + y) + c], in which x is the index of the pixel along the direction of height, y is along width direction, c is the channel. I have another not-yet-released package to deal with this style of multi-dimensional array, but there is still quite some work to finish with that.

There is truly a way to get the compressed data. *Image.RawStripReader/RawTileReader provides access to raw data for custom applications.

synxroform commented 4 years ago

Thank you for reply. You can see example source code in . I don’t know why, but my program output something like a broken TV when the image is compressed. Maybe i do something wrong.