.NET GDI+ Simple Image Operations

(In C#)

System.Drawing.Graphics g;

bmpOriginal = new Bitmap("C:\\myImage.gif");

int nNewWidth = 2 *
bmpOriginal .Width; //suppose resize 200%
int nNewHeight = 2 *
bmpOriginal .Height;


System.Drawing.Bitmap bmpModified = new Bitmap(nNewWidth, nNewHeight);
g = Graphics.FromImage(
bmpModified );

RectangleF rectDest =new RectangleF(
0,
0,
nNewWidth,
nNewHeight);


RectangleF rectSource = new RectangleF(0, 0,
bmpOriginal.Width, bmpOriginal.Height);
g.DrawImage(
bmpOriginal ,
rectDest,
rectSource ,
GraphicsUnit.Pixel);



bmpModified .Save("C:\\myNewImage.gif", System.Drawing.Imaging.ImageFormat.Gif);

g.Dispose();
g = null;

Comments

Popular posts from this blog

Clearcase check in/uncheck out all the checked out files script

MSSQL GROUP_CONCAT

Duplicating a local copy of project from TFS and making web software client factory to work