Solved

Urgent and hopefully easy BMP

Posted on 2003-11-06
4
324 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
  • 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
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…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

762 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now