Is the image orange yellow in the CImageList control?

Source: Internet
Author: User

 

 

Use oneThe CImageList control is used to load bitmaps for TREE controls. Other colors are normally orange and yellow.

 

You can only use20 colors (orange is not included); of course, you can also use the following method to load bitmap resources without being limited by the number of colors.

 

HBITMAP LoadResourceBitmap (HINSTANCE hInstance, LPSTR lpString,

Hpalette far * lphPalette)

{

HRSRC hRsrc;

HGLOBAL hGlobal;

HBITMAP hBitmapFinal = NULL;

LPBITMAPINFOHEADER lpbi;

HDC hdc;

Int iNumColors;

If (hRsrc =: FindResource (hInstance, lpString, RT_BITMAP ))

{

HGlobal =: LoadResource (hInstance, hRsrc );

Lpbi = (LPBITMAPINFOHEADER) LockResource (hGlobal );

Hdc =: GetDC (NULL );

* LphPalette = CreateDIBPalette (LPBITMAPINFO) lpbi, & iNumColors );

If (* lphPalette)

{

: SelectPalette (hdc, * lphPalette, FALSE );

: RealizePalette (hdc );

}

HBitmapFinal =: CreateDIBitmap (hdc,

(LPBITMAPINFOHEADER) lpbi,

(LONG) CBM_INIT,

(LPSTR) lpbi + lpbi-> biSize + iNumColors * sizeof (RGBQUAD ),

(LPBITMAPINFO) lpbi,

DIB_RGB_COLORS );

: ReleaseDC (NULL, hdc );

//: UnlockResource (hGlobal );

//: FreeResource (hGlobal );

}

Return (hBitmapFinal );

}

 

// Internally used by LoadResourceBitmap

HPALETTE CreateDIBPalette (LPBITMAPINFO lpbmi, LPINT lpiNumColors)

{

LPBITMAPINFOHEADER lpbi;

LPLOGPALETTE lpPal;

HANDLE hLogPal;

HPALETTE hPal = NULL;

Int I;

Lpbi = (LPBITMAPINFOHEADER) lpbmi;

If (lpbi-> biBitCount <= 8)

* LpiNumColors = (1 <lpbi-> biBitCount );

Else

* LpiNumColors = 0; // No palette needed for 24 BPP DIB

If (lpbi-> biClrUsed> 0)

* LpiNumColors = lpbi-> biClrUsed; // Use biClrUsed

If (* lpiNumColors)

{

HLogPal = GlobalAlloc (GHND, sizeof (LOGPALETTE) +

Sizeof (PALETTEENTRY) * (* lpiNumColors ));

LpPal = (LPLOGPALETTE) GlobalLock (hLogPal );

LpPal-> palVersion = 0x300;

LpPal-> palNumEntries = * lpiNumColors;

For (I = 0; I <* lpiNumColors; I ++)

{

LpPal-> pal

PalEntry [I].

PeRed = lpbmi-> bmiColors [I]. rgbRed;

LpPal-> palP

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.