Solved

Urgent and hopefully easy BMP

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Building cUrl in Windows v7.43.0 4 36
Fast access to array, using indexes, smart iterative search 2 118
C++ mouse_event mouse look 7 97
I could not set window to top 4 21
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…
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. …
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++.

831 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