Click here to Skip to main content
15,914,386 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Text Processing Pin
Michael Dunn22-Nov-01 19:50
sitebuilderMichael Dunn22-Nov-01 19:50 
GeneralRe: Text Processing Pin
Nick Parker23-Nov-01 4:09
protectorNick Parker23-Nov-01 4:09 
GeneralRe: Text Processing Pin
Michael Dunn23-Nov-01 8:14
sitebuilderMichael Dunn23-Nov-01 8:14 
GeneralRe: Text Processing Pin
Nick Parker23-Nov-01 10:57
protectorNick Parker23-Nov-01 10:57 
GeneralRe: Text Processing Pin
Michael Dunn23-Nov-01 11:17
sitebuilderMichael Dunn23-Nov-01 11:17 
GeneralRe: Text Processing Pin
Nick Parker24-Nov-01 1:54
protectorNick Parker24-Nov-01 1:54 
GeneralEnumPrinters function Pin
Brett G.22-Nov-01 16:49
Brett G.22-Nov-01 16:49 
QuestionHow to display a bitmap of 24 bits correctly?? Pin
Leesen22-Nov-01 16:23
Leesen22-Nov-01 16:23 
Hi,
all
I am a beginner in vc programming.Now I have some problems
in my program.I want to display a bitmap of 24 bits,but It
seems that there are some colors the system can't display
correctly. My source code follows below.

CClientDC dc(this);
HBITMAP hBitmap=(HBITMAP)::LoadImage(AfxGetInstanceHandle (),"E:\\Bg.BMP",IMAGE_BITMAP,0,0,LR_LOADFROMFILE|LR_CREATEDIBSECTION);
CBitmap bmBG;
bmBG.Attach(hBitmap);
BITMAP bm;
bmBG.GetBitmap(&bm);
CDC dcMem;
dcMem.CreateCompatibleDC(&dc);
CBitmap* pOldBitmap=(CBitmap*)dcMem.SelectObject(&bmBG);
CRect lRect;
GetClientRect(&lRect);
lRect.NormalizeRect();
DIBSECTION ds;
BITMAPINFOHEADER &bmInfo=ds.dsBmih;
bmBG.GetObject(sizeof(ds),&ds);
CPalette pal;
int nColors = bmInfo.biClrUsed ?bmInfo.biClrUsed : 1 << bmInfo.biBitCount;
if( nColors > 256 ) pal.CreateHalftonePalette( &dc );
else{
// Create the palette
RGBQUAD *pRGB = new RGBQUAD[nColors];
::GetDIBColorTable( dcMem, 0, nColors, pRGB );
UINT nSize = sizeof(LOGPALETTE) + (sizeof(PALETTEENTRY) * nColors);
LOGPALETTE *pLP = (LOGPALETTE *) new BYTE[nSize];
pLP->palVersion = 0x300;
pLP->palNumEntries = nColors;
for( int i=0; i<ncolors;i++)
{
="" plp-="">palPalEntry[i].peRed = pRGB[i].rgbRed;
pLP->palPalEntry[i].peGreen = pRGB[i].rgbGreen;
pLP->palPalEntry[i].peBlue = pRGB[i].rgbBlue;
pLP->palPalEntry[i].peFlags = 0;
}
pal.CreatePalette( pLP );
delete[] pLP;
delete[] pRGB;
}

dc.StretchBlt(10,10,lRect.Width()-10,lRect.Height()-10,&dcMem,0,0,bm.bmWidth,bm.bmHeight,SRCCOPY);

I will appreciate your advanced help.

Best Regards.Confused | :confused: Confused | :confused:
AnswerRe: How to display a bitmap of 24 bits correctly?? Pin
Christian Graus22-Nov-01 16:38
protectorChristian Graus22-Nov-01 16:38 
GeneralRe: How to display a bitmap of 24 bits correctly?? Pin
Leesen22-Nov-01 16:48
Leesen22-Nov-01 16:48 
GeneralRe: How to display a bitmap of 24 bits correctly?? Pin
Christian Graus22-Nov-01 17:21
protectorChristian Graus22-Nov-01 17:21 
GeneralSorting the CStringArray Pin
Tili22-Nov-01 15:11
Tili22-Nov-01 15:11 
GeneralRe: Sorting the CStringArray Pin
Christian Graus22-Nov-01 16:42
protectorChristian Graus22-Nov-01 16:42 
GeneralRe: Sorting the CStringArray Pin
Jon Hulatt22-Nov-01 22:29
Jon Hulatt22-Nov-01 22:29 
GeneralRe: Sorting the CStringArray Pin
Tili23-Nov-01 7:23
Tili23-Nov-01 7:23 
GeneralRe: Sorting the CStringArray Pin
Christian Graus23-Nov-01 10:21
protectorChristian Graus23-Nov-01 10:21 
GeneralRe: Sorting the CStringArray Pin
Alvaro Mendez23-Nov-01 11:53
Alvaro Mendez23-Nov-01 11:53 
GeneralCDialog Return Value Pin
Matt Newman22-Nov-01 11:53
Matt Newman22-Nov-01 11:53 
GeneralRe: CDialog Return Value Pin
Christian Graus22-Nov-01 12:11
protectorChristian Graus22-Nov-01 12:11 
GeneralRe: CDialog Return Value Pin
Matt Newman22-Nov-01 12:15
Matt Newman22-Nov-01 12:15 
GeneralComparing the contents of DC's Pin
Member 2362222-Nov-01 11:29
Member 2362222-Nov-01 11:29 
GeneralRe: Comparing the contents of DC's Pin
Christian Graus22-Nov-01 12:13
protectorChristian Graus22-Nov-01 12:13 
GeneralRe: Comparing the contents of DC's Pin
Member 2362222-Nov-01 18:23
Member 2362222-Nov-01 18:23 
GeneralRe: Comparing the contents of DC's Pin
Christian Graus22-Nov-01 19:25
protectorChristian Graus22-Nov-01 19:25 
GeneralDisabled 256-color toolbar buttons Pin
Erik Hammar22-Nov-01 11:06
Erik Hammar22-Nov-01 11:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.