?
Solved

altering bitmap before display

Posted on 2002-04-10
7
Medium Priority
?
344 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
NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

 
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

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

Question has a verified solution.

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

This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
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…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

762 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