Solved

SetBitmapBits with 32 bit color DIB in non true color system

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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Suggested Solutions

zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
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…

733 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