[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

altering bitmap before display

Posted on 2002-04-10
7
Medium Priority
?
352 Views
Last Modified: 2013-12-03
I load a bitmap resource
   hBitmap = LoadBitmap(hInst,MAKEINTRESOURCE(MY_BITMAP));
and would like to edit it before displaying it in a dialog box static picture control
     SendDlgItemMessage(hDlg,MY_PICTURE_CONTROL,STM_SETIMAGE,(WPARAM)IMAGE_BITMAP,(LPARAM)hBitmap);

I have tried creating a DC, selecting the bitmap into it, and doing some drawing, but the unchanged bitmap is always displayed in the control.
Thank You
0
Comment
Question by:Ignatz
[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
  • 2
  • +1
7 Comments
 
LVL 22

Expert Comment

by:cookre
ID: 6932641
Doesn't painting to the DC effect only the image as displayed on that device and not the original bitmap selected into it?  And if you want to save the changes you have to create a new bitmap from the DC?
0
 
LVL 23

Expert Comment

by:chensu
ID: 6932726
It should work. Show your code please.
0
 

Author Comment

by:Ignatz
ID: 6933725
hBitmap = LoadBitmap(hInst,MAKEINTRESOURCE(MY_BITMAP));
GetObject(hBitmap,sizeof(BITMAP),&bmp);
hdcMem = CreateDC("DISPLAY","DISPLAY",NULL,NULL);
hOldBitmap = (HBITMAP)SelectObject(hdcMem,hBitmap);
rect.left = rect.top = 0;
rect.right = bmp.bmWidth;
rect.bottom = bmp.bmHeight;
hBrush = (HBRUSH)GetStockObject(BLACK_BRUSH);
FillRect(hdcMem,&rect,hBrush);
SendDlgItemMessage(hDlg,COLOR_EXAMPLE,STM_SETIMAGE,(WPARAM)IMAGE_BITMAP,(LPARAM)hBitmap);
SelectObject(hdcMem,hOldBitmap);
0
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 
LVL 1

Accepted Solution

by:
Marsc earned 800 total points
ID: 6934259
Try hMemDC = CreateCompatibleDC (NULL);
I´ve allways used this function.
0
 

Author Comment

by:Ignatz
ID: 6934334
did the trick.
Thanks
0
 
LVL 1

Expert Comment

by:Marsc
ID: 6936819
Well... I am glad to having been helpfull....
Just to complete the answer a little.

NULL Should be another existing HDC
When you use NULL as a parameter, windows assumes the screen as DC.

I guess you was failing at the "SelectObject" line because there was No DC created.....
0
 
LVL 23

Expert Comment

by:chensu
ID: 6937468
Marsc> there was No DC created.....

CreateDC("DISPLAY","DISPLAY",NULL,NULL) creates a DC associated with the actual display device while CreateCompatibleDC(NULL) creates a memory DC, which is what you need.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

656 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