f



PDEImageGetData question

Dear all, I'm trying to extract a raster image stored in a PDF as a ICCBased
8 bit image XObject, and I'm using PDEImageGetDataLen and GetData to get the
data and tried to put it in an SVG as <image
xlink:href="data:image/jpeg,base64,..." /> with no luck. I know the jpeg and
base64 bit are probably wrong, but I really have no idea how to do it, nor
how to store the data from GetData into a physical jpg/bmp/whatever file and
xlink to it. I've read chapter 4 of the PDF 1.4 manual and am still very
confused... According to Acrobat PDF Inspector, the image does not have any
decode params, and it's colour space is ICCBased, with 8 bit samples.

Please enlighten... If you could just give me an ever so simply code example
of how to present the data extracted from PDEImageGetData in an XML readible
format.

Thanks, Julius


0
Dr
7/8/2003 12:37:10 AM
comp.text.pdf 5600 articles. 0 followers. ramon (1518) is leader. Post Follow

3 Replies
1226 Views

Similar Articles

[PageSpeed] 43

"Dr Joolz" <jxm96c@hotmail.com> wrote:

>Dear all, I'm trying to extract a raster image stored in a PDF as a ICCBased
>8 bit image XObject, and I'm using PDEImageGetDataLen and GetData to get the
>data and tried to put it in an SVG as <image
>xlink:href="data:image/jpeg,base64,..." /> with no luck. I know the jpeg and
>base64 bit are probably wrong, but I really have no idea how to do it, nor
>how to store the data from GetData into a physical jpg/bmp/whatever file and
>xlink to it. I've read chapter 4 of the PDF 1.4 manual and am still very
>confused... According to Acrobat PDF Inspector, the image does not have any
>decode params, and it's colour space is ICCBased, with 8 bit samples.

The data you extract is just the pixels. You should realise that every
raster file format (BMP, GIF, TIFF, JPEG etc. etc.) contains not only
the pixels but information about the image, such as width, height,
colour space, metadata, and more. Frequently the arrangement of the
pixels is different - for instance in a BMP they are in the order
B,G,R rather than R,G,B and there are different rules for what to do
at the end of a scan line.

So, to write successfully an image file you need EITHER
(a) a full and detailed knowledege of the file format, in order to
write the code to generate it (I'd recommend sticking to BMP in this
case), OR
(b) use of a library or API that knows how to write the image - for
instance libjpeg for JPEG, libtiff for TIFF.  
>
>Please enlighten... If you could just give me an ever so simply code example
>of how to present the data extracted from PDEImageGetData in an XML readible
>format.

case (a) wouldn't be ever so simple, even for BMP.  
----------------------------------------
Aandi Inston  quite@dial.pipex.com http://www.quite.com
Please support usenet! Post replies and follow-ups, don't e-mail them.

0
quite
7/8/2003 7:46:50 AM
Hi Aandi, thanks for your help. I'm trying out the jpeglib C library and am
having some luck. However, there are few things I would like to ask for help
on. Firstly I've got a ASUns8* from PDEImageGetData, all the ASInt32s from
PDEImageGetAttrs (800x600, 8 bit per component), the colourspace name of
'DeviceRGB' and decode[8] is all 0's. Now Jpeglib by default sets the bit
per sample at 8, and wants width, height, colourspace and the image buffer
in unsigned char*. I've tried casting what I got from GetData to char* into
the image buffer, width and height as ASInt32 no problem, and sticking with
JPEGlib's JCS_RGB colourspace, the result I got is broken. The Jpg file only
gets written about 1/5 from teh top and it's very scrambled random colours,
and those coloured lines are not reaching the full width (600) of the image
while the rest of the image shows grey. My plug-in crashes half way thru
anyway. I'm just wondering if the colourspace is equivalent? Or is DeviceRGB
a different kind of RGB? What do I need to do to the image data from GetData
beforre giving it to jpeglib, which takes an unsigned char* as the image
buffer. Thanks!

Please enlighten, Julius

-- 
***24 hours in a day...24 beers in a case...coincidence?***
"Aandi Inston" <quite@dial.pipex.com> wrote in message
news:3f0a760e.3021607581@reading.news.pipex.net...
> "Dr Joolz" <jxm96c@hotmail.com> wrote:
>
> >Dear all, I'm trying to extract a raster image stored in a PDF as a
ICCBased
> >8 bit image XObject, and I'm using PDEImageGetDataLen and GetData to get
the
> >data and tried to put it in an SVG as <image
> >xlink:href="data:image/jpeg,base64,..." /> with no luck. I know the jpeg
and
> >base64 bit are probably wrong, but I really have no idea how to do it,
nor
> >how to store the data from GetData into a physical jpg/bmp/whatever file
and
> >xlink to it. I've read chapter 4 of the PDF 1.4 manual and am still very
> >confused... According to Acrobat PDF Inspector, the image does not have
any
> >decode params, and it's colour space is ICCBased, with 8 bit samples.
>
> The data you extract is just the pixels. You should realise that every
> raster file format (BMP, GIF, TIFF, JPEG etc. etc.) contains not only
> the pixels but information about the image, such as width, height,
> colour space, metadata, and more. Frequently the arrangement of the
> pixels is different - for instance in a BMP they are in the order
> B,G,R rather than R,G,B and there are different rules for what to do
> at the end of a scan line.
>
> So, to write successfully an image file you need EITHER
> (a) a full and detailed knowledege of the file format, in order to
> write the code to generate it (I'd recommend sticking to BMP in this
> case), OR
> (b) use of a library or API that knows how to write the image - for
> instance libjpeg for JPEG, libtiff for TIFF.
> >
> >Please enlighten... If you could just give me an ever so simply code
example
> >of how to present the data extracted from PDEImageGetData in an XML
readible
> >format.
>
> case (a) wouldn't be ever so simple, even for BMP.
> ----------------------------------------
> Aandi Inston  quite@dial.pipex.com http://www.quite.com
> Please support usenet! Post replies and follow-ups, don't e-mail them.
>


0
Dr
7/11/2003 4:34:07 PM
Hi there, I've got it all working now. Thanks :-)

Jules


0
Dr
7/12/2003 10:20:26 PM
Reply: