Solved

Urgent and hopefully easy BMP

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
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 how to clear a vector as well as how to detect empty vectors in C++.

776 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