Class vdImage
- Namespace
- VectorDraw.Professional.vdFigures
- Assembly
- VectorDraw.Professional.dll
Represents a raster image entity placed in the drawing as a rectangular figure.
public class vdImage : vdRect, IDisposable, IVDSerialise, IBaseObject, IvdHatchFigure
- Inheritance
-
vdImage
- Implements
- Inherited Members
Examples
// Example: create and add an image to a document
var idef = document.Images.Add("photo.jpg");
var img = new vdImage(document) {
ImageDefinition = idef,
Width = 10.0,
Height = 5.0,
InsertionPoint = new gPoint(0,0,0),
Rotation = 0.0
};
document.ActiveEntities.AddItem(img);
document.Redraw(false);
Creating an image from a specific page of a PDF file:
int pageindex = 0;//we attach the first page of the pdf file
//Note it is better to set a Name to an ImageDefinition that contains the page number of the pdf that we want to display, in order to avoid the conflict when other pages are going to be added
vdImageDef imagedef = Images.Add(System.IO.Path.GetFileNameWithoutExtension(pdffilename) + "_" + (i + pageindex).ToString(), pdffilename);
imagedef.Transparency = Color.White;//set the transparency to white which is usually used by a pdf file
imagedef.ActiveFrame = pageindex;//the active frame of the pdf that we will attach
//create a new image tha rreference the previous image definition
VectorDraw.Professional.vdFigures.vdImage img = new VectorDraw.Professional.vdFigures.vdImage();
img.SetUnRegisterDocument(this);
img.setDocumentDefaults();
img.ImageDefinition = imagedef;
img.Display |= VdConstImg.VdImageTransparent;//set the dispay to transparent in order to transparency the white pdf background
img.ImageScale = 1.0d;
//set the image size equal to the selected pdf size in inches
if (img.ImageDefinition.PDFImageSize != null) img.ImageScale = img.ImageDefinition.PDFImageSize.x * scale;
Remarks
The vdImage class binds to a vdImageDef which holds the underlying image data and metadata. An instance defines placement and appearance through properties inherited from vdRect (for example InsertionPoint, Rotation, Width, Height) and image-specific properties such as ImageDefinition, Display, KeepAspect, and ClipBoundary. The object supports pixel-to-ECS mapping via PixelToECSMatrix() and transforms to world coordinates with ECSMatrix. When the referenced image is a metafile (EMF/WMF), Explode() can convert the metafile to vector entities and return a vdInsert referencing a generated vdBlock.
Drawing behavior respects display flags (e.g. clipped drawing, transparency and border visibility) and rendering implementations may handle clipped image polygons differently depending on their capabilities. Many of the usual curve operations (for example non-image offsetting) are not applicable to this object.
Constructors
- vdImage()
Initializes a new instance of the vdImage object.
- vdImage(vdDocument)
Initializes a new instance of the vdImage object and registers it to the passed Document.
- vdImage(vdDocument, vdImageDef, gPoint, double, double)
Initializes a new instance of the vdImage object and registers it to the passed Document.
Properties
- BoundingBox
Gets the Bounding Box of the vdImage object in WorldCoordinate System.
- ClipBoundary
Get/Set a collection of points indicating a boundary to clip the image. It is relative to the Image definition Coordinate system in pixels. The points are in pixels relative to the upper left corner of the image. In case of a pdf image the points are relative to the upper left corner of the selected pdf page size which is defined by PDFImageSize in inches.
- Display
Get/Set the Display property of the vdImage object.
- ECSMatrix
Gets the transformation Matrix that converts coordinates from the object's local coordinate system (object coordinate system, OCS) to the World Coordinate System (WCS).
- HatchProperties
This property will not effect the vdImage object.
- Height
Get/Set the height of the vdImage object in Drawing units.
- ImageBinding
Get the ImageBind image object of the ImageDefinition property.
- ImageDefinition
Get/Set the vdImageDef object of the image indicating the Image Definition of the object.
- ImageScale
Get/Set the image scale.
- KeepAspect
Defines if the image will be drawn by keeping the ImageDefinition aspect .
- VerticalDeviation
Get/Set the vertical deviation angle in radians of the image
Represents the result of the horizontal angle in the Width direction minus the vertical angle in the Height direction minus 90 degrees
- Width
Get/Set the width of the vdImage object in Drawing units.
Methods
- DeSerialize(DeSerializer, string, object)
This Function is called foreach field name of the vdImage object when opening in vdml format.
- Draw(vdRender)
Called in order to draw the vdImage object in a specified vdRender object.
- DrawGrip(int, Box, vdRender)
Overriden function in order to draw the center move grip differently.
- Explode()
Explodes this image into one or more vector entities.
- GetCompareHash()
Returns a unique 32 bit integer value according to the object type and its properties values
- GetGripPoints()
A function returning the grip points of the object.
- GetOrientation(out gPoint, out Vector, out Vector)
Receives the object orientation properties that defines the transformation from raster image pixels to World Coordinate System
- GetTableDependecies(vdTableDependeciesArgs)
Fills the passed vdTableDependeciesArgs args with all the table references of this object (vdLayer, vdBlock, vdDimstyle, vdLineType, vdTextstyle, vdImageDef, vdHatchPattern etc).
- GetValidGripPointsItems()
Returns the number of valid grip points of the object. Must return the same number of points as the GetGripPoints() method.
- InitializeProperties()
Resets the properties of the vdImage object to the Default values.
- MatchProperties(vdPrimary, vdDocument)
Matches all the common properties from an object and sets them to this object.
- MoveGripPointsAt(Int32Array, double, double, double)
This function is intended to be called during a grip edit of the object.
- OnOwnerChanged()
This method is called when the object's owner is changed.
- PixelToECSMatrix()
Returns a Matrix that tranform a pixel point relative to selected Bitmap Rectangle into ECSMatrix of this object.
- Serialize(Serializer)
This Function is called when saving the vdImage object to vdml format.
- SetOrientation(gPoint, Vector, Vector)
Select the orientation that maps the selected image pixels to the world Coordinate System
- ToString()
Gets a System.String that represents the type and the name(if is not null) of the vdImage Object.
- Transformby(Matrix)
Transforms all geometrical properties of this object by the specified Matrix.
- Update()
Updates the object after change of properties.