Class Image
- Namespace
- iTextSharp.text
- Assembly
- iTextSharp.LGPLv2.Core.dll
An Image is the representation of a graphic element (JPEG, PNG or GIF) that has to be inserted into the document
public abstract class Image : Rectangle, IElement
- Inheritance
-
Image
- Implements
- Derived
- Inherited Members
Constructors
Image(Uri)
constructors
protected Image(Uri url)
Parameters
url
Urithe URL where the image can be found.
Image(Image)
Constructs an Image object duplicate.
protected Image(Image image)
Parameters
image
Imageanother Image object.
Fields
AX
static membervariables (concerning the presence of borders)
public const int AX = 0
Field Value
AY
This represents a coordinate in the transformation matrix.
public const int AY = 1
Field Value
BX
This represents a coordinate in the transformation matrix.
public const int BX = 2
Field Value
BY
This represents a coordinate in the transformation matrix.
public const int BY = 3
Field Value
CX
This represents a coordinate in the transformation matrix.
public const int CX = 4
Field Value
CY
This represents a coordinate in the transformation matrix.
public const int CY = 5
Field Value
DEFAULT
this is a kind of image Element.
public const int DEFAULT = 0
Field Value
DX
This represents a coordinate in the transformation matrix.
public const int DX = 6
Field Value
DY
This represents a coordinate in the transformation matrix.
public const int DY = 7
Field Value
Invert
Image color inversion
protected bool Invert
Field Value
LEFT_ALIGN
this is a kind of image Element.
public const int LEFT_ALIGN = 0
Field Value
MIDDLE_ALIGN
this is a kind of image Element.
public const int MIDDLE_ALIGN = 1
Field Value
Mask
protected bool Mask
Field Value
ORIGINAL_BMP
type of image
public const int ORIGINAL_BMP = 4
Field Value
ORIGINAL_GIF
type of image
public const int ORIGINAL_GIF = 3
Field Value
ORIGINAL_JBIG2
type of image @since 2.1.5
public const int ORIGINAL_JBIG2 = 9
Field Value
ORIGINAL_JPEG
type of image
public const int ORIGINAL_JPEG = 1
Field Value
ORIGINAL_JPEG2000
type of image
public const int ORIGINAL_JPEG2000 = 8
Field Value
ORIGINAL_NONE
type of image
public const int ORIGINAL_NONE = 0
Field Value
ORIGINAL_PNG
type of image
public const int ORIGINAL_PNG = 2
Field Value
ORIGINAL_TIFF
type of image
public const int ORIGINAL_TIFF = 5
Field Value
ORIGINAL_WMF
type of image
public const int ORIGINAL_WMF = 6
Field Value
Profile
ICC Profile attached
protected IccProfile Profile
Field Value
RIGHT_ALIGN
this is a kind of image Element.
public const int RIGHT_ALIGN = 2
Field Value
RotationRadians
This is the rotation of the image.
protected float RotationRadians
Field Value
TEXTWRAP
this is a kind of image Element.
public const int TEXTWRAP = 4
Field Value
Template
The template to be treated as an image.
protected PdfTemplate[] Template
Field Value
UNDERLYING
this is a kind of image Element.
public const int UNDERLYING = 8
Field Value
absoluteX
This is the absolute X-position of the image.
protected float absoluteX
Field Value
absoluteY
This is the absolute Y-position of the image.
protected float absoluteY
Field Value
alignment
The alignment of the Image.
protected int alignment
Field Value
alt
Text that can be shown instead of the image.
protected string alt
Field Value
annotation
if the annotation is not null the image will be clickable.
protected Annotation annotation
Field Value
bpc
this is the bits per component of the raw image. It also flags a CCITT image.
protected int bpc
Field Value
colorspace
this is the colorspace of a jpeg-image.
protected int colorspace
Field Value
compressionLevel
The compression level of the content streams. @since 2.1.3
protected int compressionLevel
Field Value
deflated
Holds value of property deflated.
protected bool deflated
Field Value
dpiX
Holds value of property dpiX.
protected int dpiX
Field Value
dpiY
Holds value of property dpiY.
protected int dpiY
Field Value
imageMask
protected Image imageMask
Field Value
indentationLeft
for the moment these variables are only used for Images in class Table
protected float indentationLeft
Field Value
indentationRight
the indentation to the right.
protected float indentationRight
Field Value
interpolation
Holds value of property interpolation.
protected bool interpolation
Field Value
layer
protected IPdfOcg layer
Field Value
mySerialId
protected long mySerialId
Field Value
originalData
Holds value of property originalData.
protected byte[] originalData
Field Value
- byte[]
originalType
Holds value of property originalType.
protected int originalType
Field Value
plainHeight
This is the width of the image without rotation.
protected float plainHeight
Field Value
plainWidth
This is the width of the image without rotation.
protected float plainWidth
Field Value
rawData
The raw data of the image.
protected byte[] rawData
Field Value
- byte[]
scaledHeight
This is the original height of the image taking rotation into account.
protected float scaledHeight
Field Value
scaledWidth
This is the scaled width of the image taking rotation into account.
protected float scaledWidth
Field Value
spacingAfter
The spacing after the image.
protected float spacingAfter
Field Value
spacingBefore
The spacing before the image.
protected float spacingBefore
Field Value
transparency
this is the transparency information of the raw image
protected int[] transparency
Field Value
- int[]
type
The imagetype.
protected int type
Field Value
url
The URL of the image.
protected Uri url
Field Value
- Uri
Properties
AbsoluteX
Returns the absolute X position.
public float AbsoluteX { get; }
Property Value
- float
a position
AbsoluteY
Returns the absolute Y position.
public float AbsoluteY { get; }
Property Value
- float
a position
Additional
public PdfDictionary Additional { get; set; }
Property Value
Alignment
Get/set the alignment for the image.
public int Alignment { get; set; }
Property Value
- int
a value
Alt
Get/set the alternative text for the image.
public string Alt { get; set; }
Property Value
- string
a string
Annotation
Get/set the annotation.
public Annotation Annotation { get; set; }
Property Value
- Annotation
the Annotation
Bpc
Gets the bpc for the image.
public int Bpc { get; }
Property Value
- int
a bpc value
Remarks
this only makes sense for Images of the type RawImage.
Colorspace
Gets the colorspace for the image.
public int Colorspace { get; }
Property Value
- int
a colorspace value
Remarks
this only makes sense for Images of the type Jpeg.
CompressionLevel
Sets the compression level to be used if the image is written as a compressed stream. @since 2.1.3
public int CompressionLevel { get; set; }
Property Value
Deflated
public bool Deflated { get; set; }
Property Value
DirectReference
public PdfIndirectReference DirectReference { get; set; }
Property Value
DpiX
Gets the dots-per-inch in the X direction. Returns 0 if not available.
public int DpiX { get; }
Property Value
- int
the dots-per-inch in the X direction
DpiY
Gets the dots-per-inch in the Y direction. Returns 0 if not available.
public int DpiY { get; }
Property Value
- int
the dots-per-inch in the Y direction
ImageMask
Get/set the explicit masking.
public Image ImageMask { get; set; }
Property Value
- Image
the explicit masking
IndentationLeft
public float IndentationLeft { get; set; }
Property Value
IndentationRight
public float IndentationRight { get; set; }
Property Value
InitialRotation
Some image formats, like TIFF may present the images rotated that have to be compensated.
public float InitialRotation { get; set; }
Property Value
Interpolation
Sets the image interpolation. Image interpolation attempts to produce a smooth transition between adjacent sample values.
public bool Interpolation { get; set; }
Property Value
- bool
New value of property interpolation.
Inverted
Inverts the meaning of the bits of a mask.
public bool Inverted { get; set; }
Property Value
- bool
true to invert the meaning of the bits of a mask
Layer
public IPdfOcg Layer { get; set; }
Property Value
Matrix
Returns the transformation matrix of the image.
public float[] Matrix { get; }
Property Value
- float[]
an array [AX, AY, BX, BY, CX, CY, DX, DY]
MySerialId
returns serial id for this object
public long MySerialId { get; }
Property Value
OriginalData
public byte[] OriginalData { get; set; }
Property Value
- byte[]
OriginalType
public int OriginalType { get; set; }
Property Value
PlainHeight
Gets the plain height of the image.
public float PlainHeight { get; }
Property Value
- float
a value
PlainWidth
Gets the plain width of the image.
public float PlainWidth { get; }
Property Value
- float
a value
RawData
methods to retrieve information
public byte[] RawData { get; }
Property Value
- byte[]
the raw data
Remarks
this only makes sense for Images of the type RawImage.
Rotation
Sets the rotation of the image in radians.
public float Rotation { set; }
Property Value
RotationDegrees
Sets the rotation of the image in degrees.
public float RotationDegrees { set; }
Property Value
ScaledHeight
Gets the scaled height of the image.
public float ScaledHeight { get; }
Property Value
- float
a value
ScaledWidth
Gets the scaled width of the image.
public float ScaledWidth { get; }
Property Value
- float
a value
Smask
Holds value of property smask.
public bool Smask { get; set; }
Property Value
SpacingAfter
public float SpacingAfter { get; set; }
Property Value
SpacingBefore
public float SpacingBefore { get; set; }
Property Value
TagIcc
Tags this image with an ICC profile.
public IccProfile TagIcc { get; set; }
Property Value
TemplateData
Get/set the template to be used as an image.
public PdfTemplate TemplateData { get; set; }
Property Value
- PdfTemplate
the template
Remarks
this only makes sense for Images of the type ImgTemplate.
Transparency
Returns the transparency.
public int[] Transparency { get; set; }
Property Value
- int[]
the transparency
Type
Returns the type.
public override int Type { get; }
Property Value
- int
a type
Url
Gets the string-representation of the reference to the image.
public Uri Url { get; set; }
Property Value
- Uri
a string
WidthPercentage
Holds value of property widthPercentage.
public float WidthPercentage { get; set; }
Property Value
XyRatio
Holds value of property XYRatio.
public float XyRatio { get; set; }
Property Value
Methods
GetImageRotation()
methods to set information
public float GetImageRotation()
Returns
- float
the current image rotation in radians
GetInstance(SKBitmap, SKEncodedImageFormat, int)
Converts a .NET image to a Native(PNG, JPG, GIF, WMF) image
public static Image GetInstance(SKBitmap image, SKEncodedImageFormat format, int quality = 100)
Parameters
image
SKBitmapformat
SKEncodedImageFormatquality
int
Returns
GetInstance(SKBitmap, BaseColor)
Gets an instance of an Image from a System.Drawing.Image.
public static Image GetInstance(SKBitmap image, BaseColor color)
Parameters
image
SKBitmapthe System.Drawing.Image to convert
color
BaseColorif different from null the transparency pixels are replaced by this color
Returns
- Image
an object of type ImgRaw
GetInstance(SKBitmap, BaseColor, bool)
Gets an instance of an Image from a SkiaSharp.SKBitmap.
public static Image GetInstance(SKBitmap image, BaseColor color, bool forceBw)
Parameters
image
SKBitmapthe System.Drawing.Image to convert
color
BaseColorif different from null the transparency pixels are replaced by this color
forceBw
boolif true the image is treated as black and white
Returns
- Image
an object of type ImgRaw
GetInstance(byte[])
Gets an instance of an Image.
public static Image GetInstance(byte[] imgb)
Parameters
imgb
byte[]a byte array
Returns
- Image
an object of type Gif, Jpeg or Png
GetInstance(Stream)
public static Image GetInstance(Stream s)
Parameters
s
Stream
Returns
GetInstance(int, int, bool, int, int, byte[])
Gets an instance of an Image in raw mode.
public static Image GetInstance(int width, int height, bool reverseBits, int typeCcitt, int parameters, byte[] data)
Parameters
width
intthe width of the image in pixels
height
intthe height of the image in pixels
reverseBits
booltypeCcitt
intparameters
intdata
byte[]
Returns
GetInstance(int, int, bool, int, int, byte[], int[])
public static Image GetInstance(int width, int height, bool reverseBits, int typeCcitt, int parameters, byte[] data, int[] transparency)
Parameters
Returns
GetInstance(int, int, byte[], byte[])
Creates a JBIG2 Image. @since 2.1.5
public static Image GetInstance(int width, int height, byte[] data, byte[] globals)
Parameters
width
intthe width of the image
height
intthe height of the image
data
byte[]the raw image data
globals
byte[]JBIG2 globals
Returns
GetInstance(int, int, int, int, byte[])
Gets an instance of an Image in raw mode.
public static Image GetInstance(int width, int height, int components, int bpc, byte[] data)
Parameters
width
intthe width of the image in pixels
height
intthe height of the image in pixels
components
int1,3 or 4 for GrayScale, RGB and CMYK
bpc
intbits per component
data
byte[]the image data
Returns
- Image
an object of type ImgRaw
GetInstance(int, int, int, int, byte[], int[])
Gets an instance of an Image in raw mode.
public static Image GetInstance(int width, int height, int components, int bpc, byte[] data, int[] transparency)
Parameters
width
intthe width of the image in pixels
height
intthe height of the image in pixels
components
int1,3 or 4 for GrayScale, RGB and CMYK
bpc
intbits per component
data
byte[]the image data
transparency
int[]transparency information in the Mask format of the image dictionary
Returns
- Image
an object of type ImgRaw
GetInstance(string)
Gets an instance of an Image.
public static Image GetInstance(string filename)
Parameters
filename
stringa filename
Returns
- Image
an object of type Gif, Jpeg or Png
GetInstance(Uri)
Gets an instance of an Image.
public static Image GetInstance(Uri url)
Parameters
url
Urian URL
Returns
- Image
an object of type Gif, Jpeg or Png
GetInstance(Image)
Gets an instance of an Image.
public static Image GetInstance(Image image)
Parameters
image
Imagean Image
Returns
- Image
an object of type Gif, Jpeg or Png
GetInstance(PdfTemplate)
Gets an instance of an Image in raw mode.
public static Image GetInstance(PdfTemplate template)
Parameters
template
PdfTemplate
Returns
GetInstance(PrIndirectReference)
Reuses an existing image. @throws BadElementException on error
public static Image GetInstance(PrIndirectReference iref)
Parameters
iref
PrIndirectReferencethe reference to the image dictionary
Returns
- Image
the image
GetSerialId()
generates new serial id
protected static long GetSerialId()
Returns
HasAbsolutePosition()
Checks if the Images has to be added at an absolute position.
public bool HasAbsolutePosition()
Returns
- bool
a bool
HasAbsoluteX()
Checks if the Images has to be added at an absolute X position.
public bool HasAbsoluteX()
Returns
- bool
a bool
HasIccProfile()
Checks is the image has an ICC profile.
public bool HasIccProfile()
Returns
- bool
the ICC profile or null
IsImgRaw()
Returns true if the image is a ImgRaw-object.
public bool IsImgRaw()
Returns
- bool
a bool
IsImgTemplate()
Returns true if the image is an ImgTemplate-object.
public bool IsImgTemplate()
Returns
- bool
a bool
IsJpeg()
Returns true if the image is a Jpeg-object.
public bool IsJpeg()
Returns
- bool
a bool
IsMask()
Returns true if this Image is a mask.
public bool IsMask()
Returns
- bool
true if this Image is a mask
IsMaskCandidate()
Returns true if this Image has the requisites to be a mask.
public bool IsMaskCandidate()
Returns
- bool
true if this Image can be a mask
IsNestable()
@see com.lowagie.text.Element#isNestable() @since iText 2.0.8
public override bool IsNestable()
Returns
MakeMask()
Make this Image a mask.
public void MakeMask()
ScaleAbsolute(float, float)
Scale the image to an absolute width and an absolute height.
public void ScaleAbsolute(float newWidth, float newHeight)
Parameters
ScaleAbsoluteHeight(float)
Scale the image to an absolute height.
public void ScaleAbsoluteHeight(float newHeight)
Parameters
newHeight
floatthe new height
ScaleAbsoluteWidth(float)
Scale the image to an absolute width.
public void ScaleAbsoluteWidth(float newWidth)
Parameters
newWidth
floatthe new width
ScalePercent(float)
Scale the image to a certain percentage.
public void ScalePercent(float percent)
Parameters
percent
floatthe scaling percentage
ScalePercent(float, float)
Scale the width and height of an image to a certain percentage.
public void ScalePercent(float percentX, float percentY)
Parameters
percentX
floatthe scaling percentage of the width
percentY
floatthe scaling percentage of the height
ScaleToFit(float, float)
Scales the image so that it fits a certain width and height.
public void ScaleToFit(float fitWidth, float fitHeight)
Parameters
SetAbsolutePosition(float, float)
Sets the absolute position of the Image.
public void SetAbsolutePosition(float absoluteX, float absoluteY)
Parameters
SetDpi(int, int)
Sets the dots per inch value dpi for x coordinates dpi for y coordinates
public void SetDpi(int dpiX, int dpiY)
Parameters
SimplifyColorspace()
Replaces CalRGB and CalGray colorspaces with DeviceRGB and DeviceGray.
public void SimplifyColorspace()