I. A brief description of the System.Drawing namespace
The System.Drawing namespace provides the basic functionality to access GDI +, more advanced features in the system.drawing.drawing2d,system.drawing.imaging and System.Drawing.Text namespaces
Assembly: System.Drawing.dll
Ii. Brief introduction of System.Drawing.Image
Image class: An abstract base class that provides functionality for classes originating from Bitmap and Metafile
Namespaces: System.Drawing
Assembly: System.Drawing.dll
Prototype definition:
[Serializabaleattribute][comvisibleattribute (true)][typeconverterattribute ( typeof(ImageConverter))]publicabstractclass Image:marshalbyrefobject, ISerializable, ICloneable, IDisposable
Common Instance Properties:
Height gets the altitude (in pixels) of the current image instance
Width gets the widths (in pixels) of the current image instance
HorizontalResolution get the horizontal resolution (pixels/inch) of the current image instance
VerticalResolution get the vertical resolution (pixels/inch) of the current image instance
Physicaldimension Gets the width and height of the current image.
Rawformat getting the current image format
PixelFormat gets the pixel format of the current image
Code:
1 usingSystem;2 usingSystem.Drawing;3 4 classApp5 {6 Static voidMain ()7 {8 varimg = Image.FromFile (@"image format. jpg");//image format. png to name extension9 Console.WriteLine (img. Height);Ten Console.WriteLine (img. Width); One Console.WriteLine (img. HorizontalResolution); A Console.WriteLine (img. verticalresolution); - Console.WriteLine (img. physicaldimension); - Console.WriteLine (img. Physicaldimension.width); the Console.WriteLine (img. Physicaldimension.height); - Console.WriteLine (img. Rawformat); -Console.WriteLine (IMG. Rawformat.equals (System.Drawing.Imaging.ImageFormat.Png));//whether it is in Png format -Console.WriteLine (IMG. Rawformat.equals (System.Drawing.Imaging.ImageFormat.Jpeg));//whether it is a JPG format, not an extension myoji jpg is not equal to the image format is Jpeg + Console.WriteLine (img. PixelFormat); - } +}
View Code
Effect
Download the code attached to this section
Common static methods:
public static image FromFile (string filename) creates an image from the specified file
public static image FromStream (Stream stream) creates an image from the specified data stream
Common example methods:
Public Image getthumbnailimage (int thumbwidth,int Thumbheight,system.drawing.image.getthumbnailimageabort callback, INTPTR callbackdata) Returns the thumbnail of this image
RotateFlip rotation
public void Save (string filename) saves the Image to the specified file or stream
Code:
usingSystem;usingSystem.Drawing;classapp{Static voidMain () {using(varimg = Image.FromFile (@"image format. jpg")) { //generate thumbnail images varThumbimg = img. Getthumbnailimage ( the, -, () =>{return false;},intptr.zero); Thumbimg.save (@"image Format _thumb.jpg"); //Image Rollover varNewimg = img. Clone () asImage; Newimg.rotateflip (ROTATEFLIPTYPE.ROTATE180FLIPX); Newimg.save (@"image Format _x axis flip 180 degrees. jpg"); } }}
Download the code attached to this section
Probe into the source--system.drawing of class library