public Translate ( float offsetX, float offsetY ) : void | ||
offsetX | float | |
offsetY | float | |
return | void |
Image myImage = Image.FromFile("myImage.jpg"); Graphics g = Graphics.FromImage(myImage); // create a Matrix object Matrix myMatrix = new Matrix(); // translate the image 50 pixels to the right and 20 pixels down myMatrix.Translate(50, 20); // apply the matrix transformation to the graphics object g.Transform = myMatrix; // draw the transformed image g.DrawImage(myImage, new Point(0, 0));
Image myImage = Image.FromFile("myImage.jpg"); Graphics g = Graphics.FromImage(myImage); // create a Matrix object Matrix myMatrix = new Matrix(); // flip the image vertically myMatrix.Scale(1, -1); // apply the matrix transformation to the graphics object g.Transform = myMatrix; // draw the transformed image g.DrawImage(myImage, new Point(0, myImage.Height));These examples demonstrate how to use the System.Drawing.Drawing2D Matrix Translate method to move an image or graphics object. The package library is System.Drawing.