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

Adding an image to an annotation

$
0
0

Hi,

 

I'm trying to add an image to an appearance for an annotation, but it just doesn't seem to work.

 

CArray<char> pByteArray;

 

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

{

      CosObj imageDict, imageFilter, imageStream, xObjectDict;

      ASStm rawImageStream;

      ASUns32 imageStreamLength

 

      imageStreamLength = (ASUns32)pByteArray.GetSize();

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

 

      imageDict = CosNewDict(cdoc, false, 6);

      imageFilter = CosNewName(cdoc, false, ASAtomFromString("DCTDecode"));

 

 

      CosDictPut(imageDict,ASAtomFromString("Filter"),imageFilter);

      CosDictPut(imageDict,ASAtomFromString("Type"),CosNewName(cdoc, false, ASAtomFromString("XObject")));

      CosDictPut(imageDict,ASAtomFromString("Subtype"),CosNewName(cdoc, false, ASAtomFromString("Image")));

      CosDictPut(imageDict,ASAtomFromString("Name"),CosNewName(cdoc, false, ASAtomFromString("ImgKoopmansLogo")));

      CosDictPut(imageDict,ASAtomFromString("ColorSpace"),CosNewName(cdoc, false, ASAtomFromString("DeviceRGB")));

      CosDictPut(imageDict,ASAtomFromString("Height"),CosNewInteger(cdoc, false, 208));

      CosDictPut(imageDict,ASAtomFromString("Width"),CosNewInteger(cdoc, false, 714));

      CosDictPut(imageDict,ASAtomFromString("BitsPerComponent"),CosNewInteg er(cdoc, false, 8));

      CosDictPut(imageDict,ASAtomFromString("Length"), CosNewInteger(cdoc, false, imageStreamLength));

 

      imageStream = CosNewStream(cdoc, true, rawImageStream, 0, false, imageDict, imageFilter, -1);

 

      xObjectDict = CosNewDict(cdoc, false,1);

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

 

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

}

 

 

Loading the image from resource works and the Image XObject is referred to in the appearance stream like this:

 

strcat_s(buf, "q /KOOPMANS_LOGO Do Q");

 

Also the procset resources look like this:

 

cProcSetObj = CosNewArray(cdoc, false, 3L);

CosArrayPut(cProcSetObj, 0L, CosNewNameFromString(cdoc, false, "PDF"));

CosArrayPut(cProcSetObj, 1L, CosNewNameFromString(cdoc, false, "Text"));

CosArrayPut(cProcSetObj, 2L, CosNewNameFromString(cdoc, false, "ImageC"));

CosDictPutKeyString(resourcesDict, "ProcSet", cProcSetObj);

 

The image is not showing when placing an annotation.

 

Can anyone see what I'm missing here?


Viewing all articles
Browse latest Browse all 73766

Trending Articles



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