.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

Outlook : "operation failed, object could not be found. " when trying to close a PST.

How to transfer app and data from old iPhone to new iPhone for model IOS17 and IOS18 above.

Tips on how to use IBM iNotes (web client) on emailing or scheduling - Like copy tables from Excel or checking for user id (windows logon id) through email address