|
-
July 7th, 2012, 02:28 PM
#7
Re: How to get an file-loaded bitmap to fit a static image container using StretchBlt
May I ask a couple of very basic questions?
Q: When one uses a 'CreateCompatible.. DC or Bitmap function, I understand that the the device context struct of the object created will be 'compatible' with that of the HDC input parameter. But when loading a bitmap from a file, if one only has the handle (HBITMAP), what is the 'compatible' DC reference to use since the newly loaded bitmap handle has no DC initially associated with it. Since the newly loaded bitmap is to be set into the existing interface, it should presumably have a compatible DC associated with it, but that is just the DC of the interface image container, so why do I need a separate DC for it. Why not just get the interface image container DC and use that for both?
Q: What is the precise meaning of 'compatible' in the above context? This sounds as though the newly created DC is not necessarily 'identical' with the input DC, but rather only 'compatible'. I would like a clear explanation of what is meant here by 'compatible'.
Q: Getting the size of the newly loaded bitmap appears to be essential to using StretchBlt to fit the bitmap into the interface image container, the size of which is obviously known. As far as mixing MFC and GDI stuff, while it may not be pretty, I couldn't find any pure way to accomplish basic things like getting the size of the newly loaded bitmap. For example, the following code works:
Code:
BITMAP bm;
::GetObject( hBmp, sizeof( bm ), &bm );
int bmWidth = bm.bmWidth;
int bmHeight = bm.bmHeight;
but I could not find how to use the MFC CBitmap or CImage classes to do this. I spent alot of time hunting for code examples but none found worked for me. As a pragmatist, I feel whatever works is OK with me. But I agree with your comment in this regard. The reason is that the internet is full of code that is mostly GDI and much of which doesnt work.
Last edited by Mike Pliam; July 7th, 2012 at 02:33 PM.
mpliam
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|