Skip navigation
Currently Being Moderated

how to insert png to pdf?

May 21, 2012 12:58 AM

Tags: #import_png

I have readed the pdf reference 1.6,i want to insert png to pdf.

i konw that the png consits of alpha and RGB,

31 0 obj
<</BitsPerComponent 8/ColorSpace/DeviceRGB/Filter/DCTDecode/Height 154/Length 8781/Name/X/SMask 30 0 R/Subtype/Image/Type/XObject/Width 154>>stream

I know that 30 0 obj is alpha data after encompressed,buf i don't  konw the stream object in 31 0 obj, how to get the stream data from png?

 
Replies
  • Currently Being Moderated
    May 21, 2012 3:46 AM   in reply to cheng845

    You need to decode the PNG format to get just the raw pixels.  Then separate the alpha pixels from the rest and write both objects.

     

    Also, DCTDecode is fro JPEG.  You'd probably want FlateDecode for PNG.

     
    |
    Mark as:
  • Currently Being Moderated
    May 21, 2012 4:13 AM   in reply to lrosenth

    I have get the alpha piexels and raw pixel(RGB) using the libpng to decode png format, but i don't know that what's  the content of 31 0 obj stream.

    I use the adobe acrobat to insert a png to pdf.

    the result:

     

    24 0 obj

    <</Contents 43 0 R/CropBox[0.0 0.0 612.0 792.0]/Group 39 0 R/ID 40 0 R/MediaBox[0.0 0.0 612.0 792.0]/PZ 1.0/Parent 14 0 R/Resources<</ColorSpace<</CS0 33 0 R>>/Font<</C0_0 38 0 R>>/ProcSet[/PDF/Text/ImageC]/XObject<</Im0 44 0 R>>>>/Rotate 0/Type/Page>>

     

    44 0 obj

    <</BitsPerComponent 8/ColorSpace/DeviceRGB/Filter/DCTDecode/Height 154/Length 8792/Name/X/SMask 45 0 R/Subtype/Image/Type/XObject/Width 154>>stream

    ............

    endstream

     

    45 0 obj
    <</BitsPerComponent 8/ColorSpace/DeviceGray/Filter/FlateDecode/Height 154/Length 6157/Name/X/Subtype/Image/Type/XObject/Width 154>>stream

    ....

    endstream

    

    I know that the stream data of 45 0 obj is alpha data  after compressed,but i don't know what's format the stream data of 44 0 obj  and how to get it from a png.

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 21, 2013 2:17 AM   in reply to cheng_x

    What are the values of image matrix for png image file ?

     

    imageMatrix.a = ASInt16ToFixed(width);

                        imageMatrix.d = ASInt16ToFixed(height);

                        imageMatrix.b = imageMatrix.c = fixedZero;

                        imageMatrix.h = fixedZero;

                        imageMatrix.v = fixedZero;

     

     

    Is it correct for png ?

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points