Updated: September 2008
An abstract base class that provides functionality for the Bitmap and Metafile descended classes.
<SerializableAttribute> _ <ComVisibleAttribute(True)> _ <TypeConverterAttribute(GetType(ImageConverter))> _ Public MustInherit Class Image _ Inherits MarshalByRefObject _ Implements ISerializable, ICloneable, IDisposable
Dim instance As Image
[SerializableAttribute] [ComVisibleAttribute(true)] [TypeConverterAttribute(typeof(ImageConverter))] public abstract class Image : MarshalByRefObject, ISerializable, ICloneable, IDisposable
[SerializableAttribute] [ComVisibleAttribute(true)] [TypeConverterAttribute(typeof(ImageConverter))] public ref class Image abstract : public MarshalByRefObject, ISerializable, ICloneable, IDisposable
public abstract class Image extends MarshalByRefObject implements ISerializable, ICloneable, IDisposable
The following code example is designed for use with Windows Forms. It is a handler for the Paint event. A Graphics object is passed to the event and is used to draw the image on the form. The code performs the following actions:
Creates an image from a file named SampImag.jpg. This file must be located in the same folder as the application executable file.
Creates a point at which to draw the upper-left corner of the image.
Draws the unscaled image on the form.
Private Sub ImageExampleForm_Paint _ (ByVal sender As System.Object, _ ByVal e As System.Windows.Forms.PaintEventArgs) _ Handles MyBase.Paint ' Create image. Dim newImage As Image = Image.FromFile("SampImag.jpg") ' Create Point for upper-left corner of image. Dim ulCorner As New Point(100, 100) ' Draw image to screen. e.Graphics.DrawImage(newImage, ulCorner) End Sub
private void ImageExampleForm_Paint(object sender, PaintEventArgs e) { // Create image. Image newImage = Image.FromFile("SampImag.jpg"); // Create Point for upper-left corner of image. Point ulCorner = new Point(100, 100); // Draw image to screen. e.Graphics.DrawImage(newImage, ulCorner); }
private: void ImageExampleForm_Paint(System::Object^ sender, System::Windows::Forms::PaintEventArgs^ e) { // Create image. Image^ newImage = Image::FromFile( "SampImag.jpg" ); // Create Point for upper-left corner of image. Point ulCorner = Point(100,100); // Draw image to screen. e->Graphics->DrawImage( newImage, ulCorner ); }
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC
Date
History
Reason
September 2008
Updated code example.
Customer feedback.