コード例 #1
0
 public ImagePdfBytesInfo(PdfImageXObject imageXObject)
 {
     pngColorType = -1;
     bpc          = imageXObject.GetPdfObject().GetAsNumber(PdfName.BitsPerComponent).IntValue();
     pngBitDepth  = bpc;
     palette      = null;
     icc          = null;
     stride       = 0;
     width        = (int)imageXObject.GetWidth();
     height       = (int)imageXObject.GetHeight();
     colorspace   = imageXObject.GetPdfObject().Get(PdfName.ColorSpace);
     decode       = imageXObject.GetPdfObject().GetAsArray(PdfName.Decode);
     FindColorspace(colorspace, true);
 }
コード例 #2
0
 /// <summary>
 /// Calculates a rectangle with the specified coordinates and height, and the width is
 /// calculated in such a way that the original proportions of the xObject do not change.
 /// </summary>
 /// <remarks>
 /// Calculates a rectangle with the specified coordinates and height, and the width is
 /// calculated in such a way that the original proportions of the xObject do not change.
 /// <para />
 /// To calculate the original width and height of the xObject, the BBox and Matrix fields
 /// are used. For mor information see paragraph 8.10.1 in ISO-32000-1.
 /// </remarks>
 /// <param name="xObject">the xObject for which we are calculating the rectangle</param>
 /// <param name="x">the x-coordinate of the lower-left corner of the rectangle</param>
 /// <param name="y">the y-coordinate of the lower-left corner of the rectangle</param>
 /// <param name="height">the height of the rectangle</param>
 /// <returns>the rectangle with specified coordinates and height</returns>
 public static Rectangle CalculateProportionallyFitRectangleWithHeight(iText.Kernel.Pdf.Xobject.PdfXObject
                                                                       xObject, float x, float y, float height)
 {
     if (xObject is PdfFormXObject)
     {
         PdfFormXObject formXObject = (PdfFormXObject)xObject;
         Rectangle      bBox        = PdfFormXObject.CalculateBBoxMultipliedByMatrix(formXObject);
         return(new Rectangle(x, y, (height / bBox.GetHeight()) * bBox.GetWidth(), height));
     }
     else
     {
         if (xObject is PdfImageXObject)
         {
             PdfImageXObject imageXObject = (PdfImageXObject)xObject;
             return(new Rectangle(x, y, (height / imageXObject.GetHeight()) * imageXObject.GetWidth(), height));
         }
         else
         {
             throw new ArgumentException("PdfFormXObject or PdfImageXObject expected.");
         }
     }
 }