public void Start(
RasterImage image,
int width,
int height,
int bitsPerPixel,
RasterByteOrder order,
RasterDitheringMethod ditheringMethod,
RasterSizeFlags sizeFlags,
RasterColor[] palette
)
- (BOOL)startResize:(LTRasterImage *)image width:(NSInteger)width height:(NSInteger)height bitsPerPixel:(NSInteger)bitsPerPixel order:(LTRasterByteOrder)order ditheringMethod:(LTRasterDitheringMethod)ditheringMethod sizeFlags:(LTRasterSizeFlags)sizeFlags palette:(NSArray<LTRasterColor *> *)palette callback:(void (^ __nullable)(LTRasterImageResizeData *, BOOL *))callback error:(NSError **)error;
public:
void Start(
RasterImage^ image,
int width,
int height,
int bitsPerPixel,
RasterByteOrder order,
RasterDitheringMethod ditheringMethod,
RasterSizeFlags sizeFlags,
array<RasterColor>^ palette
)
def Start(self,image,width,height,bitsPerPixel,order,ditheringMethod,sizeFlags,] palette):
image
Image to be resized.
width
New width of the image data.
height
New height of the image data.
bitsPerPixel
Output bits per pixel. Use 0 for 8-bit grayscale. Possible values are: 0, 1, 2, 3, 4, 5, 6, 7, 8, 12, 16, 24, 32, 48 and 64.
order
Output color order.
ditheringMethod
Flags that indicate the type of dithering, if bitsPerPixel is not the same as the source image.
sizeFlags
Flags that indicate the type of resizing.
palette
The palette to dither to if bitsPerPixel is less than or equal to 8. Pass a null reference to dither to the fixed palette or if no palette is required.
Remarks ditheringMethod is used when dithering is needed to produce the output bits per pixel. The interpolation usually requires that the input data be converted to 24-bit or 48-bit and then back to the desired bits per pixel. So some dithering might be required if the output bits/pixel are less than or equal to 8.
The Start method starts the resizing process. This will be followed by calls to ResizeBuffer to retrieve the resized data and by a call to Stop, to end the resize process and clean up any allocated resources.
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 image
using (RasterImage srcImage = codecs.Load(srcFileName))
{
// We will resize to half the original size
int destWidth = srcImage.Width / 2;
int destHeight = srcImage.Height / 2;
// Create the destination image
using (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 Handler
resize.Resize += new EventHandler<RasterImageResizeEventArgs>(resize_Resize);
byte[] buffer = new byte[destImage.BytesPerLine];
// Start the resize process
resize.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 one
for (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 image
codecs.Save(destImage, destFileName, RasterImageFormat.Bmp, 24);
}
}
}
}
private void resize_Resize(object sender, RasterImageResizeEventArgs e)
{
// e.Row should ALWAYS be less than e.Image.Height
if (e.Row >= e.Image.Height)
{
e.Cancel = true; // abort the resize
return;
}
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