HasICCProfile() public method

public HasICCProfile ( ) : bool
return bool
示例#1
0
 /**
 * Adds an image to the document but not to the page resources. It is used with
 * templates and <CODE>Document.Add(Image)</CODE>.
 * @param image the <CODE>Image</CODE> to add
 * @param fixedRef the reference to used. It may be <CODE>null</CODE>,
 * a <CODE>PdfIndirectReference</CODE> or a <CODE>PRIndirectReference</CODE>.
 * @return the name of the image added
 * @throws PdfException on error
 * @throws DocumentException on error
 */
 public PdfName AddDirectImageSimple(Image image, PdfIndirectReference fixedRef)
 {
     PdfName name;
     // if the images is already added, just retrieve the name
     if (images.ContainsKey(image.MySerialId)) {
         name = images[image.MySerialId];
     }
     // if it's a new image, add it to the document
     else {
         if (image.IsImgTemplate()) {
             name = new PdfName("img" + images.Count);
             if (image is ImgWMF){
                 ImgWMF wmf = (ImgWMF)image;
                 wmf.ReadWMF(PdfTemplate.CreateTemplate(this, 0, 0));
             }
         }
         else {
             PdfIndirectReference dref = image.DirectReference;
             if (dref != null) {
                 PdfName rname = new PdfName("img" + images.Count);
                 images[image.MySerialId] = rname;
                 imageDictionary.Put(rname, dref);
                 return rname;
             }
             Image maskImage = image.ImageMask;
             PdfIndirectReference maskRef = null;
             if (maskImage != null) {
                 PdfName mname = images[maskImage.MySerialId];
                 maskRef = GetImageReference(mname);
             }
             PdfImage i = new PdfImage(image, "img" + images.Count, maskRef);
             if (image is ImgJBIG2) {
                 byte[] globals = ((ImgJBIG2) image).GlobalBytes;
                 if (globals != null) {
                     PdfDictionary decodeparms = new PdfDictionary();
                     decodeparms.Put(PdfName.JBIG2GLOBALS, GetReferenceJBIG2Globals(globals));
                     i.Put(PdfName.DECODEPARMS, decodeparms);
                 }
             }
             if (image.HasICCProfile()) {
                 PdfICCBased icc = new PdfICCBased(image.TagICC, image.CompressionLevel);
                 PdfIndirectReference iccRef = Add(icc);
                 PdfArray iccArray = new PdfArray();
                 iccArray.Add(PdfName.ICCBASED);
                 iccArray.Add(iccRef);
                 PdfArray colorspace = i.GetAsArray(PdfName.COLORSPACE);
                 if (colorspace != null) {
                     if (colorspace.Size > 1 && PdfName.INDEXED.Equals(colorspace[0]))
                         colorspace[1] = iccArray;
                     else
                         i.Put(PdfName.COLORSPACE, iccArray);
                 }
                 else
                     i.Put(PdfName.COLORSPACE, iccArray);
             }
             Add(i, fixedRef);
             name = i.Name;
         }
         images[image.MySerialId] = name;
     }
     return name;
 }
示例#2
0
 /**
 * Adds an image to the document but not to the page resources. It is used with
 * templates and <CODE>Document.Add(Image)</CODE>.
 * @param image the <CODE>Image</CODE> to add
 * @param fixedRef the reference to used. It may be <CODE>null</CODE>,
 * a <CODE>PdfIndirectReference</CODE> or a <CODE>PRIndirectReference</CODE>.
 * @return the name of the image added
 * @throws PdfException on error
 * @throws DocumentException on error
 */
 public PdfName AddDirectImageSimple(Image image, PdfIndirectReference fixedRef)
 {
     PdfName name;
     // if the images is already added, just retrieve the name
     if (images.ContainsKey(image.MySerialId)) {
         name = (PdfName) images[image.MySerialId];
     }
     // if it's a new image, add it to the document
     else {
         if (image.IsImgTemplate()) {
             name = new PdfName("img" + images.Count);
             if (image.TemplateData == null) {
                 if (image is ImgWMF){
                     ImgWMF wmf = (ImgWMF)image;
                     wmf.ReadWMF(PdfTemplate.CreateTemplate(this, 0, 0));
                 }
             }
         }
         else {
             PdfIndirectReference dref = image.DirectReference;
             if (dref != null) {
                 PdfName rname = new PdfName("img" + images.Count);
                 images[image.MySerialId] = rname;
                 imageDictionary.Put(rname, dref);
                 return rname;
             }
             Image maskImage = image.ImageMask;
             PdfIndirectReference maskRef = null;
             if (maskImage != null) {
                 PdfName mname = (PdfName)images[maskImage.MySerialId];
                 maskRef = GetImageReference(mname);
             }
             PdfImage i = new PdfImage(image, "img" + images.Count, maskRef);
             if (image.HasICCProfile()) {
                 PdfICCBased icc = new PdfICCBased(image.TagICC);
                 PdfIndirectReference iccRef = Add(icc);
                 PdfArray iccArray = new PdfArray();
                 iccArray.Add(PdfName.ICCBASED);
                 iccArray.Add(iccRef);
                 PdfObject colorspace = i.Get(PdfName.COLORSPACE);
                 if (colorspace != null && colorspace.IsArray()) {
                     ArrayList ar = ((PdfArray)colorspace).ArrayList;
                     if (ar.Count > 1 && PdfName.INDEXED.Equals(ar[0]))
                         ar[1] = iccArray;
                     else
                         i.Put(PdfName.COLORSPACE, iccArray);
                 }
                 else
                     i.Put(PdfName.COLORSPACE, iccArray);
             }
             Add(i, fixedRef);
             name = i.Name;
         }
         images[image.MySerialId] = name;
     }
     return name;
 }