Class DxfRasterImageDef
- Namespace
- GeometryHelper.Dxf
- Assembly
- GeometryHelper.dll
An IMAGEDEF of a DXF file, as AutoCAD's RasterImageDef: the picture file the IMAGEs of a drawing show, under its
name in the dictionary of images (GetImageDictionary(DxfDatabase)), with the size in pixels and the size of a pixel
AutoCAD read from the file when it loaded it.
public sealed class DxfRasterImageDef : DxfDBObject
- Inheritance
-
DxfRasterImageDef
- Inherited Members
Remarks
The library reads no picture: what AutoCAD learns by loading the file (its colours, its kind, whether it is found) it has not, and the path is kept as the file writes it. A PNG of 4 by 3 pixels at 96 dots an inch, loaded by AutoCAD 2021, is an IMAGEDEF of the size (4, 3) and pixels of 0.2646 mm, its resolution in centimetres.
Made in code, a definition is given its path and its size in pixels, which AutoCAD reads from the file and the library
cannot, and added to a drawing's dictionary of images under a name:
DxfDBDictionary images = DxfRasterImageDef.CreateImageDictionary(db); images.SetAt(DxfRasterImageDef.SuggestName(images, path), new DxfRasterImageDef(path, new GeoVector2(4, 3)));
An image is then made of it by DxfRasterImage(DxfRasterImageDef).
Constructors
- DxfRasterImageDef(string, GeoVector2)
Initializes a definition made in code of a picture file, as AutoCAD's
new RasterImageDef()given itsSourceFileNameand loaded: the path as it is to be written, and the size in pixels the caller gives, which AutoCAD reads from the file when it loads it and the library does not; a pixel (1, 1) in no unit, and loaded (280 of 1), as ezdxf writes a new one, so that AutoCAD loads the picture when it opens the drawing. Added to a drawing by SetAt(string, DxfDBObject) of its dictionary of images (CreateImageDictionary(DxfDatabase)).
Properties
- IsLoaded
Gets whether AutoCAD had the picture loaded when it saved the drawing (group 280), as AutoCAD's
IsLoadedwas then; true where the record gives none, and for a definition made in code.
- ResolutionMMPerPixel
Gets or sets the size of one pixel in millimetres (groups 11, 21), as AutoCAD's
ResolutionMMPerPixel: (0.2646, 0.2646) for a picture of 96 dots an inch; (1, 1) where the record gives none, as ezdxf and ACadSharp read none, and for a definition made in code.
- ResolutionUnits
Gets or sets the unit the picture's resolution is given in (group 281), as AutoCAD's
ResolutionUnits: centimetres (2) or inches (5) for a picture that says its resolution, none (0) for one that does not.
- Size
Gets the size of the picture in pixels (groups 10, 20), as AutoCAD's
Size: (4, 3) for a picture of 4 by 3; (0, 0) where the record gives none.
- SourceFileName
Gets or sets the path of the picture file (group 1), as AutoCAD's
SourceFileName: as the file writes it, a path of the machine it was drawn on or one relative to the drawing, such asC:\pictures\px43.png.
Methods
- CreateImageDictionary(DxfDatabase)
Gets the dictionary of the images of a drawing, made where it has none, as AutoCAD's
CreateImageDictionarymakes it: ACAD_IMAGE_DICT of the named object dictionary, owned by it, of entries kept (281 of 1). The one the drawing has where it has one, where AutoCAD 2021 makes a new one in its place and erases the old with its definitions.
- Erase()
Erases the definition, as AutoCAD 2021's
Eraseof aRasterImageDef: its entry of the dictionary of images taken out, and with it every image of the drawing that shows it, as AutoCAD takes those associated with it. AutoCAD leaves an image of no reactor pointing at the definition erased, which the library does not: a copy is erased with the rest.
- GetEntityCount(out bool)
Gets how many images of the drawing are associated with the definition, as AutoCAD 2021's
GetEntityCountcounts them: those whose IMAGEDEF_REACTOR the definition lists, an image made in code and appended, or associated by AssociateRasterDef(DxfRasterImageDef); a copy, which AutoCAD'sCloneappended leaves with no reactor, is not counted, as AutoCAD counts it not. Two images in a block placed by two INSERTs count once each.
- GetImageDictionary(DxfDatabase)
Gets the dictionary of the images of a drawing, as AutoCAD's
GetImageDictionarygives its id: ACAD_IMAGE_DICT of the named object dictionary, each DxfRasterImageDef under its name; null where the drawing has none.
- SuggestName(DxfDBDictionary, string)
Gets a name for a definition of a picture in a dictionary of images, as AutoCAD 2021's
SuggestNamegives it: the file's name without its folder or extension,px43forC:\pictures\px43.pngandPhoto 1forpictures\Photo 1.JPG; and where the dictionary has that name, letters of either case the same, the name and_1, or_2and on, the first it has not.
- ToString()
Gives the definition as a line for debugging: its type, its handle and its path.