Re: How to store a 1 or 8 bit DIB in a pdf as a thumbnail image

31 views
Skip to first unread message

Support

unread,
May 30, 2013, 9:03:21 PM5/30/13
to pdfne...@googlegroups.com
Hi James,
 
For 8 bit images you would pass 8 and for 1 bit 1
 
The main problem is that you are specifying ColorSpace::CreateDeviceRGB(). For 8 bit or 1 bit images you should pass ColorSpace::CreateDeviceGray() instead.
 
Finally, for 1 bpc images makes sure that all lines in image data are byte aligned.
 
 

On Tuesday, May 7, 2013 9:58:57 PM UTC-7, James Dustin wrote:
Hi, 
I've been trying to use the pdfnet sdk to add a thumbnail image to a pdf page.
I'm using the sdk with a existing application that is supplying the images to me as DIBs. Sometime 24bit and sometimes 8 or 1 bit depending on the contents of the page.

Everything is fine for 24bit but the 8bit or 1bit images are stored incorrectly (black, skewed, random etc).

The approach i've used is to get the bits from the dib, flip the BGR to RGB and to pad to DWORD and then used:

Image i = Image::Create(
     DocPtr->GetSDFDoc(),
     (char*) ImageBits,
     ImageBitsSize,
     iWidth, 
     iHeight, 
     8,   // 8 for 24bit? what about 1 bit?
     ColorSpace::CreateDeviceRGB(), 
     EncoderHints);

page.GetSDFObj().Put("Thumb", i.GetSDFObj()); 

Can you let me know what approach i should use for 8 or 1 bit images? Is there a PDFnet method or class to that can either store the 1 or 8bit dibs in the pdf or convert them to a format that can be stored?


Any help appreciated.
thanks,
James
Reply all
Reply to author
Forward
0 new messages