afplib icon indicating copy to clipboard operation
afplib copied to clipboard

How to view the image (ImageData) as tiff or pdf.

Open connectmedinesh opened this issue 2 years ago • 3 comments

Please help me on this,

I was able to open MO:DCA file using your lib and I was successful getting hands on the Image (IOCA) but I don't know to how view the image as tiff or pdf.

The properties I found on the IOCA file using SDFHelper.ipds2sdf and Triplets (BeginSegment, BeginImage,ImageSizeImpl,IDESizeImpl,ImageLUTID, ImageEncodingImpl, ImageData)

getSEGNAME() :null getOBJTYPE() :255 getVRESOL :2000, getVSIZE :5000 getHRESOL :2000 getHSIZE :1196 getUNITBASE :0 iDESizeImpl :1 ImageLUTID : 0 getBITORDR :null getCOMPRID :ConstG4MMR (G4 MMR-Modified Modified READ) getRECID :1

connectmedinesh avatar Jan 16 '23 03:01 connectmedinesh

Hi @connectmedinesh,

this looks like a black and white G4 MMR encoded image. You'd need to extract the binary data from ImageData, decompress using G4 MMR and then construct a B/W image from it. I believe there are some old G4 MMR decompressors on the internet.

Hope that helps! Yan

yan74 avatar Jan 16 '23 08:01 yan74

Hi @yan74, Thanks for the prompt response. I was able to decompress the Binary data and now I have the G4 MMR decompressed data. Can you please tell me what do you mean by "construct B/W Image", Can you please give me an idea how to construct a B/W Image or sample code, it would be so helpful.

Java Class : https://github.com/ESCRIBA/lenient-pdf-compare/blob/4dcedec705b70328fa78935e0e2f95a94a89ef8c/src/com/sun/pdfview/decode/CCITTFaxDecoder.java

Method used: public synchronized void decodeT6(byte[] buffer, byte[] compData,int startX, int height)

Thanks in advance.

connectmedinesh avatar Jan 17 '23 04:01 connectmedinesh

I guess now you have your black and white pixels represented by bits in that buffer. Construct an empty BufferedImage having the IOCA images width and height and with a b/w or grey color space. Looping over height and width with y and x you would figure out the bit in that buffer that represent the x,y pixel you are currently at. Depending on whether this is 0 or 1 you set a white or black pixel at x,y.

I know this is very rough and high level - there should be some code on the internet on how to do this.

yan74 avatar Jan 17 '23 08:01 yan74