D
Darrel
I've been trying to figure out how to crop an image. I found the sample code
below, but I'm not exactly sure what it's doing. I've added my own comments
as best I can trying to explain what I think it's doing. Can anyone clarify
this for me?
' I think this takes my current image (g) and then resizes it to what I want
bmpImage = New Bitmap(g, newWidth, newHeight)
' now I set up a rectangle to the dimensions of the cropped version
recCrop = New Rectangle(0, 0, resizedWidth, resizedHeight)
' this is where I begin to get lost. I think this is taking
' my resizedi mages and cropping it based on the rectangle
' dimensions I made
bmpCrop = New Bitmap(recCrop.Width, recCrop.Height, bmpImage.PixelFormat)
' Now I get really lost, I'm not sure what the rest of this is doing.
gphCrop = Graphics.FromImage(bmpCrop)
recDest = New Rectangle(0, 0, Width, Height)
gphCrop.DrawImage(bmpImage, recDest, recCrop.X, recCrop.Y, recCrop.Width,
_recCrop.Height, GraphicsUnit.Pixel)
-Darrel
below, but I'm not exactly sure what it's doing. I've added my own comments
as best I can trying to explain what I think it's doing. Can anyone clarify
this for me?
' I think this takes my current image (g) and then resizes it to what I want
bmpImage = New Bitmap(g, newWidth, newHeight)
' now I set up a rectangle to the dimensions of the cropped version
recCrop = New Rectangle(0, 0, resizedWidth, resizedHeight)
' this is where I begin to get lost. I think this is taking
' my resizedi mages and cropping it based on the rectangle
' dimensions I made
bmpCrop = New Bitmap(recCrop.Width, recCrop.Height, bmpImage.PixelFormat)
' Now I get really lost, I'm not sure what the rest of this is doing.
gphCrop = Graphics.FromImage(bmpCrop)
recDest = New Rectangle(0, 0, Width, Height)
gphCrop.DrawImage(bmpImage, recDest, recCrop.X, recCrop.Y, recCrop.Width,
_recCrop.Height, GraphicsUnit.Pixel)
-Darrel