public object Data { get; }
Public ReadOnly Property Data As Object
@property (nonatomic, assign, readonly, nullable) const NSData *data
public Object getData()
public:
property Object^ Data {
Object^ get();
}
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:\LEADTOOLS21\Resources\Images";
}
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.ImageProcessing
Imports Leadtools.ImageProcessing.Core
Imports Leadtools.ImageProcessing.Color
Imports Leadtools.Controls
Imports Leadtools.Dicom
Imports Leadtools.Drawing
Imports Leadtools.Svg
Public Sub DataExample()
Dim codecs As RasterCodecs = New RasterCodecs()
Dim destFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Data.bmp")
' Create an image with user defined data
Dim width As Integer = 40
Dim height As Integer = 40
Dim bitsPerPixel As Integer = 24
Dim size As Integer = width * height * 3
Dim data1 As IntPtr = Marshal.AllocHGlobal(size)
' Load the image
Dim image As RasterImage = New RasterImage(RasterMemoryFlags.User, width, height, bitsPerPixel, RasterByteOrder.Bgr,
RasterViewPerspective.TopLeft, Nothing, data1, size)
' Get a pointer to the internal data and fill it with gray shades
Dim dataSize As Integer = CInt(image.DataSize)
Dim buffer As Byte() = New Byte(dataSize - 1) {}
Dim inc As Boolean = True
Dim value As Byte = 0
Dim i As Integer = 0
Do While i < buffer.Length
buffer(i + 0) = value
buffer(i + 1) = value
buffer(i + 2) = value
If inc Then
If value = 255 Then
inc = False
value = 254
Else
value = value + Convert.ToByte(1)
End If
Else
If value = 0 Then
inc = True
value = 1
Else
value = value - Convert.ToByte(1)
End If
End If
i += 3
Loop
' Copy this buffer to the image data
Dim data2 As IntPtr = CType(image.Data, IntPtr)
Marshal.Copy(buffer, 0, data2, buffer.Length)
' Save the image
codecs.Save(image, destFileName, RasterImageFormat.Bmp, 24)
image.Dispose()
Marshal.FreeHGlobal(data1)
codecs.Dispose()
End Sub
Public NotInheritable Class LEAD_VARS
Public Const ImagesDir As String = "C:\LEADTOOLS21\Resources\Images"
End Class
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