SetRowColumn(int,int,IntPtr,int) Method (original) (raw)

Summary

Copies data from an unmanaged memory buffer to an image, with an offset to the image.

Syntax

Parameters

row
The number of the row to update. The first row is 0, and the last row is 1 less than the image height.

column
The column offset within the row to update. The first column offset is 0, and the last column offset is 1 less than the image width.

buffer
Pointer to an unmanaged memory buffer containing the image data. The buffer should contain uncompressed data regardless of whether the image is compressed or not.

bufferCount
The number of bytes to update. Consider the bits per pixel, and avoid specifying a number that goes past the end of the row.

For a 1-bit image, each byte represents 8 pixels. For a 4-bit image, each byte represents 2 pixels. For an 8-bit image, each byte represents 1 pixel. For a 16-bit image, every 2 bytes represents one pixel. For 24-bit images, every three bytes represents one pixel. For a 32-bit image, every four bytes represents one pixel. For a 48-bit image, every six bytes represents one pixel. For a 64-bit image, every eight bytes represents one pixel.

Return Value

The number of bytes put.

Example

using Leadtools; using Leadtools.Codecs; using Leadtools.ImageProcessing; using Leadtools.ImageProcessing.Core; using Leadtools.ImageProcessing.Color; using Leadtools.Dicom; using Leadtools.Drawing; using Leadtools.Controls; using Leadtools.Svg; public void GetRowColumnExample() { RasterCodecs codecs = new RasterCodecs(); RasterImage image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "IMAGE1.CMP")); // This example does not work with rotated view perspectives. if ((image.ViewPerspective != RasterViewPerspective.TopLeft) || (image.ViewPerspective != RasterViewPerspective.BottomLeft)) image.ChangeViewPerspective(RasterViewPerspective.TopLeft); // Specify a rectangle in the top left part of the displayed image. int xOffset = Convert.ToInt32(image.Width / 8); // Column offset of the rectangle to process. int xSize = Convert.ToInt32(image.Width / 3); // Pixel width of the rectangle to process. int yOffset = Convert.ToInt32(image.Height / 8); // Row offset of the rectangle to process. int ySize = Convert.ToInt32(image.Height / 3); // Pixel height of the rectangle to process. // Adjust the YOffset if the view perspective is bottom left. if (image.ViewPerspective == RasterViewPerspective.BottomLeft) yOffset = image.Height - yOffset - ySize; // Allocate the buffer. byte[] Buffer = new byte[xSize * 3]; // Invert the colors of pixels in the rectangle. image.Access(); for (int i = yOffset; i < yOffset + ySize; i++) { image.GetRowColumn(i, xOffset, Buffer, 0, xSize * 3); for (int col = 0; col < xSize * 3; col++) Buffer[col] ^= 0xFF; image.SetRowColumn(i, xOffset, Buffer, 0, xSize * 3); } image.Release(); codecs.Save(image, Path.Combine(LEAD_VARS.ImagesDir, "IMAGE1_getrowcol.BMP"), RasterImageFormat.Bmp, 0); image.Dispose(); codecs.Dispose(); } static class LEAD_VARS { public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images"; }

Leadtools Assembly

Convert(byte[],int,int,int,int,RasterByteOrder,RasterByteOrder,RasterColor[],RasterColor[],int,int,int,RasterConvertBufferFlags) Method

Convert(byte[],int,int,int,int,RasterByteOrder,RasterByteOrder,RasterColor[],RasterColor[],RasterColor16[],RasterColor16[],int,int,int,RasterConvertBufferFlags) Method

Convert(IntPtr,int,int,int,RasterByteOrder,RasterByteOrder,RasterColor[],RasterColor[],int,int,int,RasterConvertBufferFlags) Method

Convert(IntPtr,int,int,int,RasterByteOrder,RasterByteOrder,RasterColor[],RasterColor[],RasterColor16[],RasterColor16[],int,int,int,RasterConvertBufferFlags) Method