LBitmap::LBitmap

Summary

Constructs and initializes the member variables of the LBitmap object.

Syntax

#include "ltwrappr.h"

LBitmap::LBitmap()

LBitmap::LBitmap(pInfo, pBits)

LBitmap::LBitmap(hDC, hBitmap, hPalette)

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

LBitmap::LBitmap(pBitmapHandle)

Parameters

BITMAPINFO * pInfo

Pointer to a BITMAPINFO structure that describes the bitmap data.

L_UCHAR * pBits

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

HDC hDC

Handle to a Windows DC.

HBITMAP hBitmap

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

HPALETTE hPalette

Handle of the palette to be used for the bitmap or NULL if the bitmap does not have a 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. 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.

L_UINT 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.

LPRGBQUAD 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.

L_UINT uViewPerspective

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

Value Meaning
TOP_LEFT [1] Top-left of image is first in memory.
BOTTOM_LEFT180 [2] (Document/Medical only) Same as TOP_RIGHT, which is BOTTOM_LEFT rotated clockwise by 180 degrees.
BOTTOM_LEFT [4] 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 [6] (Document/Medical only) First row is the right side, first column is top side.
TOP_LEFT90 [6] (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.

COLORREF 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.

L_UINT uMemory

Flag that indicates 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 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

Platforms

Win32, x64.

See Also

Functions

Topics

Example

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

L_INT LBitmap__LBitmapFirstExample() 
{ 
   L_INT nRet; 
   LBitmap LeadBitmap; 
   //Load an image 
   nRet =LeadBitmap.Load(MAKE_IMAGE_PATH(TEXT("image1.cmp")), 0,ORDER_BGR); 
   if(nRet !=SUCCESS) 
      return nRet; 
 
   return SUCCESS; 
} 
 
//This is an example for LBitmap::LBitmap(pInfo, pBits): 
L_INT LBitmap__LBitmapSecondExample() 
{ 
   BITMAPINFO bmpInfo; 
   L_UCHAR  bits[256]; 
   // fill bmpInfo & bits with a valid image 
   
   LBitmap Bitmap(&bmpInfo, bits); 
 
   return SUCCESS; 
} 
 
//This is an example for LBitmap::LBitmap(hDC, hBitmap, hPalette): 
 
L_INT LBitmap__LBitmapThirdExample(HWND hWnd) 
{ 
   L_INT nRet; 
   HDC hDC; 
   LBitmap     LeadBitmap ; 
   HBITMAP hBitmap; 
 
   nRet =LeadBitmap.Load (MAKE_IMAGE_PATH(TEXT("image1.cmp"))); 
   if(nRet !=SUCCESS) 
      return nRet; 
 
   hDC = GetDC(hWnd) ; 
   hBitmap = LeadBitmap.ConvertToDDB( hDC) ; 
   LBitmap MyBitmap(hDC, hBitmap, 0); 
 
   // ..... 
   // ..... 
 
   ReleaseDC(hWnd,hDC) ; 
   return SUCCESS; 
} 
 
//This is an example for LBitmap::LBitmap(uWidth, uHeight, uBitsPerPixel, uOrder, pPalette, uViewPerspective, crFill, uMemory) 
L_INT LBitmap__LBitmapForthExample() 
{ 
   LBitmap m_Bitmap(100, 50, 24, ORDER_BGR, NULL, TOP_LEFT, RGB(255, 0, 0), TYPE_CONV); 
 
   return SUCCESS; 
} 
  
//     This is an example for LBitmap::LBitmap(pBitmapHandle): 
L_INT LBitmap__LBitmapFifthExample() 
{ 
   L_INT nRet; 
   BITMAPHANDLE bmp; 
    
   nRet =L_CreateBitmap(&bmp,sizeof(BITMAPHANDLE ), TYPE_CONV, 50, 50, 24, ORDER_BGR, NULL, TOP_LEFT,NULL,0); 
   if(nRet !=SUCCESS) 
      return nRet; 
   LBitmap m_Bitmap(&bmp); 
   return SUCCESS; 
} 

Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C++ Class Library Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.