PDF Generating Tool Support Forum

HOME   Login   Register    Search




  Subject: BMP in BASE64 encoding
   PostPosted: 30 Nov 2011, 13:45 
My html file contains images in BMP format encoded as BASE64 (see example.zip).

I downloaded the demo version of PD4ML and run the Converter.class to do a quick test:

java -Xmx512m -cp pd4ml_demo.jar;ss_css2.jar;. Converter example.html example.pdf "" ""

The GIF image has been successfully converted in the PDF file. But the BMP file is missing (see example.pdf).

Does pd4ml support BMP files?


Attachments:
Converter.java [1.39 KiB]
Downloaded 20 times
File comment: Contains example.html
example.zip [1.54 KiB]
Downloaded 19 times
example.pdf [3.25 KiB]
Downloaded 15 times
  Subject: Re: BMP in BASE64 encoding
   PostPosted: 30 Nov 2011, 23:58 
Does the BMP have transparency mask?
Could you please publish the image in its original form (as BMP file)?
Thank you!


  Subject: Re: BMP in BASE64 encoding
   PostPosted: 01 Dec 2011, 16:36 
Please find the file signature.bmp in the attached signature.zip file.


Attachments:
signature.zip [365 Bytes]
Downloaded 16 times
  Subject: Re: BMP in BASE64 encoding
   PostPosted: 02 Dec 2011, 22:00 
Well, with your sample image we identified and fixed a bug in our code, related to 1-bit bitmap images.

However when I tried your original HTML sample with base64-encoded images, the BMP still failed to appear in the resulting PDF. Which is quite strange.

I have dumped base64-decoded image ("bad image") and the second image you provided ("good image"). There is a difference in the file headers (the rests of the images are identical). See the attachment.

It is difficult to say if the "bad image" has been corrupted during base64 encoding or it is a species of BMP format, known only to Microsoft.

The impacted bytes are quite important:

Good image:
File type is :BM
Size of file is :4990
Size of bitmapinfoheader is :40
Width is :342
Height is :112
Planes is :1
BitCount is :1
Compression is :0
SizeImage is :4928
X-Pixels per meter is :0
Y-Pixels per meter is :0
Colors used are :2
Colors important are :2

Bad image:
File type is :BM
Size of file is :4990
Size of bitmapinfoheader is :40
Width is :342
Height is :112
Planes is :1
BitCount is :1
Compression is :0
SizeImage is :0
X-Pixels per meter is :2834
Y-Pixels per meter is :2834
Colors used are :2
Colors important are :0

It looks like MS IE repairs the "bad image" on-a-fly and displays it correctly. If you save the image from MS IE you'll get an image byte-to-byte identical to the "good image".

We would implement a workaround for such corrupted images, but it is not obvious how to obtain the missing "size of the raw bitmap data" value.


Attachments:
bmpcmp.png
bmpcmp.png [ 22.28 KiB | Viewed 641 times ]
  Subject: Re: BMP in BASE64 encoding
   PostPosted: 13 Dec 2011, 14:05 
http://en.wikipedia.org/wiki/BMP_file_format explains how to calculate SizeImage. I will update our code and set this value. Would it be possible that you send me a test pd4ml package containing the bug fix for 1 bit bmp files?


  Subject: Re: BMP in BASE64 encoding
   PostPosted: 14 Dec 2011, 19:13 
I've just sent the version to your email box.


  Subject: Re: BMP in BASE64 encoding
   PostPosted: 19 Dec 2011, 12:54 
I tested your bux fix. But it seems there is still a problem.

Please find attached my example containing now BMP files which have set the ImageSize correctly (BMP file & BASE64 encoded).

Could you have a look at it again?


Attachments:
example.zip [2.86 KiB]
Downloaded 15 times
  Subject: Re: BMP in BASE64 encoding
   PostPosted: 19 Dec 2011, 12:55 
I tested your bux fix. But it seems there is still a problem.

Please find attached my example containing now BMP files which have set the ImageSize correctly.

Could you have a look at it again?


  Subject: Re: BMP in BASE64 encoding
   PostPosted: 19 Dec 2011, 16:47 
Yes, the images you provided are still not compatible with PD4ML.

I did the simple test again: opened your HTML in MS IE and saved the BMP as signature2.bmp and included it to example.html

Obviously MS IE again repaired format errors of your BMP. See attached.

I also compared signature.bmp and signature2.bmp. As I see 2 values "40" and "13" are swapped:


Attachments:
pd4ml2631.pdf [744.17 KiB]
Downloaded 15 times
screenshot.png
screenshot.png [ 17.89 KiB | Viewed 592 times ]
  Subject: Re: BMP in BASE64 encoding
   PostPosted: 20 Dec 2011, 09:30 
Many thanks!!! I didn't take litte endian into account. Now it is working.



[Reply]     [ 10 posts ] 

Copyright ©2004-10 zefer|org. All rights reserved. Bookmark and Share