Re: MFC CPicture, CBitmap and CDC programming question
From: Louis Solomon [SteelBytes] (louis_at_steelbytes.spam-is-bad.com)
Date: 03/01/04
- Next message: Marc: "Re: Outputting text to a bitmap"
- Previous message: Louis Solomon [SteelBytes]: "Re: How does BitBlt convert color formats?"
- Next in thread: Andy Mortimer [MS]: "Re: MFC CPicture, CBitmap and CDC programming question"
- Reply: Andy Mortimer [MS]: "Re: MFC CPicture, CBitmap and CDC programming question"
- Maybe reply: Todd Bandrowsky: "Re: MFC CPicture, CBitmap and CDC programming question"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 1 Mar 2004 13:33:25 +1100
explore DIBSections ...
they are an easy an practical way to dirrectly manipulate and then draw
images
...
load the source image into a dib section (CreateDIBSection) in a memory dc
(created with CreateCompatibleDC), then directly manipulate the pixels using
the pointer returned by CreateDIBSection, then BitBlt it during a wm_paint
to the screen
-- Louis Solomon www.steelbytes.com "Adam Messer" <amesser@mchsi.com> wrote in message news:8pe040lebddtgo4n8v57tcbh22efvj61ds@4ax.com... > Hello all, > > I am a fairly new Windows programmer. I am writing a program > to remote control some A/V equipment. The way I decided to implement > my interface is to use a BMP image of a universal remote control. I am > using Visual Studio 6 with C++ and MFC in a dialog application. > > I have gone through the trouble to get the coordinates of > every button on the remote control. By capturing the left button click > message I am able to determine which button was under the mouse when > it is clicked. I want visual feedback when a button is clicked, and > here is what I am doing to get it. > > 1) I find all the 'fairly white' pixels within the button region and > paint them a bright yellow to make it look like the button lights when > clicked. > > 1a) Many of my buttons are not rectangular and there is black writing > on each button. That is why I can't simply paint all pixels in my > rectangles. > > 2) After about 1/2 second I change the color of the yellow pixels back > to a 'standard white' color. > > 3) I am using the SetPixelV method to set the colors of the buttons. > > > When I say 'fairly white', I mean all pixels who's RGB values fall > into a range that look white. SInce I took a picture of my remote > control instead of drawing it within my application, the colors vary a > lot, so I can't simply do a flood fill. The color of the buttons and > the surrounding areas are not consistent. > > This is obviously a very inefficient way to accomplish my task. There > is one button called 'light' on my remote. When I click on it the > whole keypad is supposed to light up for a few seconds. It takes so > long to write all the pixels, one by one, that it looks like a yellow > wave slowly washes across my remote control. > > The way I see it I have two choices. 1) I can go into some sort of > graphics program (i.e. Photoshop) and 'fix up' the remote control > image file. 2) I can set all 'fairly white' pixels to a consistent > white when my application initializes. I can then use a flood fill > when a button is clicked which should be much faster. > > Here is my problem. The method I am using to write directly into the > device context doesn't work if my application gets re-painted. All the > colors revert back to their defaults. If some kind sole out there > could clue me in on a way to change the colors that would remain > changed after a re-paint, I would be forever grateful! > > Please forgive me if my terminology isn't very good, but I am an OS > programmer, not a UI or graphics programmer. These Win32 and MFC > concepts and terms are fairly new to me. > > TIA, > Adam Messer > amesser39@hotmail.com >
- Next message: Marc: "Re: Outputting text to a bitmap"
- Previous message: Louis Solomon [SteelBytes]: "Re: How does BitBlt convert color formats?"
- Next in thread: Andy Mortimer [MS]: "Re: MFC CPicture, CBitmap and CDC programming question"
- Reply: Andy Mortimer [MS]: "Re: MFC CPicture, CBitmap and CDC programming question"
- Maybe reply: Todd Bandrowsky: "Re: MFC CPicture, CBitmap and CDC programming question"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|