Solved

Urgent and hopefully easy BMP

Posted on 2003-11-06
4
332 Views
Last Modified: 2010-04-01

I am trying to display a BMP using the following in an onpaint event:

            CDC *LogoDC, LogoMemDC;
            CBitmap* OldBMP;
            CBitmap LogoBitmap;
            BITMAP BMPObject;

            LogoDC = m_CLogo.GetDC();
            LogoBitmap.LoadBitmap(IDB_BITMAP1);
            LogoBitmap.GetObject( sizeof(BITMAP), &BMPObject);
            LogoMemDC.CreateCompatibleDC(LogoDC);
            OldBMP = LogoMemDC.SelectObject(&LogoBitmap);
            LogoDC->BitBlt(0, 0, BMPObject.bmWidth, BMPObject.bmHeight, &LogoMemDC, 0,0, SRCCOPY );
            LogoMemDC.SelectObject(OldBMP);

Problem is I only get about 256 colours and need proper resolution - 16 bit I think it is.

How do I do this?!

Thanks a lot

James.
0
Comment
Question by:J_Seaman
[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
  • 2
4 Comments
 
LVL 13

Expert Comment

by:SteH
ID: 9694788
Have you tried using LoadImage instead of LoadBitmap?

The other thing: Normally I would load the bitmap at another place into a variable and only display it inside the onpaint handler. It might depend on where the bitmap comes from and if it changes often but here it seems to be a resource.
0
 

Author Comment

by:J_Seaman
ID: 9694880
Any chance of some code, really busy at the moment and that's n issue which is considered a bonus. If so you can have the points and a very big thankyou. Already determined the problem is due to the internal BMP stuff being stored in 256 colour.
0
 
LVL 13

Accepted Solution

by:
SteH earned 25 total points
ID: 9694952
I use a dialog where I have bitmap displayed in a static control which has a control member var named c_csPic1. To change the bitmap I use the following code:

        hOld = c_csPic1.SetBitmap (hBitmap);
        if (hOld != NULL) {
            ::DeleteObject (hOld);
        }

hBitmap could be genrated using LoadImage (...). The bitmap is then automatically drawn in the OnPaint handler of the static control.
0
 

Author Comment

by:J_Seaman
ID: 9695239
Not had a chance to test it yet but thanks a lot - I trust ya!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

735 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