Quantcast
Channel: Adobe Community : Unanswered Discussions - Acrobat
Viewing all articles
Browse latest Browse all 73766

how to add image to appearance using PDEImageCreate?

$
0
0

Hi,

 

Can anyone help me with adding a jpg to an apearance by using PDEImageCreate?

 

This is my code for adding the image to the appearance stream:

 

if (LoadImageFromResource(&pByteArray, MAKEINTRESOURCE(IDJ_STAMP_LOGO_50), _T("JPG")))

{

                              CosObj imageDict, imageFilter, imageStream, encodeParams, xObjectDict;

                              ASStm rawImageStream;

                              ASUns32 imageStreamLength;

 

                              imageStreamLength = (ASUns32)pByteArray.GetSize();

                              rawImageStream = ASMemStmRdOpen(pByteArray.GetData(), imageStreamLength);

 

 

                              PDEImage volatile pdeImage = NULL;

                              PDEImageAttrs pdeImageAttrs;

                              PDEColorSpace pdeColorSpace;

                              ASFixedMatrix imageMatrix;

 

                              memset(&pdeImageAttrs, 0, sizeof(PDEImageAttrs));

                              pdeImageAttrs.flags = kPDEImageExternal;

                              pdeImageAttrs.width = 245;

                              pdeImageAttrs.height = 48;

                              pdeImageAttrs.bitsPerComponent = 8;

 

                              imageMatrix.a = ASInt16ToFixed(245);

                              imageMatrix.d = ASInt16ToFixed(48);

                              imageMatrix.b = imageMatrix.c = fixedZero;

                              imageMatrix.h = fixedTwoSeventy;

                              imageMatrix.v = fixedSeventyTwo;

 

                              pdeColorSpace = PDEColorSpaceCreateFromName(ASAtomFromString("DeviceRGB"));

 

                              PDEFilterArray filterArray;

                              PDEFilterSpec filterSpec;

 

 

                              memset (&filterSpec, 0, sizeof (PDEFilterSpec));

                              filterSpec.name = ASAtomFromString ("DCTDecode");

                              filterArray.numFilters = 1;

                              filterArray.spec[0] = filterSpec;

 

 

                              DURING

                                   pdeImage = PDEImageCreate (&pdeImageAttrs, sizeof(pdeImageAttrs), &imageMatrix,

                                                         kPDEImageEncodedData, pdeColorSpace, NULL, &filterArray,

                                                         rawImageStream, NULL, imageStreamLength);

                              HANDLER

                                             char errorBuf[256];

                                             ASGetErrorString (ASGetExceptionErrorCode(), errorBuf, 256);

       AVAlertNote (errorBuf);

                              END_HANDLER

 

                              imageStream = CosNewNull();

 

                              PDEImageGetCosObj(pdeImage, &imageStream);

 

                              xObjectDict = CosNewDict(cdoc, false,1L);

                              CosDictPut(xObjectDict, ASAtomFromString("LOGO"), imageStream);

 

 

                              CosDictPut(resourcesDict, ASAtomFromString("XObject"), xObjectDict);

 

 

                              strcat_s(buf, " q 245 0 0 48 0 0 cm /LOGO Do Q");

}

 

 

This does not work and a message is given saying the image is already in a container.

 

So the Image XObject is already in the XObject dictionary by calling PDEImageCreate?


Viewing all articles
Browse latest Browse all 73766

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>