views:

1528

answers:

4

I want to crop a pic in c#. As in most photo editing softwares i want to use the rectangle box which can be resize and move with mouse(as in most image editing softwares).

plz also tell that how it is possible that the pic inside the rectangle is bright while outside is darker. following pic give the some idea........

http://img3.imageshack.us/img3/2286/cropcvi.jpg

I also need a way which is fast and best.plz help me to give any idea.

Thanks in advance.

A: 

The outside of the selection box seems to have a black image laid over it with a alpha of about 30%. To do this you would just take each pixel outside of the content area and draw a black pixel with a 30% alpha on top of it. This would give the desired dimmed out effect.

As for how you can get a rectangle to be dynamically seizable in C#.

Nick Berardi
Thanks Nick Beradi for help. the problem is that if i do work on one pixel one by one, its take very time . is there any fast way like color matrix?
qulzam
A: 

(My answer assumes a web application using ASP.NET):

You probably needs some javascript library to get the dimensions of the pic to crop. This jQuery plugin will do the trick:

http://www.webresourcesdepot.com/jquery-image-crop-plugin-jcrop/

Then here's an article on Stack Overflow that shows how to crop the image:

http://stackoverflow.com/questions/734930/how-to-crop-an-image-using-c

Keltex
Thanks to give answer. sir my application is not web based. it is simple desk top application. so i cant use the javascript.
qulzam
A: 

In order to draw a picture lighter or darker (or alter the colors in any way) you use a ColorMatrix, like this.

danbystrom
i know the use of color matrix but i know only use the colormatrix on all the image. how can we use it on the part of the image?
qulzam
Draw it as five seprate rectangles (five calls to .DrawImage). You can divide the picture in four rectangles that covers all that is outside your selection and one rectangle that is the selection in itself.
danbystrom
A: 

Check this out:

http://www.codeproject.com/KB/WPF/CropAdorner.aspx

Gilad