Link to home
Start Free TrialLog in
Avatar of marakr
marakr

asked on

Problems with bitmap and palette

Hello,
I'm developing an application using MSVC++ 4.0 and MFC.  There should appear a picture when I run the application during some seconds.  I've scanned two pictures: one of 16 colors and other one of 256 colors for each display configuration.  
The code on the OnPaint routine is:
      CPaintDC dc(this);
      // get information about video mode
      int i, j, k;
      i = dc.GetDeviceCaps(BITSPIXEL);
      j = dc.GetDeviceCaps(PLANES);
      k = dc.GetDeviceCaps(NUMCOLORS);

      UINT resource;
      //deletes the resource used to initialize the CBitmap object
      m_bitmap.DeleteObject( );
      if ( (i==1) && (j==4) && (k==16) )
            resource = IDB_SPLASH16;      // 16 colors
      else
            resource = IDB_SPLASH;            // 256+ colors

      if (!m_bitmap.LoadBitmap(resource))
            return;

      CDC dcImage;
      if (!dcImage.CreateCompatibleDC(&dc))
            return;

      BITMAP bm;
      m_bitmap.GetBitmap(&bm);

      // Paint the image.
      CBitmap* pOldBitmap = dcImage.SelectObject(&m_bitmap);
      dc.BitBlt(0, 0, bm.bmWidth, bm.bmHeight, &dcImage, 0, 0, SRCCOPY);
      dcImage.SelectObject(pOldBitmap);

I'm having problems with the picture shown.  The same picture that I visualize in the Photo Paint software looks different that when I visualize it as an open picture (it seems to loose colors).  I don't know if I should initialize the palette or change its order.  Is there any special configuration for the palette in order to make it work?  Anyway, is it a problem with the palette?  Else, is it an MFC problem or a graphical problem?
Thanks.
ASKER CERTIFIED SOLUTION
Avatar of snoegler
snoegler

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial