sivarajankumar / alivepdf

Automatically exported from code.google.com/p/alivepdf
0 stars 0 forks source link

Gray scale jpegs don't work - heres a fix #152

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Use a gray-scale Jpeg image
2. Create PDF
3. Tada ! 

What is the expected output? What do you see instead?
The image shows up as a white rectangle.

What version of the product are you using? On what operating system?
0.1.4.9  OS-X

Please provide any additional information below.
Gray-scale Jpegs must use the DeviceGray ColorSpace.

To fix, modify images/JPEGImage.as, add 3 lines:

     physicalWidthDpi = getShortBigEndian(data, 8);
     physicalHeightDpi = getShortBigEndian(data, 10);
>>>  if ( (data[12] & 0xFF) == 1) cs ='DeviceGray';  // data[12] is # of
components: 1 for grey scale

     ...

     x = getShortBigEndian(data, 8);
     y = getShortBigEndian(data, 10);
>>>  if ( (data[12] & 0xFF) == 1) cs ='DeviceGray';

     ...

     width = getShortBigEndian(data, 3);
     height = getShortBigEndian(data, 1);
>>> if ( (data[5] & 0xFF) == 1) cs ='DeviceGray'; 

Original issue reported on code.google.com by andredeb...@gmail.com on 3 Sep 2009 at 12:09

GoogleCodeExporter commented 8 years ago
Thanks for the bug and fix!

I will include the fix in the 0.1.5 RC.

Thibault

Original comment by thibault.imbert on 23 Jan 2010 at 9:55

GoogleCodeExporter commented 8 years ago
Hello,
It still does not work for me. I am using the addImage method with a 'JPG' 
argument.
I even force the cs to be at DeviceGray constantly, in case the test on data[5] 
and data[12] would not work. Are you sure it works?

Original comment by thebigne...@gmail.com on 17 Oct 2010 at 10:08

GoogleCodeExporter commented 8 years ago
I am trying to get an image in PDF which has only gray channel like I saw a 
damo on alive PDF http://alivepdf.bytearray.org/?p=3 it generates pdf with CMYK 
channels but when I provide CMYK ColorSpace it still outputs RGB channels. I 
may be missing something. Please help me what else is missing. 

Original comment by rahat.j...@gmail.com on 22 Jun 2011 at 5:29