public object Data { get; }
@property (nonatomic, assign, readonly, nullable) const NSData *data
public java.lang.Object getData();
public:
property Object^ Data {
Object^ get();
}
Data # get (RasterImage)
The data for the image.
This value should only be used with images created with user-defined data. Other type of images will return an undefined internal value.
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 DataExample()
{
RasterCodecs codecs = new RasterCodecs();
string destFileName = Path.Combine(LEAD_VARS.ImagesDir, "Data.bmp");
// Create an image with user defined data
int width = 40;
int height = 40;
int bitsPerPixel = 24;
int size = width * height * 3;
IntPtr data1 = Marshal.AllocHGlobal(size);
// Load the image
RasterImage image = new RasterImage(
RasterMemoryFlags.User,
width,
height,
bitsPerPixel,
RasterByteOrder.Bgr,
RasterViewPerspective.TopLeft,
null,
data1,
size);
// Get a pointer to the internal data and fill it with gray shades
long dataSize = image.DataSize;
byte[] buffer = new byte[dataSize];
bool inc = true;
byte value = 0;
for (int i = 0; i < buffer.Length; i += 3)
{
buffer[i + 0] = value;
buffer[i + 1] = value;
buffer[i + 2] = value;
if (inc)
{
if (value == 255)
{
inc = false;
value = 254;
}
else
value++;
}
else
{
if (value == 0)
{
inc = true;
value = 1;
}
else
value--;
}
}
// Copy this buffer to the image data
IntPtr data2 = (IntPtr)image.Data;
Marshal.Copy(buffer, 0, data2, buffer.Length);
// Save the image
codecs.Save(image, destFileName, RasterImageFormat.Bmp, 24);
image.Dispose();
Marshal.FreeHGlobal(data1);
codecs.Dispose();
}
static class LEAD_VARS
{
public const string ImagesDir = @"C:\LEADTOOLS22\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