Solved

SetBitmapBits with 32 bit color DIB in non true color system

Posted on 1998-08-23
2
387 Views
Last Modified: 2013-12-03
Dear experts

I'm using VC++5.0.
I'd like to SetBitmapBits which is created with CreateCompatibleBitmap with 32 bit color DIB which I drew.
So, I tried with CBitmap::SetBitmapBits().
It works well in 32 bit color VGA.
But it makes abnormal display in NON 32 bit color VGA.
Can anyone let me know how to load 32 bit color DIB to a bitmap regardless of system color ? i.e. work in any color bit VGA.

Any comments will be appreciated.
0
Comment
Question by:okg
2 Comments
 
LVL 14

Accepted Solution

by:
AlexVirochovsky earned 200 total points
Comment Utility
I work with Borland C++(OWL), but i think,
 that is same problem: Palette!
 You must set you palette to Context.
 Code must be something as:
 //
    TPalette *tPalette;
 //  define palette for case read
    if (read)
      {
      TDib *tDib = new TDib("file.bmp");
      tPalette =  new TPalette(*tDib);
      }
    else             //or make this manually
     {
         PALETTEENTY Palette;
         HDC hdc = GetDC(NULL);
         GetSystemPaletteEntries(hdc,0,256,Palette);
         ReleaseDC(NULL, hdc);
         tPalette = new TPalette(Palette, 256);
     }
//use palette
  TBitmap *tBitmap = Window->FindBitmap();//make bitmap
  mdc = CreateCompatibleDC(hdc);
  TMemoryDC  *mdc = (TMemoryDC *)CreateCompatibleDC(dc);
  HPALETTE hOldPal1 = SelectPalette(*mdc, tPalette,NULL);
  RealizePalette(*mdc);
                        //select bitmap
  mdc->SelectObject(*tBitmap);
                        //display bitmap
  BitBlt(dc, 0, 0, nMaxx, nMaxy,mdc, 0,0,SRCCOPY);
// if this palette(Standart or bitmap's) not availible
// for you Display, you can use Nearest color, as
  COLORREF lCol = GetPixel(dc,j + nXStart, nY - i-1 + nYStart);
                              //nearest color of Palette
  BYTE nTest =      GetNearestPaletteIndex(hPal, lCol);

//More information about palette you can read in Windows
//Help or in Books, as(for example):
// Eric R.Lyons: Black Art of Windows Game Programming

0
 

Author Comment

by:okg
Comment Utility
What I want is SetBitmapBits or Create Bitmap with 32bit color DIB. OF course, CBitmap is compatible with DC (non-32bit VGA).
 
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now