Solved

SetBitmapBits with 32 bit color DIB in non true color system

Posted on 1998-08-23
2
397 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
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

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

825 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