Image Manipulation C# (PictureBox) [en-US]

Code gallery link (download): http://code.msdn.microsoft.com/Image-Manipulation-C-09020bc1

* Version 2.0 – Added Load Image Function

Introduction
I have been noticing that for some reason people are developing several projects with pictures in Visual Studio Projects, mainly Windows forms projects. Evern yesterday i helped a guy with an issue of zoom in and out an image within a picture box. For those that dont know this visual studio toolbox artifact, it represents a Windows picture box control for displaying an image.
After helping this guy i started to google for some related problems and found out many other people asking the same questions. In order to help these people and other that may work with Images in Visual Studio projects i developed this small Demo, to show you how simple operations can be done.


Description
This sample countains controls to mak several manipulations in Images within a picture box, such controls include:

Zoom in
Zoom out
Flip Horizontally
Flip Vertically
Resizing
Rotate Left
Rotate Right
Zoom in with a track bar
Make drawings in the image with a brush
Saving the manipulated picture
Moving picture box
Load images to picture box

These ar as i said, the basics controls to start playing with pictures in Visual Studio. Here is a print screen on this demo with the explanation of the controls:

This sample includes just one image and no control to change it dynamcally, hoevr you can change the image to one of your own in the picture box control.

Snippet of a zoom in

public void ZoomIn()
{
Multiplier = new Size(2,2);

Image MyImage = pictureBox1.Image;

Bitmap MyBitMap = new Bitmap(MyImage, Convert.ToInt32(MyImage.Width * Multiplier.Width),
Convert.ToInt32(MyImage.Height * Multiplier.Height));

Graphics Graphic = Graphics.FromImage(MyBitMap);

Graphic.InterpolationMode = InterpolationMode.High ;

pictureBox1.Image = MyBitMap;

}

About Me

Rui Pedro Machado @ 2012 | Portugal rpmachado.wordpress.com

Anúncios

2 comments

Deixe uma Resposta

Preencha os seus detalhes abaixo ou clique num ícone para iniciar sessão:

Logótipo da WordPress.com

Está a comentar usando a sua conta WordPress.com Terminar Sessão / Alterar )

Imagem do Twitter

Está a comentar usando a sua conta Twitter Terminar Sessão / Alterar )

Facebook photo

Está a comentar usando a sua conta Facebook Terminar Sessão / Alterar )

Google+ photo

Está a comentar usando a sua conta Google+ Terminar Sessão / Alterar )

Connecting to %s