?
Solved

SetBitmapBits with 32 bit color DIB in non true color system

Posted on 1998-08-23
2
Medium Priority
?
417 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

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
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…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

777 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