Welcome to LEAD Support Forum Login | Register | Faq  

    LEAD Support Forum
  Resource to find answers and post technical questions about LEAD products.
Search    
   

My solution to crop Image..Hope to help you...
Started by yourfriend20030 at 03-12-2009 23:22. Topic has 0 replies.

Print Search « Previous Thread Next Thread »
  03-12-2009, 23:22
yourfriend20030 is not online. Last active: 1/4/2010 10:00:43 AM yourfriend20030

Top 50 Posts
Joined on 08-14-2008
Posts 77
My solution to crop Image..Hope to help you...
Reply Quote
May be I understand your problem. I think my solution will help you to solve this.
Here is my Code
1. Declare X1,Y1,X2,Y2 as integer to determine your rectangle you want to crop on the Image
2. In mouseDown event you set value for X1,Y1
3. In the MouseRelease Event you setvalue for X2,Y2
4. Assume that you want to crop after Release mouse event. Because you have determined your rectangle on your image so you can use CropComand to Crop your Image as you want

I have built my own Dicom Viewer Application containing Crop feature like Photoshop and other Image Processing and It works very well.
Here is my code I can share for you
void _medicalViewer_CellMouseUp(object sender, MedicalViewerCellMouseEventArgs e)
{
X2 = e.X - e.ImageRectangle.X;
Y2 = e.Y - e.ImageRectangle.Y;
ImgRec = e.ImageRectangle;
if (isCropping)
{
CropImage(_medicalViewer.Cells[CellIndex].GetTag(1, MedicalViewerTagAlignment.TopCenter).Text, _medicalViewer.Cells[CellIndex].Image, X1, Y1, X2, Y2);
//}

}

void _medicalViewer_CellMouseDown(object sender, MedicalViewerCellMouseEventArgs e)
{
X1 = e.X-e.ImageRectangle.X;

Y1 = e.Y - e.ImageRectangle.Y;
}

XR=img.Width/_medicalViewer.Cells[CellIndex].Size.Width;
YR=img.Height/_medicalViewer.Cells[CellIndex].Size.Height;
X1 = Convert.ToInt32(X1 * img.Width / ImgRec.Width);
Y1 = Convert.ToInt32(Y1 * img.Height / ImgRec.Height);
X2 = Convert.ToInt32(X2 * img.Width / ImgRec.Width);
Y2 = Convert.ToInt32(Y2 * img.Height / ImgRec.Height);
if (X1 > X2)
{
Temp = X1;
X1 = X2;
X2 = Temp;
}
if (Y1 > Y2)
{
Temp = Y1;
Y1 = Y2;
Y2 = Temp;
}
int H, W;
H = Y2 - Y1;

W = X2 - X1;

if (H == 0 || W == 0) return;
// Crop W and H pixels from (X1,Y1) of the image
CropCommand command = new CropCommand();
command.Rectangle = new Rectangle(X1, Y1, W, H);

Hope to help you!
   Report 
Post
LEAD Support Fo... » Developer » Special Effects » My solution to crop Image..Hope to help you...

Powered by Community Server, by Telligent Systems