You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is an excellent and versatile control, I am using the ImageBoxEx code (v1.1) extending the ImageBox v1.4 found in the latest NuGet package. I am using ImageBoxEx because I want to add some image editing capabilities to transform my image.
So far I get my image displayed, the selection regions are displayed and can be resized and moved. At some point though, I want to CROP the image using the SelectionRegion rectangle. I have the code to do the cropping which I have tested in a regular (stock) PictureBox control; However, this does not seem to be working with the ImageBox/Ex controls.
Basically I do this:
using (ImageProcessor imgProc = new ImageProcessor(imageBox1.Image))
{
Rectangle rect = Rectangle.Round(imageBox1.SelectionRegion);
imageBox1.SelectNone();
imgProcessor.Crop(rect);
imageBox1.Image = imgProcessor.CurrentImage;
}
where the Crop method looks like this:
public void Crop(Rectangle r)
{
Bitmap temp = (Bitmap)_currentBitmap; // this is where the bitmap was placed by the constructor
Bitmap bmap = (Bitmap)temp.Clone();
if (r.X + r.Width > _currentBitmap.Width)
r.Width = _currentBitmap.Width - r.X;
if (r.Y + r.Height > _currentBitmap.Height)
r.Height = _currentBitmap.Height - r.Y;
_currentBitmap = (Bitmap)bmap.Clone(r, bmap.PixelFormat);
}
But after I do that the imageBox image gets cleared from the ImageBoxEx control. If I eliminate the using() then the image remains the same as if I had not cropped it.
The text was updated successfully, but these errors were encountered:
I tried it that way and it worked. I don't know why the original approach works on the PictureBox but not on ImageBox, maybe because yours is more complex but MUCH more versatile! Excellent work by the way.
This is an excellent and versatile control, I am using the ImageBoxEx code (v1.1) extending the ImageBox v1.4 found in the latest NuGet package. I am using ImageBoxEx because I want to add some image editing capabilities to transform my image.
So far I get my image displayed, the selection regions are displayed and can be resized and moved. At some point though, I want to CROP the image using the SelectionRegion rectangle. I have the code to do the cropping which I have tested in a regular (stock) PictureBox control; However, this does not seem to be working with the ImageBox/Ex controls.
Basically I do this:
where the Crop method looks like this:
But after I do that the imageBox image gets cleared from the ImageBoxEx control. If I eliminate the using() then the image remains the same as if I had not cropped it.
The text was updated successfully, but these errors were encountered: