> ' Crop an image > Public Function Crop() As Boolean > Dim loGraphics As System.Drawing.Graphics = Nothing > Dim loImage As System.Drawing.Bitmap = Nothing > > ' This is a placeholder > loImage = New System.Drawing.Bitmap(nCropWidth, nCropHeight) > > loGraphics = System.Drawing.Graphics.FromImage(loImage) > > ' This will use oImage and obtain the new result into loImage > loGraphics.DrawImage(oImage, New System.Drawing.Rectangle(0, 0, nCropWidth, nCropHeight), _ > nStartXPoint, nStartYPoint, nCropWidth, nCropHeight, System.Drawing.GraphicsUnit.Pixel) > > ' Release this object > loGraphics.Dispose() > > ' Take the new result and dump it back to oImage > oImage = loImage.Clone > > ' Release this object > loImage.Dispose() > > Return True >End Function >>
> ' Crop an image > Public Function Crop() As Boolean > Dim loGraphics As System.Drawing.Graphics = Nothing > Dim loImage As System.Drawing.Bitmap = Nothing > > ' This is a placeholder > loImage = New System.Drawing.Bitmap(nCropWidth, nCropHeight) > > loGraphics = System.Drawing.Graphics.FromImage(loImage) > > ' This will use oImage and obtain the new result into loImage > loGraphics.DrawImage(oImage, New System.Drawing.Rectangle(0, 0, nCropWidth, nCropHeight), _ > nStartXPoint, nStartYPoint, nCropWidth, nCropHeight, System.Drawing.GraphicsUnit.Pixel) > > ' Release this object > loGraphics.Dispose() > > ' Clear the old reference otherwise, if we upload an image with a secondary directory and the secondary file > ' does not require a resize, we will have a lock issue > oImage.Dispose() > > ' Take the new result and dump it back to oImage > oImage = loImage.Clone > > ' Release this object > loImage.Dispose() > > Return True >End Function >>