Bitmap quick question

Hello Group,

I have a bitmap composed of only two colors: black and 
white. I want to replace the white color with red. Here's 
how I'm trying to do it without success:

--------------------
COLORMAP colorMap;
CBitmap  bitmap;

colorMap.from = RGB(255, 255, 255);
colorMap.to = RGB(255, 0, 0);

// Load the bitmap but map the background to the 
appropriate color
VERIFY(bitmap.LoadMappedBitmap(IDB_MY_BITMAP, 0, 
&colorMap, 1));

// Set the mapped bitmap in the static control
m_staticBitmap.SetBitmap(HBITMAP(m_bitmap));
---------------------

Can someone please tell me why this is not working, 
knowing that the static control is created with the 
bitamp type?

Thanks in advance,
Geo

0
ckarakiro (63)
10/6/2003 6:19:07 PM
vc.mfc 33608 articles. 0 followers. Follow

4 Replies
780 Views

Similar Articles

[PageSpeed] 29

"Geo" <ckarakiro@hotmail.com> wrote in message
news:2360401c38c36$54a5f1f0$a601280a@phx.gbl...
> Hello Group,
>
> I have a bitmap composed of only two colors: black and
> white. I want to replace the white color with red. Here's
> how I'm trying to do it without success:
>
> --------------------
> COLORMAP colorMap;
> CBitmap  bitmap;
>
> colorMap.from = RGB(255, 255, 255);
> colorMap.to = RGB(255, 0, 0);
>
> // Load the bitmap but map the background to the
> appropriate color
> VERIFY(bitmap.LoadMappedBitmap(IDB_MY_BITMAP, 0,
> &colorMap, 1));
>
> // Set the mapped bitmap in the static control
> m_staticBitmap.SetBitmap(HBITMAP(m_bitmap));
> ---------------------
>
> Can someone please tell me why this is not working,
> knowing that the static control is created with the
> bitamp type?

I've never used LoadMappedBitmap, but what you've got above looks ok. What I
think the problem is is that your CBitmap is function local and is being
destroyed almost as soon as you give it over to the CStatic. Try obtaining
your HBITMAP by using CBitmap::Detach.
-- 
Jeff Partch [VC++ MVP]


0
jeffp (1711)
10/6/2003 6:38:51 PM
Jeff,

Thank you for your response. If the CBitmap is destroyed 
the bitmap image wouldn't display in the CStatic, which 
is the case. I can see the bitmap image when I run the 
program so the CBitmap object is not destroyed.

Anyway, I tried your suggestion and added m_bitmap.Detach
() and it still didn't work.

If you have other suggestions please tell me.

Thanks again,
Geo

>
>I've never used LoadMappedBitmap, but what you've got 
above looks ok. What I
>think the problem is is that your CBitmap is function 
local and is being
>destroyed almost as soon as you give it over to the 
CStatic. Try obtaining
>your HBITMAP by using CBitmap::Detach.
>-- 
>Jeff Partch [VC++ MVP]
>
>
>.
>
0
ckarakiro (63)
10/6/2003 8:05:36 PM
"Geo" <ckarakiro@hotmail.com> wrote in message
news:106101c38c45$34f09540$a001280a@phx.gbl...
> Jeff,
>
> Thank you for your response. If the CBitmap is destroyed
> the bitmap image wouldn't display in the CStatic, which
> is the case. I can see the bitmap image when I run the
> program so the CBitmap object is not destroyed.

Oh, I'm sorry -- I thought that non-display *was* the problem. :)

>
> If you have other suggestions please tell me.

So when you said earlier that it was a black & white bitmap, is that the
same thing as monochrome? If so, do monochrome bitmaps have a colortable? If
they don't, would this kb article apply?...

http://support.microsoft.com/default.aspx?scid=%2Fservicedesks%2Fbin%2Fkbsearch.asp%3FArticle%3D329006

-- 
Jeff Partch [VC++ MVP]


0
jeffp (1711)
10/6/2003 8:50:20 PM
Jeff,

Thanks a lot. Yes indeed, the bitmap I'm using has more
than 256 colors. I've tried my code with a 256-bit color 
bitmap and now it works.

Thanks again,
Geo

>-----Original Message-----
>"Geo" <ckarakiro@hotmail.com> wrote in message
>news:106101c38c45$34f09540$a001280a@phx.gbl...
>> Jeff,
>>
>> Thank you for your response. If the CBitmap is 
destroyed
>> the bitmap image wouldn't display in the CStatic, which
>> is the case. I can see the bitmap image when I run the
>> program so the CBitmap object is not destroyed.
>
>Oh, I'm sorry -- I thought that non-display *was* the 
problem. :)
>
>>
>> If you have other suggestions please tell me.
>
>So when you said earlier that it was a black & white 
bitmap, is that the
>same thing as monochrome? If so, do monochrome bitmaps 
have a colortable? If
>they don't, would this kb article apply?...
>
>http://support.microsoft.com/default.aspx?scid=%
2Fservicedesks%2Fbin%2Fkbsearch.asp%3FArticle%3D329006
>
>-- 
>Jeff Partch [VC++ MVP]
>
>
>.
>
0
ckarakiro (63)
10/6/2003 9:17:16 PM
Reply:

Similar Artilces:

ListView question #3
Hi, I've searched on internet to find some tips how to detect when a ListView: - draw the headers (if it is header, and for which column) - draw the rows (which row / index) - draw items (to which column belongs the drawed item) i've read some articles about subclassing WndProc. I've checked that way but it's huge amount of time spent and result is really poor :-( i would like to know if there is not another way...a little bit easier Topics behind that are : - allow different types of items (not only text, but also progress bars, spinboxes,..) - Customize the header (imag...

Bitmap
hi, I display a bitmap on my sdi client area and I want to draw on the bitmap in transparent mode so the area I draw above the bitmap only will change the bitmap pixel color so I can still see the bitmap ant the line I draw above it, How can I do that??? Thanks Not sure if I understand your question, but if you are trying to draw on top of your image simply do the following. In OnDraw(...) //First Draw your bitmap pDC->Bltbit(..) //Then Draw your line code or other GDI functions pDC->MoveTo(...) pDC->LineTo(...) Every time OnDraw(...) gets called it will refresh your image an...

Item discount question
I'm running a promotion where if the customer spends more than $20 they get a free lb of ground beef or a free lb of chicken breast. The problem is the packages are often more than a pound. Is there a way to take $4.99 off of the price of ground beef if I scan a code (or coupon)? For example, the customer spends more than $20. They have a package of ground beef that is 1.21 lbs. with a price of $5.93 (4.99 a pound). I want the system to calculate the price to 0.94 cents. All input is greatly appreciated! This is a multi-part message in MIME format. ------=_NextPart_000_0DA7_0...

Question about enumerate threads of process
Hi all I want to enumerate threads of a process in Winnt4. I know that Toolhelper lib can't work at Nt. someone tell me Psapi.dll also do the same thing. I check it at msdn, but found no function can work. can anybody tell me, how can i do that with psapi.dll. Thanks advance. sincerely. Take a look at the following KB article Q175030 - HOWTO: Enumerate Applications in Win32 -- Cheers Check Abdoul [ VC++ MVP ] ----------------------------------- "LiPei" <zxblp@163.com> wrote in message news:O3VW8T4bDHA.2940@TK2MSFTNGP11.phx.gbl... > Hi all > &g...

More of a backup question
Hi, I am doing some DR testing and have a question regarding backups using NetBackup. I assume someone else out there must be using it as well. I did a full backup of one of my storage groups and then did a mail store restore of a small store. Netbackup seemed to do everything correctly but I'm a bit confused by it's output. The file it gave me as my "restore" is a single file named exactly what my mail store is named and is the same size as the ..edb and .stm file combined. I assume all the data for the mail store is in this file (no extension / file type is ap...

Userproperty question
If I don't want to process certain emails is an Inbox folder, is one method of doing so while scanning the folder's emails is to check the value of a userproperty? For example, if the property doesn't exist, process it and add the userproperty else skip? That's one possible way. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007. Reminder Manager, Extended Reminders, Attachment Options. http://www.slovaktech.com/products.htm "Salad" <salad@oilandvinegar.com> wrote in message news:MY...

device driver question!
Hi: When device driver was activated by the API "ActivateDeviceEx", the DllEntry was called or not? I had added a "debug msg" statement in the DllEntry try to find out the Device driver DLL was loaded or not, but this mark (DEBUGMSG/ RETAILMSG) was never shown it!. However, xxx_Iint's debug message was shown, and same as xxx_Open! So How this DLL was loaded? why DllEntry is not entry point? Thanks Lu On Jun 7, 2:54=A0pm, ydlu <yudian...@gmail.com> wrote: > When device driver was activated by the API "ActivateDeviceEx", the > DllE...

bitmaps
hi, i actually want to display the bitmap image in picture box and does not wants its scope to be destroyed.i want to do this only in vc++6 and does not want to do with any third party tools.how can i do it? thanks a lot to Ajay kalra for a very great support given to this group. thanks in advance susi. CString szFilename ("D:\\abc2.bmp"); HBITMAP hBmp = (HBITMAP)::LoadImage( NULL, szFilename, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE|LR_CREATEDIBSECTION ); //pointer to a static...

Exchange installation question
Greetings, We are considering going to Exchange from Groupwise. We currently have AD on a Windows 2000 infrastructure. My question is if we installed Exchange 2003 on windows 2000, can anyone share their thoughts on later upgrading the os to 2003? It would probably make sense to upgrade the network now, then install exchange, but we're in a crunch at the moment and need to get this e-mail project going. Thanks! Chris Starting afresh with a new OS install is always preferable, but not always possible. Can upgrade OS later if that's the case, the only issue is unavailability of cer...

Updating Money Deluxe 2007 question
Will Microsoft keep the Money updates available permanently, as they do with updates for old operating systems like Windows 98? The reason I ask is that, at least in my experience, Money updates have never been a manually downloadable file, but rather once you install the program, Money calls out on the Internet and looks for updates. If Microsoft doesn't keep the updates online, is there any way to download the update files now for permanent keeping? I did a test. I installed Money 2007 Deluxe on my Virtual PC. As soon as I went into the program after installation, it updated ...

Toolbar button without bitmap only text
Hello All I want to display only text in the tool bar buttons without bitmap how shall i do that Thanks in advace Faisal Try the following to your toolbar object: SendMessage(TB_SETIMAGELIST, 0, NULL); -- Ajay Kalra [MVP - VC++] ajaykalra@yahoo.com "Faisal Masoor" <fmansoor@softpak.com> wrote in message news:uOstAT7TEHA.2464@TK2MSFTNGP10.phx.gbl... > Hello All > > I want to display only text in the tool bar buttons without bitmap how shall > i do that > > Thanks in advace > Faisal > > Thanks Ajay But it didn't worked any more ideas Fa...

2 questions #2
hello, Here is my first question,money plus keeps downloading my statement but will only use 1 payee.How do i fix this. Question 2 Money has decided that it will now import my statement for my checking account and put it into my savings account.How do i fix this I am using money plus deluxe version 17.0.120.1415 purchased in the us and i have been using this program for almost a year.Any help would be appreciated In microsoft.public.money, sondra99999 wrote: >hello, > Here is my first question,money plus keeps downloading my statement but >will only use 1 payee.How ...

e-mail distribution group question
Here's the situation: User A's incoming e-mail are delivered to user A and user B. User B's incoming e-mails are also delivered to user C. BUT user C does not want user A's e-mails... At the moment User C gets both user A and B's e-mails Is there a way I can set this up? Many thanks M Hi, Do they need to receieve copies of others emails in their own mailbox? You could give permissions to read the other users mailboxes. Then you of your clients would just need to add them as an additional mailbox in Outlook. The other option is to create a server side rule in outl...

should i copy the bitmap header info when i wanna copy the bitmap data to global memory
now what i can get is the CBitmap, i wanna save it to global memory block ,so i can resuse it elsewhere, how could i achieve this? should i copy the bitmapheadinfo,and how??i can only get width, height info from CBitmap class Do you need the information in the bitmap header? joe On 6 Sep 2006 01:34:56 -0700, "thinktwice" <memorialday@gmail.com> wrote: >now what i can get is the CBitmap, i wanna save it to global memory >block ,so i can resuse it elsewhere, how could i achieve this? should i >copy the bitmapheadinfo,and how??i can only get width, height info fro...

bitmap caret
hi does anybody have an experience working with bitmapped window caret? there is a little problem. take a look at this code please. void CcntrlDlg::OnEnSetfocusEdit1() { CBitmap mbmp; mbmp.LoadBitmap(IDB_BITMAP1); mEdit.CreateCaret(&mbmp); mEdit.ShowCaret(); } the problem is it doesn't work!. system actually draws the bitmapped caret in a right position, but it isn't flashing. it works quite different from what we have when using solid or grey caret(created by CreateSolidCaret and CreateGrayCaret functions ). these two look just how they have to look with happy flashing and...

Resizing bitmap without losing quality (or a method to redraw the bitmap)
I have a 2d real time oscilloscope (a bitmap created with CDC CreateCompatibleDc and so on...). I need to resize to a bigger image and back to original size when the user click one of two button (like a zoom). I have tried with StretchBlt, but the image is very poor in quality. I can create a new bitmap of the desired size for perfect quality, but in this way a lose the graph that is displayed on first bitmap. Is it possible to resize the bitmap wihout losing too much or do something that allow me not to lose the 2d graph drawed on it? roby.schwarz@libero.it wrote: > I have a 2d real tim...

Outlook 200, outlook today question
I'm using OL 2000 w/ Win xp, all updates. I just replaced my old crt with a flat screen HD monitor. A problem came up with outlook today. On the calendar, when an item goes past due time, it goes gray. On the old crt it was still readable, on the new flat screen it's not - it's too faint. I can't find anyway of adjusting the past time calendar items to be darker either on the monitor or in OL. Any ideas? Thanks That's controlled by embedded CSS and can't be changed easily. Which style do you use? I thought the default Outlook Today style makes it look a tin...

Excel rounding question
I am working on a worksheet where I am doing orders, if I have an order of anything over a whole number I need to round it up to 25 more. So 26 would need to be 50, etc. If it's 25 I need it to be 25 or if its 12 I need for it to be 25, 51 would need to be 75, etc. How do I go about doing this? =ceiling(a1,25) "Mac" <Mac@discussions.microsoft.com> wrote in message news:34F60A5E-61BC-4806-986C-1B019AEBBB40@microsoft.com... >I am working on a worksheet where I am doing orders, if I have an order of > anything over a whole number I need to round it up to 25 more. S...

bitmaps
how do i put a transparent bitmap, such as a sprite, on the screen If the bitmap has a palette then you can use LoadMappedBitmap to replace any palette colour with any colour of your choosing but loading the bitmap frequently to re-map would be painfully expensive and, besides it would only work for a single, solid background colour. While that works well for putting transparency on bitmaps for a dialog box I think you'll have to do the logic yourself for a transparent bitmap on a background with multiple colours. If you think about doing it is quite easy. Create a monochrome mask of ...

Question: Remove Credits from a receivables trial balance
From one of our users... How can you remove credits from a receivables trial balance? (I tried and a debit memo and was not given an option of applying it to a specific credit. Now I have two lines, one of my original credit and one for the debit memo. The balance is 0, but both line items show up.) Thanks, Morgan Did the user go to the Apply Sales Documents menu option and apply the credit to the debit? I tested this and it worked fine. "Morgan" <abcd@senditon.com> wrote in message news:eoq2jJ7MFHA.3512@TK2MSFTNGP15.phx.gbl... > From one of our users... > >...

IncrediMail Question
Not surprisingly, there does not appear to be an IncrediMail newsgroup. I'm hopeful to get some guidance here. I have a Dell Dimension 8400, with WinXP and the IncrediMail application. I am unable to turn the computer on due to a blown capacitor. However, I believe the hard drive is in good shape for me to recover data. Has anyone here had any success with restoring IncrediMail? I'm confident I can locate the data files, but will they import back into a new installation of IncrediMail on a new computer? I don't even want to install it on the new computer, but I figured that ...

another newbie question
Publisher 2002. I have composed a price ticket Portrait orientation in A4 page size. I want to print * so that there are 2 per page (as A4 Landscape side by side) * Canon iP 4000 kgm While STILL in a state of withdrawal waiting for components to arrive to repair his dead laptop, Ed notices a message from "kgm" <justins@TAKESOCKSOFFsidcliffe.wanadoo.co.uk>. > I have composed a price ticket Portrait orientation in A4 page size. > I want to print * so that there are 2 per page (as A4 Landscape side by > side) > * Canon iP 4000 If your printer driver supports it...

easy questions
Rich, Just a quick question.......i need a microsoft office core certifaction. More specfially i need to learn (and certified in) Excel Xp, Word Xp, and Outlook Xp. I have been to this newsgroup before and haven't been to find what i need. Can anyone suggest particular book titles I can read to pass such a exam. Also does any know where i can write a mock exam to evalute my skills. Any other comments on this would also be welcomed. I know their is the microsoft tutorial cd (or office xp step by step)included in Office Xp. Does anyone believe those tuturial alone would...

SMTP Connector question #2
Hi Had a single E2K3 Sp2 server earlier, and have now added a FE. SMTP connector moved from BE to FE. System enabled with ActiveSync,OWA & Https/Rpc. Everything works perfect. When I looked at "Queues" on BE there is still an SMTP Connector with a strange name: "SMTP Connector -_a46bf5ed9709644683af8319dab8789b_S (SMTP Connector)" -SMTP-Default SMTP Virtual Server-Ready. What's this? Can it be removed? How? Jordan ...

Pivot Table Sub-Total question
I have a pivot table with the following fields in it: Item Number (i.e., CH-1, CH-2, etc.) Floor (LL, 1, 2, 3, 4, etc.) Unit cost (dollar amount) Quantity (numeric value) Extended cost (Quantity * Unit Cost) It's based on a large spreadsheet with all this info and more. I want my chart to reflect each item number, quantity listed by floor, and then a sub-total for each item number (Quantity and Extended Cost). For example, on floor 1, I have 5 CH-1, on floor 2 I have 6 of them. I want a subtotal to say that I have a total of 11 on all floors. I also want the extended cost per it...