public event EventHandler<RasterImageResizeEventArgs> Resize public:event EventHandler<RasterImageResizeEventArgs^>^ Resize
def Resize(sender,e): # sender: RasterImageResize e: RasterImageResizeEventArgs The event handler receives an argument of type RasterImageResizeEventArgs containing data related to this event. The following RasterImageResizeEventArgs properties provide information specific to this event.
| Property | Description |
|---|---|
| Buffer | Gets the unmanaged buffer that holds the resized row. |
| BufferArray | Gets the managed buffer that holds the resized row. |
| Bytes | Gets the number of bytes in the resized row buffer. |
| Cancel | Gets or sets a value indicating whether to abort the resize operation. |
| Column | Gets the column offset within the row being resized. |
| Image | Gets a reference to the image being resized. |
| Row | Gets the number of the resized row. |
using Leadtools;using Leadtools.Codecs;public void RasterImageResizeExample(){string srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp");string destFileName = Path.Combine(LEAD_VARS.ImagesDir, "Image1_RasterImageResize.bmp");using (RasterCodecs codecs = new RasterCodecs()){// Load the source imageusing (RasterImage srcImage = codecs.Load(srcFileName)){// We will resize to half the original sizeint destWidth = srcImage.Width / 2;int destHeight = srcImage.Height / 2;// Create the destination imageusing (RasterImage destImage = new RasterImage(RasterMemoryFlags.Conventional,destWidth,destHeight,srcImage.BitsPerPixel,srcImage.Order,srcImage.ViewPerspective,srcImage.GetPalette(),IntPtr.Zero,0)){RasterImageResize resize = new RasterImageResize();// Add Event Handlerresize.Resize += new EventHandler<RasterImageResizeEventArgs>(resize_Resize);byte[] buffer = new byte[destImage.BytesPerLine];// Start the resize processresize.Start(srcImage,destWidth,destHeight,srcImage.BitsPerPixel,srcImage.Order,srcImage.DitheringMethod,RasterSizeFlags.None,srcImage.GetPalette());destImage.Access();// get the rows for the resized image, one by onefor (int row = 0; row < destImage.Height; row++){resize.ResizeBuffer(row, 0, buffer, 0, destImage.BytesPerLine);destImage.SetRow(row, buffer, 0, destImage.BytesPerLine);}destImage.Release();resize.Stop();// Save the destination imagecodecs.Save(destImage, destFileName, RasterImageFormat.Bmp, 24);}}}}private void resize_Resize(object sender, RasterImageResizeEventArgs e){// e.Row should ALWAYS be less than e.Image.Heightif (e.Row >= e.Image.Height){e.Cancel = true; // abort the resizereturn;}byte[] buffer = new byte[e.Bytes];e.Image.Access();e.Image.GetRowColumn(e.Row, e.Column, buffer, 0, e.Bytes);e.Image.Release();Marshal.Copy(buffer, 0, e.Buffer, e.Bytes);Console.WriteLine("{0}, {1}", e.Row, e.Column);}static class LEAD_VARS{public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images";}
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document
