Solved

altering bitmap before display

Posted on 2002-04-10
7
332 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
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 22

Expert Comment

by:cookre
Comment Utility
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
Comment Utility
It should work. Show your code please.
0
 

Author Comment

by:Ignatz
Comment Utility
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 1

Accepted Solution

by:
Marsc earned 200 total points
Comment Utility
Try hMemDC = CreateCompatibleDC (NULL);
I´ve allways used this function.
0
 

Author Comment

by:Ignatz
Comment Utility
did the trick.
Thanks
0
 
LVL 1

Expert Comment

by:Marsc
Comment Utility
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
Comment Utility
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
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 video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

771 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

11 Experts available now in Live!

Get 1:1 Help Now