Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

SetBitmapBits with 32 bit color DIB in non true color system

Posted on 1998-08-23
2
Medium Priority
?
428 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 14

Accepted Solution

by:
AlexVirochovsky earned 200 total points
ID: 1413819
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
ID: 1413820
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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever found yourself doing a repetitive action with the mouse and keyboard, and if you have even a little programming experience, there is a good chance that you can use a text editor to whip together a sort of macro to automate the proce…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
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…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

618 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