Class vdImageDef
- Namespace
- VectorDraw.Professional.vdPrimaries
- Assembly
- VectorDraw.Professional.dll
Represents an image definition used by the drawing model.
A vdImageDef encapsulates either a reference to an external image file (via FileName) or an embedded image stored in the Bytes property. It provides functionality to load and bind images into an VectorDraw.Render.ImageBind instance, apply image transforms and effects.
public sealed class vdImageDef : vdPrimary, IVDSerialise, IBaseObject, IDisposable
- Inheritance
-
vdImageDef
- Implements
- Inherited Members
Examples
// Create and embed an image definition and attach it to new vdImage drawing figure: var idef = document.Images.Add("Logo", @"C:\Images\logo.png"); idef.EmbedImage(); // embed the image bytes into the drawing file so no need to keep the external file. // Set the white pixels of the image as transparent: idef.Transparency = Color.White; vdImage img = new vdImage(document, idef, new gPoint(0, 0, 0), 10.0, 0.0); img.Display = VdConstImg.VdImageShowAllTransparent;//in order transparency to be applied we need to set the display property to one of the transparency modes, in this case we want to show all the image with transparency so we set it to VdImageShowAllTransparent document.Model.Entities.AddItem(img); document.Redraw(false);
Remarks
Responsibilities:
- Store image source information (file path or embedded bytes).
- Lazily bind and expose the runtime VectorDraw.Render.ImageBind via the Image property.
- Support embedding images into the drawing file using EmbedImage() and InternalSetBytes(ByteArray).
- Support image operations such as rotation/flip (ApplyRotationFlip(vdRotateFlipTypeEnum)) and pixel-level effects (ApplyEffects(bool, bool, bool, int, int, int, int, int, double, double, double) , Transparency).
Typical usage:
- Create or obtain a vdImageDef from a document's
Imagestable. - Set FileName to reference an external file or call EmbedImage() to embed bytes.
- Use Image to read runtime image information such as Width, Height .
- Call ApplyEffects(bool, bool, bool, int, int, int, int, int, double, double, double) or ApplyRotationFlip(vdRotateFlipTypeEnum) to modify the image; call InternalSetBytes(ByteArray) if storing modified bytes.
Constructors
- vdImageDef()
Initializes the vdImageDef object.
- vdImageDef(vdDocument)
Initializes the vdImageDef object and registers it to the passed Document.
- vdImageDef(vdDocument, string)
Initializes the vdImageDef object and registers it to the passed Document.
Properties
- ActiveFrame
Get/Set the number of page the vdImageDef will be used when draw.
- Bytes
Get an array of bytes that consist the image of the object.
- Deleted
Get/Set a property that marks the object as Deleted or not.
- FileName
Get/Set the filename of the vdImageDef's image.
- FrameCount
Get the number of pages the image has.
- Height
Get the height of the image in pixels.
- Image
Get the ImageBind image object of the object.
- InterpolationMode
specifies the algorithm that is used when images are scaled.
- IsEmbeded
Returns true is object contains a valid Image defined from a Byte array and not from a File name.
- IsPDFImage
Returns true if the image is a PDF file, otherwise returns false.
- Name
Get/Set the name of the object.
- NumColors
Get the number of colors the image has.
- PDFImageSize
return the size of the PDF page in case that the image is a PDF file and the PDF page size can be retrieved. The size is returned in units of inches. The X value of the vector is the width and the Y value is the height. In case that the image is not a PDF file or the PDF page size cannot be retrieved then null is returned.
- Transparency
Get/Set the color to be used as transparent for the image.
- VisibleOnForms
Get/Set a boolean value representing if the vdImageDef will be viewed in Vectordraw forms.
- Width
Get the width of the image in pixels.
Methods
- ApplyEffects(bool, bool, bool, int, int, int, int, int, double, double, double)
This method changes this vdImageDef's Bitmap by applying the passed effects controlled from the parameters. Note that after this call the Image will be Binded to the Document.
- ApplyRotationFlip(vdRotateFlipTypeEnum)
This method changes this vdImageDef's Bitmap by applying the passed RotateFlipType Rotation and Flip.Note that after this call the Image will be Binded to the Document.
- DeSerialize(DeSerializer, string, object)
This Function is called foreach field name of the vdImageDef object when opening in vdml format.
- Dispose()
Releases all resources used by this image of the definition.
- EmbedImage()
Reads the selected image bytes and fill the Bytes property.
- GetCompareHashCode()
Returns a 32-bit signed integer hash code for this object instance.
- GetHbitmap()
Creates a GDI bitmap object from this System.Drawing.Bitmap.
- GetPalette()
Returns the Palette of the selected Bitmap or null if the bitmap is not ColorIndexed.
- GetTableDependecies(vdTableDependeciesArgs)
Fills the passed vdTableDependeciesArgs args with all the table references of this object (vdLayer, vdBlock, vdDimstyle, vdLineType, vdTextstyle, vdImageDef, vdHatchPattern etc).
- ImageAsDataObject()
Create a DataObject that contain a copy of the Image.
- ImageAsDataObject(int)
Creates a DataObject that contain a copy of the Image in 24 bit per pixel format and reducing the size of original image in depend of passed maxImageMemBytes.
- InitializeProperties()
Resets the properties of the vdDimstyle object to the Default values.
- InternalGetBytes()
Returns an array of bytes containing the BITMAPFILEHEADER,BITMAPINFO and the image bytes.
- InternalSetBytes(ByteArray)
Sets the bytes for the image of the object.
- IsImageValid()
Checks if the object's Image reference is valid.
- MatchProperties(vdPrimary, vdDocument)
Matches all the common properties from an object and sets them to this object.
- OnOwnerChanged()
This method is called when the object's owner is changed.
- Save(string)
Saves this System.Drawing.Image to the specified file.
- SelectPalette(Color[], bool)
Select a new palette for the selected image.
- Serialize(Serializer)
This Function is called when saving the vdImageDef object to vdml format.
- SetImageFromDataObject(object)
Set Image from a DataObject.
- ToString()
Gets a System.String that represents the name of the vdImageDef Object.
- Update()
Updates the object after change of properties.