/// <summary> /// Initializes a new instance of the <c>ImageDefinition</c> class. /// </summary> /// <param name="name">Image definition name.</param> /// <param name="file">Image file name with full or relative path.</param> /// <remarks> /// <para> /// The name assigned to the image definition must be unique. /// </para> /// <para> /// Supported image formats: BMP, JPG, PNG, TIFF.<br /> /// Even thought AutoCAD supports more image formats, this constructor is restricted to the ones the .net library supports in common with AutoCAD. /// Use the generic constructor instead. /// </para> /// <para> /// Note (this is from the ACAD docs): AutoCAD 2000, AutoCAD LT 2000, and later releases do not support LZW-compressed TIFF files, /// with the exception of English language versions sold in the US and Canada.<br /> /// If you have TIFF files that were created using LZW compression and want to insert them into a drawing /// you must save the TIFF files with LZW compression disabled. /// </para> /// </remarks> public ImageDefinition(string name, string file) : base(name, DxfObjectCode.ImageDef, false) { if (string.IsNullOrEmpty(file)) { throw new ArgumentNullException(nameof(file), "The image file name should be at least one character long."); } //FileInfo info = new FileInfo(file); //if (!info.Exists) // throw new FileNotFoundException("Image file not found", file); this.file = file; try { using (Image bitmap = Image.FromFile(file)) { this.width = bitmap.Width; this.height = bitmap.Height; this.horizontalResolution = bitmap.HorizontalResolution; this.verticalResolution = bitmap.VerticalResolution; // the System.Drawing.Image stores the image resolution in inches this.resolutionUnits = ImageResolutionUnits.Inches; } } catch (Exception) { throw new ArgumentException("Image file not supported.", file); } this.reactors = new Dictionary <string, ImageDefinitionReactor>(); }
/// <summary> /// Initializes a new instance of the <c>ImageDefinition</c> class. Only available for Net Framework 4.5 builds. /// </summary> /// <param name="name">Image definition name.</param> /// <param name="file">Image file name with full or relative path.</param> /// <remarks> /// <para> /// The name assigned to the image definition must be unique. /// </para> /// <para> /// Supported image formats: BMP, JPG, PNG, TIFF.<br /> /// Even thought AutoCAD supports more image formats, this constructor is restricted to the ones the .net library supports in common with AutoCAD. /// Use the generic constructor instead. /// </para> /// <para> /// Note (this is from the ACAD docs): AutoCAD 2000, AutoCAD LT 2000, and later releases do not support LZW-compressed TIFF files, /// with the exception of English language versions sold in the US and Canada.<br /> /// If you have TIFF files that were created using LZW compression and want to insert them into a drawing /// you must save the TIFF files with LZW compression disabled. /// </para> /// </remarks> public ImageDefinition(string name, string file) : base(name, DxfObjectCode.ImageDef, false) { if (string.IsNullOrEmpty(file)) { throw new ArgumentNullException(nameof(file)); } FileInfo info = new FileInfo(file); if (!info.Exists) { throw new FileNotFoundException("Image file not found.", file); } this.file = file; try { using (System.Drawing.Image bitmap = System.Drawing.Image.FromFile(file)) { this.width = bitmap.Width; this.height = bitmap.Height; this.horizontalResolution = bitmap.HorizontalResolution; this.verticalResolution = bitmap.VerticalResolution; // the System.Drawing.Image stores the image resolution in inches this.resolutionUnits = ImageResolutionUnits.Inches; } } catch (Exception) { throw new ArgumentException("Image file not supported.", file); } }
/// <summary> /// Initializes a new instance of the <c>ImageDefinition</c> class. /// </summary> /// <param name="fileName">Image file name with full or relative path.</param> /// <param name="name">Image definition name.</param> /// <param name="width">Image width in pixels.</param> /// <param name="horizontalResolution">Image horizontal resolution in pixels.</param> /// <param name="height">Image height in pixels.</param> /// <param name="verticalResolution">Image vertical resolution in pixels.</param> /// <param name="units">Image resolution units.</param> /// <remarks> /// <para> /// The name assigned to the image definition must be unique. /// </para> /// <para> /// This is a generic constructor for all image formats supported by AutoCAD, note that not all AutoCAD versions support the same image formats. /// </para> /// <para> /// Note (this is from the ACAD docs): AutoCAD 2000, AutoCAD LT 2000, and later releases do not support LZW-compressed TIFF files, /// with the exception of English language versions sold in the US and Canada.<br /> /// If you have TIFF files that were created using LZW compression and want to insert them into a drawing /// you must save the TIFF files with LZW compression disabled. /// </para> /// </remarks> public ImageDefinition(string fileName, string name, int width, double horizontalResolution, int height, double verticalResolution, ImageResolutionUnits units) : base(name, DxfObjectCode.ImageDef, false) { if (string.IsNullOrEmpty(fileName)) { throw new ArgumentNullException(nameof(fileName), "The image file name should be at least one character long."); } this.fileName = fileName; this.width = width; this.height = height; this.horizontalResolution = horizontalResolution; this.verticalResolution = verticalResolution; this.resolutionUnits = units; this.reactors = new Dictionary <string, ImageDefinitionReactor>(); }
/// <summary> /// Initializes a new instance of the <c>ImageDef</c> class. /// </summary> /// <param name="fileName">Image file name with full or relative path.</param> /// <param name="name">Image definition name, if null or empty the file name without the extension will be used.</param> /// <param name="width">Image width in pixels.</param> /// <param name="horizontalResolution">Image horizontal resolution in pixels.</param> /// <param name="height">Image height in pixels.</param> /// <param name="verticalResolution">Image vertical resolution in pixels.</param> /// <param name="units">Image resolution units.</param> /// <remarks> /// <para> /// The name assigned to the image definition must be unique. /// </para> /// <para> /// This is a generic constructor for all image formats supported by AutoCAD, note that not all AutoCAD versions support the same image formats. /// </para> /// <para> /// Note (this is from the ACAD docs): AutoCAD 2000, AutoCAD LT 2000, and later releases do not support LZW-compressed TIFF files, /// with the exception of English language versions sold in the US and Canada.<br /> /// If you have TIFF files that were created using LZW compression and want to insert them into a drawing /// you must resave the TIFF files with LZW compression disabled. /// </para> /// </remarks> public ImageDef(string fileName, string name, int width, float horizontalResolution, int height, float verticalResolution, ImageResolutionUnits units) : base(name, DxfObjectCode.ImageDef, true) { if (string.IsNullOrEmpty(fileName)) { throw new ArgumentNullException("fileName", "The image file name cannot be empty or null."); } this.fileName = fileName; this.width = width; this.height = height; this.horizontalResolution = horizontalResolution; this.verticalResolution = verticalResolution; this.resolutionUnits = units; this.reactors = new Dictionary <string, ImageDefReactor>(); }
/// <summary> /// Initializes a new instance of the <c>ImageDefinition</c> class. /// </summary> /// <param name="name">Image definition name.</param> /// <param name="file">Image file name with full or relative path.</param> /// <param name="width">Image width in pixels.</param> /// <param name="horizontalResolution">Image horizontal resolution in pixels.</param> /// <param name="height">Image height in pixels.</param> /// <param name="verticalResolution">Image vertical resolution in pixels.</param> /// <param name="units">Image resolution units.</param> /// <remarks> /// <para> /// The name assigned to the image definition must be unique. /// </para> /// <para> /// This is a generic constructor for all image formats supported by AutoCAD, note that not all AutoCAD versions support the same image formats. /// </para> /// <para> /// Note (this is from the ACAD docs): AutoCAD 2000, AutoCAD LT 2000, and later releases do not support LZW-compressed TIFF files, /// with the exception of English language versions sold in the US and Canada.<br /> /// If you have TIFF files that were created using LZW compression and want to insert them into a drawing /// you must save the TIFF files with LZW compression disabled. /// </para> /// </remarks> public ImageDefinition(string name, string file, int width, double horizontalResolution, int height, double verticalResolution, ImageResolutionUnits units) : base(name, DxfObjectCode.ImageDef, false) { if (string.IsNullOrEmpty(file)) { throw new ArgumentNullException(nameof(file)); } if (file.IndexOfAny(Path.GetInvalidPathChars()) == 0) { throw new ArgumentException("File path contains invalid characters.", nameof(file)); } this.file = file; if (width <= 0) { throw new ArgumentOutOfRangeException(nameof(width), width, "The ImageDefinition width must be greater than zero."); } this.width = width; if (height <= 0) { throw new ArgumentOutOfRangeException(nameof(height), height, "The ImageDefinition height must be greater than zero."); } this.height = height; if (horizontalResolution <= 0) { throw new ArgumentOutOfRangeException(nameof(horizontalResolution), horizontalResolution, "The ImageDefinition horizontal resolution must be greater than zero."); } this.horizontalResolution = horizontalResolution; if (verticalResolution <= 0) { throw new ArgumentOutOfRangeException(nameof(verticalResolution), verticalResolution, "The ImageDefinition vertical resolution must be greater than zero."); } this.verticalResolution = verticalResolution; this.resolutionUnits = units; this.reactors = new Dictionary <string, ImageDefinitionReactor>(); }
/// <summary> /// Initializes a new instance of the <c>ImageDefinition</c> class. /// </summary> /// <param name="name">Image definition name.</param> /// <param name="file">Image file name with full or relative path.</param> /// <param name="width">Image width in pixels.</param> /// <param name="horizontalResolution">Image horizontal resolution in pixels.</param> /// <param name="height">Image height in pixels.</param> /// <param name="verticalResolution">Image vertical resolution in pixels.</param> /// <param name="units">Image resolution units.</param> /// <remarks> /// <para> /// The name assigned to the image definition must be unique. /// </para> /// <para> /// This is a generic constructor for all image formats supported by AutoCAD, note that not all AutoCAD versions support the same image formats. /// </para> /// <para> /// Note (this is from the ACAD docs): AutoCAD 2000, AutoCAD LT 2000, and later releases do not support LZW-compressed TIFF files, /// with the exception of English language versions sold in the US and Canada.<br /> /// If you have TIFF files that were created using LZW compression and want to insert them into a drawing /// you must save the TIFF files with LZW compression disabled. /// </para> /// </remarks> public ImageDefinition(string name, string file, int width, double horizontalResolution, int height, double verticalResolution, ImageResolutionUnits units) : base(name, DxfObjectCode.ImageDef, false) { if (string.IsNullOrEmpty(file)) { throw new ArgumentNullException("file"); } this.file = file; if (width <= 0) { throw new ArgumentOutOfRangeException("width", width, "The ImageDefinition width must be greater than zero."); } this.width = width; if (height <= 0) { throw new ArgumentOutOfRangeException("height", height, "The ImageDefinition height must be greater than zero."); } this.height = height; if (horizontalResolution <= 0) { throw new ArgumentOutOfRangeException("horizontalResolution", horizontalResolution, "The ImageDefinition horizontal resolution must be greater than zero."); } this.horizontalResolution = horizontalResolution; if (verticalResolution <= 0) { throw new ArgumentOutOfRangeException("verticalResolution", verticalResolution, "The ImageDefinition vertical resolution must be greater than zero."); } this.verticalResolution = verticalResolution; this.resolutionUnits = units; this.reactors = new Dictionary <string, ImageDefinitionReactor>(); }
/// <summary> /// Initializes a new instance of the <c>ImageDef</c> class. /// </summary> /// <param name="fileName">Image file name with full or relative path.</param> /// <param name="name">Image definition name, if null or empty the file name without the extension will be used.</param> /// <remarks> /// <para> /// The name assigned to the image definition must be unique. /// </para> /// <para> /// Supported image formats: BMP, JPG, PNG, TIFF.<br /> /// Eventhought AutoCAD supports more image formats, this constructor is restricted to the ones the .net library supports in common with AutoCAD. /// Use the generic constructor instead. /// </para> /// <para> /// Note (this is from the ACAD docs): AutoCAD 2000, AutoCAD LT 2000, and later releases do not support LZW-compressed TIFF files, /// with the exception of English language versions sold in the US and Canada.<br /> /// If you have TIFF files that were created using LZW compression and want to insert them into a drawing /// you must resave the TIFF files with LZW compression disabled. /// </para> /// </remarks> public ImageDef(string fileName, string name) : base(name, DxfObjectCode.ImageDef, true) { if (string.IsNullOrEmpty(fileName)) { throw new ArgumentNullException("fileName", "The image file name cannot be empty or null."); } FileInfo info = new FileInfo(fileName); if (!info.Exists) { throw new FileNotFoundException("Image file not found", fileName); } this.fileName = fileName; try { using (Image bitmap = Image.FromFile(fileName)) { this.width = bitmap.Width; this.height = bitmap.Height; this.horizontalResolution = bitmap.HorizontalResolution; this.verticalResolution = bitmap.VerticalResolution; // the System.Drawing.Image stores the image resolution in inches this.resolutionUnits = ImageResolutionUnits.Inches; } } catch (Exception) { throw new ArgumentException("Image file not supported.", fileName); } this.reactors = new Dictionary <string, ImageDefReactor>(); }
/// <summary> /// Initializes a new instance of the <c>ImageDefinition</c> class. /// </summary> /// <param name="file">Image file name with full or relative path.</param> /// <param name="width">Image width in pixels.</param> /// <param name="horizontalResolution">Image horizontal resolution in pixels.</param> /// <param name="height">Image height in pixels.</param> /// <param name="verticalResolution">Image vertical resolution in pixels.</param> /// <param name="units">Image resolution units.</param> /// <remarks> /// <para> /// The name of the file without extension will be used as the name of the image definition. /// </para> /// <para> /// This is a generic constructor for all image formats supported by AutoCAD, note that not all AutoCAD versions support the same image formats. /// </para> /// <para> /// Note (this is from the ACAD docs): AutoCAD 2000, AutoCAD LT 2000, and later releases do not support LZW-compressed TIFF files, /// with the exception of English language versions sold in the US and Canada.<br /> /// If you have TIFF files that were created using LZW compression and want to insert them into a drawing /// you must save the TIFF files with LZW compression disabled. /// </para> /// </remarks> public ImageDefinition(string file, int width, double horizontalResolution, int height, double verticalResolution, ImageResolutionUnits units) : this(Path.GetFileNameWithoutExtension(file), file, width, horizontalResolution, height, verticalResolution, units) { }
/// <summary> /// Initializes a new instance of the <c>ImageDef</c> class. /// </summary> /// <param name="fileName">Image file name with full or relative path.</param> /// <param name="width">Image width in pixels.</param> /// <param name="horizontalResolution">Image horizontal resolution in pixels.</param> /// <param name="height">Image height in pixels.</param> /// <param name="verticalResolution">Image vertical resolution in pixels.</param> /// <param name="units">Image resolution units.</param> /// <remarks> /// <para> /// The name of the file without extension will be used as the name of the image definition. /// </para> /// <para> /// This is a generic constructor for all image formats supported by AutoCAD, note that not all AutoCAD versions support the same image formats. /// </para> /// <para> /// Note (this is from the ACAD docs): AutoCAD 2000, AutoCAD LT 2000, and later releases do not support LZW-compressed TIFF files, /// with the exception of English language versions sold in the US and Canada.<br /> /// If you have TIFF files that were created using LZW compression and want to insert them into a drawing /// you must save the TIFF files with LZW compression disabled. /// </para> /// </remarks> public ImageDef(string fileName, int width, double horizontalResolution, int height, double verticalResolution, ImageResolutionUnits units) : this(fileName, Path.GetFileNameWithoutExtension(fileName), width, horizontalResolution, height, verticalResolution, units) { }
/// <summary> /// Initializes a new instance of the <c>ImageDef</c> class. /// </summary> /// <param name="fileName">Image file name with full or relative path.</param> /// <param name="name">Image definition name, if null or empty the file name without the extension will be used.</param> /// <remarks> /// <para> /// The name assigned to the image definition must be unique. /// </para> /// <para> /// Supported image formats: BMP, JPG, PNG, TIFF.<br /> /// Even thought AutoCAD supports more image formats, this constructor is restricted to the ones the .net library supports in common with AutoCAD. /// Use the generic constructor instead. /// </para> /// <para> /// Note (this is from the ACAD docs): AutoCAD 2000, AutoCAD LT 2000, and later releases do not support LZW-compressed TIFF files, /// with the exception of English language versions sold in the US and Canada.<br /> /// If you have TIFF files that were created using LZW compression and want to insert them into a drawing /// you must save the TIFF files with LZW compression disabled. /// </para> /// </remarks> public ImageDef(string fileName, string name) : base(name, DxfObjectCode.ImageDef, true) { if (string.IsNullOrEmpty(fileName)) throw new ArgumentNullException("fileName", "The image file name cannot be null or empty."); FileInfo info = new FileInfo(fileName); if (!info.Exists) throw new FileNotFoundException("Image file not found", fileName); this.fileName = fileName; try { using (Image bitmap = Image.FromFile(fileName)) { this.width = bitmap.Width; this.height = bitmap.Height; this.horizontalResolution = bitmap.HorizontalResolution; this.verticalResolution = bitmap.VerticalResolution; // the System.Drawing.Image stores the image resolution in inches this.resolutionUnits = ImageResolutionUnits.Inches; } } catch (Exception) { throw new ArgumentException("Image file not supported.", fileName); } this.reactors = new Dictionary<string, ImageDefReactor>(); }
/// <summary> /// Initializes a new instance of the <c>ImageDef</c> class. /// </summary> /// <param name="fileName">Image file name with full or relative path.</param> /// <param name="name">Image definition name, if null or empty the file name without the extension will be used.</param> /// <param name="width">Image width in pixels.</param> /// <param name="horizontalResolution">Image horizontal resolution in pixels.</param> /// <param name="height">Image height in pixels.</param> /// <param name="verticalResolution">Image vertical resolution in pixels.</param> /// <param name="units">Image resolution units.</param> /// <remarks> /// <para> /// The name assigned to the image definition must be unique. /// </para> /// <para> /// This is a generic constructor for all image formats supported by AutoCAD, note that not all AutoCAD versions support the same image formats. /// </para> /// <para> /// Note (this is from the ACAD docs): AutoCAD 2000, AutoCAD LT 2000, and later releases do not support LZW-compressed TIFF files, /// with the exception of English language versions sold in the US and Canada.<br /> /// If you have TIFF files that were created using LZW compression and want to insert them into a drawing /// you must save the TIFF files with LZW compression disabled. /// </para> /// </remarks> public ImageDef(string fileName, string name, int width, double horizontalResolution, int height, double verticalResolution, ImageResolutionUnits units) : base(name, DxfObjectCode.ImageDef, true) { if (string.IsNullOrEmpty(fileName)) throw new ArgumentNullException("fileName", "The image file name cannot be null or empty."); this.fileName = fileName; this.width = width; this.height = height; this.horizontalResolution = horizontalResolution; this.verticalResolution = verticalResolution; this.resolutionUnits = units; this.reactors = new Dictionary<string, ImageDefReactor>(); }
/// <summary> /// Initializes a new instance of the <c>ImageDef</c> class. /// </summary> /// <param name="fileName">Image file name with full or relative path.</param> /// <param name="width">Image width in pixels.</param> /// <param name="horizontalResolution">Image horizontal resolution in pixels.</param> /// <param name="height">Image height in pixels.</param> /// <param name="verticalResolution">Image vetical resolution in pixels.</param> /// <param name="units">Image resolution units.</param> /// <remarks> /// <para> /// The name of the file without extension will be used as the name of the image definition. /// </para> /// <para> /// This is a generic constructor for all image formats supported by AutoCAD, note that not all AutoCAD versions support the same image formats. /// </para> /// <para> /// Note (this is from the ACAD docs): AutoCAD 2000, AutoCAD LT 2000, and later releases do not support LZW-compressed TIFF files, /// with the exception of English language versions sold in the US and Canada.<br /> /// If you have TIFF files that were created using LZW compression and want to insert them into a drawing /// you must resave the TIFF files with LZW compression disabled. /// </para> /// </remarks> public ImageDef(string fileName, int width, float horizontalResolution, int height, float verticalResolution, ImageResolutionUnits units) : this(fileName, Path.GetFileNameWithoutExtension(fileName), width, horizontalResolution, height, verticalResolution, units) { }
/// <summary> /// Initializes a new instance of the <c>ImageDefinition</c> class. /// </summary> /// <param name="fileName">Image file name with full or relative path.</param> /// <param name="name">Image definition name.</param> /// <param name="width">Image width in pixels.</param> /// <param name="horizontalResolution">Image horizontal resolution in pixels.</param> /// <param name="height">Image height in pixels.</param> /// <param name="verticalResolution">Image vertical resolution in pixels.</param> /// <param name="units">Image resolution units.</param> /// <remarks> /// <para> /// The name assigned to the image definition must be unique. /// </para> /// <para> /// This is a generic constructor for all image formats supported by AutoCAD, note that not all AutoCAD versions support the same image formats. /// </para> /// <para> /// Note (this is from the ACAD docs): AutoCAD 2000, AutoCAD LT 2000, and later releases do not support LZW-compressed TIFF files, /// with the exception of English language versions sold in the US and Canada.<br /> /// If you have TIFF files that were created using LZW compression and want to insert them into a drawing /// you must save the TIFF files with LZW compression disabled. /// </para> /// </remarks> public ImageDefinition(string fileName, string name, int width, double horizontalResolution, int height, double verticalResolution, ImageResolutionUnits units) : base(name, DxfObjectCode.ImageDef, false) { if (string.IsNullOrEmpty(fileName)) throw new ArgumentNullException(nameof(fileName), "The image file name should be at least one character long."); this.fileName = fileName; this.width = width; this.height = height; this.horizontalResolution = horizontalResolution; this.verticalResolution = verticalResolution; this.resolutionUnits = units; this.reactors = new Dictionary<string, ImageDefinitionReactor>(); }