Here is the Cropping Code
Code: Select all
private void btnCrop_Click(object sender, EventArgs e)
{
try
{
int croped = oGdPictureImaging.CreateNewGdPictureImage(oGdPictureImaging.GetWidth(m_ImageID), oGdPictureImaging.GetHeight(m_ImageID), 24, Color.White);
List<Point> listofpnt = new List<Point>();
if (listofRect.Count > 0)// listofRect is having a rectangles to be cropped.
{
foreach (var item in listofRect)
{
oGdPictureImaging.GetPixelArrayInteger(m_ImageID, ref pnt, item.X + 2, item.Y + 2, item.Width - 4, item.Height - 4);
oGdPictureImaging.SetPixelArrayInteger(croped, pnt, item.X + 2, item.Y + 2, item.Width - 4, item.Height - 4);
GdViewer1.DisplayFromGdPictureImage(croped);
GdViewer1.Refresh();
listoftempDeleted.Add(item);
}
listofRect.Clear();
oGdPictureImaging.GetPixelArrayInteger(croped, ref pnt, 0, 0, oGdPictureImaging.GetWidth(croped), oGdPictureImaging.GetHeight(croped));
oGdPictureImaging.SetPixelArrayInteger(m_ImageID, pnt, 0, 0, oGdPictureImaging.GetWidth(m_ImageID), oGdPictureImaging.GetHeight(m_ImageID));
GdViewer1.DisplayFromGdPictureImage(m_ImageID);
GdViewer1.Refresh();
SaveGraphicState(false);
oGdPictureImaging.ReleaseGdPictureImage(croped);
pnt = null;
}
}
catch (Exception)
{
throw;
}
}