LBitmap::LBitmap

#include "ltwrappr.h"

L_VOID LBitmap::LBitmap(void)

L_VOID LBitmap::LBitmap(pInfo, pBits)

L_VOID LBitmap::LBitmap(hDC, hBitmap, hPalette)

L_VOID LBitmap::LBitmap(uWidth, uHeight, uBitsPerPixel=24, uOrder=ORDER_BGR, pPalette=NULL, uViewPerspective=TOP_LEFT, crFill=0, uMemory=TYPE_CONV)

L_VOID LBitmap::LBitmap(pBitmapHandle)

BITMAPINFO L_FAR * pInfo;

/* pointer to a BITMAPINFO structure */

L_UCHAR L_FAR * pBits;

/* pointer to bitmap data */

HDC hDC;

/* handle to a device context */

HBITMAP hBitmap;

/* handle to a DDB */

HPALETTE hPalette;

/* handle of the palette */

L_UINT uWidth;

/* the desired initial bitmap width */

L_UINT uHeight;

/* the desired initial bitmap height */

L_UINT uBitsPerPixel;

/* the number of bits per pixel */

L_UINT uOrder;

/* color order */

LPRGBQUAD pPalette;

/* pointer to the palette */

L_UINT uViewPerspective;

/* the desired view perspective */

COLORREF crFill;

/* fill color for the bitmap */

L_UINT uMemory;

/* flag that indicates the type of memory */

pBITMAPHANDLE pBitmapHandle;

/* pointer to a LEAD bitmap handle */

Constructs and initializes the member variables of the LBitmap object.

Parameter

Description

pInfo

Pointer to a BITMAPINFO structure that describes the bitmap data.

pBits

Pointer to the bitmap data to be used in initializing the bitmap.

hDC

Handle to a Windows DC.

hBitmap

Handle to a device dependent bitmap (DDB) of type HBITMAP.

hPalette

Handle of the palette to be used for the bitmap or NULL if the bitmap does not have a palette.

uWidth

The desired initial bitmap width.

uHeight

The desired initial bitmap height.

uBitsPerPixel

The number of bits per pixel. Valid values are 0, 1, 4, 8, 12, 16, 24, 32, 48, and 64. Use 0 to create an 8-bit grayscale bitmap. In that case, the function ignores the uOrder and pPalette parameters.

uOrder

Color order for 16-, 24-, and 32-bit bitmaps. If the resultant bitmap is less than 16 bits per pixel, this will have no effect since palletized images have no order. Possible values are:

 

Value

Meaning

 

ORDER_RGB

[0] Red, green, and blue color order in memory

 

ORDER_BGR

[1] Blue, green, and red color order in memory

 

ORDER_GRAY

[2] 12 or 16-bit grayscale image. 12 and 16-bit grayscale images are only supported in the Document/Medical toolkits.

 

ORDER_ROMM

[5] ROMM order in memory. ROMM only supports 24 and 48-bit images.

pPalette

Pointer to the palette that the bitmap will use. You can specify your own palette, or use NULL to use LEAD's fixed palette.

uViewPerspective

The desired view perspective for the bitmap. Possible values are:

 

Value

Meaning

 

TOP_LEFT

[0] Top-left of image is first in memory.

 

BOTTOM_LEFT180

[1] (Document/Medical only) Same as TOP_RIGHT, which is BOTTOM_LEFT rotated clockwise by 180 degrees.

 

BOTTOM_LEFT

[2] Bottom-left of image is first in memory.

 

TOP_LEFT180

[3] (Document/Medical only) Same as BOTTOM_RIGHT, which is TOP_LEFT rotated clockwise by 180 degrees.

 

RIGHT_TOP

[4] (Document/Medical only) First row is the right side, first column is top side.

 

TOP_LEFT90

[4] (Document/Medical only) Same as RIGHT_TOP, which is TOP_LEFT rotated clockwise by 90 degrees.

 

LEFT_TOP

[5] (Document/Medical only) First row is the left side, first column is the top side

 

BOTTOM_LEFT90

[5] (Document/Medical only) Same as LEFT_TOP, which is BOTTOM_LEFT rotated clockwise by 90 degrees

 

RIGHT_BOTTOM

[7] (Document/Medical only) First row is the right side, first column is the bottom side

 

BOTTOM_LEFT270

[7] (Document/Medical only) Same as RIGHT_BOTTOM, which is BOTTOM_LEFT rotated clockwise by 270 degrees

 

LEFT_BOTTOM

[8] (Document/Medical only) First row is the left side, first column is top side.

 

TOP_LEFT270

[8] (Document/Medical only) Same as LEFT_BOTTOM, which is TOP_LEFT rotated clockwise by 270 degrees.

crFill

The fill color. The standard Windows values for COLORREF represent either red, green, and blue color values, or an index into the bitmap's palette. A COLORREF value with the format 0x00BBGGRR represents the blue, green, and red color values for the specified pixel, where 0xBB is the blue value, 0xGG is the green value and 0xRR is the red value. If 0x01000000 is set in the COLORREF value (0x010000ZZ), the lower 8 bits (0xZZ) represent an index into the bitmap's palette which holds the color value. These COLORREF values can be used with any Windows function and macro that takes a COLORREF parameter.

 

In the Document/Medical toolkits, the COLORREF value may represent a 16 bit grayscale value if pBitmap is a 12 or 16-bit grayscale bitmap. So that the value is not confused with an RGB value, the COLORREF_GRAY16 mask (0x04000000) is set. In this case (0x0400YYYY), the lower 16 bits (0xYYYY) of the COLORREF value represent the 16-bit grayscale value. (0x0400FFFF is 16-bit white and 0x04000000is 16-bit black.) This is not a standard Windows value. Therefore, LEADTOOLS functions will recognize a COLORREF having this format, but Windows functions will not. For information on how to use a 16-bit grayscale COLORREF in a non-LEADTOOLS function, refer to LBitmapBase::GetPixelColor.

 

uMemory

Flag that indicatres the type of memory to allocate. Possible values are:

 

Value

Meaning

 

TYPE_CONV

[0x0001] Use conventional memory if the image will fit, otherwise swap to disk.

 

TYPE_COMPRESSED

[0x0200] (Document/Medical only) Allocate an RLE-compressed bitmap. You can use this flag with TYPE_CONV. For more information, refer to Speeding Up 1-Bit Documents..

 

TYPE_SUPERCOMPRESSED

[0x0400] (Document/Medical only) Keep images compressed in memory. This option causes slow access, but very low memory usage. This option is available only for 1-bit, 8-bit grayscale and 24-bit images.

pBitmapHandle

Pointer to a LEAD bitmap handle that describes an allocated bitmap.

Returns

None

Comments

LBitmap::LBitmap(uWidth, uHeight, uBitsPerPixel, uOrder, pPalette, uViewPerspective, crFill, uMemory) constructs an LBitmap object and allocates a bitmap with the desired width, height, bits per pixel, color order, view perspective and memory type. You can check for successful allocation by calling the LBitmapBase::IsAllocated member function. Even if the allocation fails, the class object is still constructed.

LBitmap::LBitmap(pInfo, pBits) constructs an LBitmap object and allocates a bitmap using the passed bitmap info and data (DIB). You can check for successful allocation by calling the LBitmapBase::IsAllocated member function. Even if the allocation fails, the class object is still constructed.

LBitmap::LBitmap(hDC, hBitmap, hPalette) constructs an LBitmap object and allocates a bitmap using the passed hBitmap (DDB). You can check for successful allocation by calling the LBitmapBase::IsAllocated member function. Even if the allocation fails, the class object is still constructed.

LBitmap::LBitmap(pBitmapHandle) constructs an LBitmap object and allocates a bitmap from another LEAD bitmap handle. You can check for successful allocation by calling the LBitmapBase::IsAllocated member function. Even if the allocation fails, the class object is still constructed.

Required DLLs and Libraries

LTDIS
LTFIL
LTIMG

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application.

See Also

Functions:

LBitmap::~LBitmap, LBitmapBase::IsAllocated, Class Members

Topics:

Using Color Values in LEADTOOLS

Example

This is an example for LBitmap::LBitmap(void).

LBitmap LeadBitmap;
//Load an image
LeadBitmap.Load(TEXT("image1.cmp"), 0,ORDER_BGR);

This is an example for LBitmap::LBitmap(pInfo, pBits):

BITMAPINFO bmpInfo;
L_UCHAR  bits[256];
// fill bmpInfo & bits with a valid image

LBitmap Bitmap(&bmpInfo, bits);

This is an example for LBitmap::LBitmap(hDC, hBitmap, hPalette):

L_VOID  MyFunction(HWND hWnd)
{
   HDC hDC;
   LBitmap     LeadBitmap ;
   HBITMAP hBitmap;
  
   LeadBitmap.Load (TEXT("image1.cmp"));

   hDC = GetDC(hWnd) ;
   hBitmap = LeadBitmap.ConvertToDDB( hDC) ;
   LBitmap MyBitmap(hDC, hBitmap, 0);
   
   // .....
   // .....

   ReleaseDC(hWnd,hDC) ;
}

This is an example for LBitmap::LBitmap(uWidth, uHeight, uBitsPerPixel, uOrder, pPalette, uViewPerspective, crFill, uMemory)

LBitmap m_Bitmap(100, 50, 24, ORDER_BGR, NULL, TOP_LEFT, RGB(255, 0, 0), TYPE_CONV)

This is an example for LBitmap::LBitmap(pBitmapHandle):

BITMAPHANDLE bmp;
L_CreateBitmap(&bmp, TYPE_CONV, 50, 50, 24, ORDER_BGR, NULL, TOP_LEFT);
LBitmap m_Bitmap(&bmp);