←Select platform

CreateFromArray Method

Summary

Constructs a new RasterImage object using the specified parameters and optional managed memory.

Syntax

C#
VB
WinRT C#
C++
Public Shared Function CreateFromArray( _ 
   ByVal flags As Leadtools.RasterMemoryFlags, _ 
   ByVal width As Integer, _ 
   ByVal height As Integer, _ 
   ByVal bitsPerPixel As Integer, _ 
   ByVal order As Leadtools.RasterByteOrder, _ 
   ByVal viewPerspective As Leadtools.RasterViewPerspective, _ 
   ByVal palette() As Leadtools.RasterColor, _ 
   ByVal userData() As Byte, _ 
   ByVal userDataLength As Integer _ 
) As Leadtools.RasterImage 
 function Leadtools.RasterImage.CreateFromArray(  
   flags , 
   width , 
   height , 
   bitsPerPixel , 
   order , 
   viewPerspective , 
   palette , 
   userData , 
   userDataLength  
) 

Parameters

flags
A combination of the RasterMemoryFlags enumeration members indicating the type of memory to allocate for the image data.

width
Width of the image in pixels.

height
Height of the image in pixels.

bitsPerPixel
The number of bits per pixel.

Valid values are 0, 1, 2, 3, 4, 5, 6, 7, 8, 12, 16, 24, 32, 48, and 64.

Use 0 to create an 8-bit grayscale image. In that case, the method ignores the order and the palette parameters.

order
Color order for 16-bit, 24-bit, 32-bit, 48-bit and 64-bit images.

If the resultant image is less than 16 bits per pixel, this will have no effect since palletized images have no order.

viewPerspective
Specifies where the beginning of the image is stored.

Most file formats start in the lower left corner while some formats start in the upper left corner.

palette
The palette that the image will use. You can specify your own palette, or use null for LEAD's fixed palette. The palette member is used only when bitsPerPixel is less than or equal to 8.

userData
Managed data array that will contain the image data when flags is RasterMemoryFlags.User.

This data must be aligned on a four byte boundary. If userData is null, the data pointer must be passed later, by calling the SetUserData method, before the image can be used.

userDataLength
Length in bytes of the data passed to userData. Only when used when userData is not null and flags is RasterMemoryFlags.User.

Remarks

Support for 12 and 16-bit grayscale images is only available in the Document/Medical Imaging editions.

There is some speed penalty (loss) for accessing RasterMemoryFlags.Tiled images. Therefore, it is not recommended for use with all images.

The RasterMemoryFlags.Tiled images are not used by default. LEADTOOLS will create them only if it failed to create RasterMemoryFlags.Conventional images and RasterMemoryFlags.NoTiled was not specified.

The following lists the distinct types of bitmaps:

  • Conventional (uncompressed and contiguous) This is the most common type.
  • Compressed (1-bit only)
  • Tiled (uncompressed, stored internally as up to 64MB tiles)

Creating an image of type RasterMemoryFlags.User does not allocate memory for the image data. Instead, the data pointer userData is used. When you create a RasterImage with user data, the IsConventionalMemory and IsMirrored flags will both be set to true. Some image processing commands, such as RotateCommand, need to re-allocate the image data. If you create an image with RasterMemoryFlags.User, and pass it to these methods, the data will be re-allocated internally by LEADTOOLS and the image object will stop using the data in userData.

Important: The above discussion is valid only for the LEADTOOLS Silverlight toolkit. LEADTOOLS for .NET does not support user memory of type array of Byte. Instead, calling this method in LEADTOOLS for .NET will create a regular conventional memory image then copy the data passed through userData to the internal image data. userData will not be used after this method returns. To create a true user-memory raster images in LEADTOOLS for .NET, use the RasterImage(..., IntPtr userData, ...) constructor.

For more information, refer to Accounting for View Perspective.

For more information, refer to Grayscale Images.

Requirements

Target Platforms

Help Version 19.0.2017.10.27
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.

Leadtools Assembly