?
Solved

altering bitmap before display

Posted on 2002-04-10
7
Medium Priority
?
354 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
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
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 
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

Get quick recovery of individual SharePoint items

Free tool – Veeam Explorer for Microsoft SharePoint, enables fast, easy restores of SharePoint sites, documents, libraries and lists — all with no agents to manage and no additional licenses to buy.

Question has a verified solution.

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

This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
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…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

850 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