RE: Completely erasing memory DC



The DC doesn't have contents as such. It does have a bitmap (or drawing
surface) selected into it.

Typically you'll (1) create a memory dc,
(2) create a bitmap,
(3) select it into the dc,
(4) do whatever drawing you need,
(5) blit to your output dc,
(6) reselect the original bitmap (which was a 1x1 monochrome one),
(7) delete the bitmap and
(8) delete the dc.
If you want a 'clean' picture, you can use redo steps 2-7 without recreating
the DCs,
or do as Kellie suggests, and wipe it that way. An alternative is ExtTextOut
with ETO_OPAQUE flag set, and an empty string, which will fill with the
current background colour.

If the PNG is a 32bit bpp with transparency, you might want to work with
AlphaBlend or similar stuff. I do something like that with an MP3 player I
have, which fades in/out the cover art for 'now playing' track.
--
Steve S


"David Ching" wrote:

Hello, is there a way to completely erase the image within a memory device
context, such that the device context becomes empty, just like when it was
first created?

The reason I ask is that I want to replace the contents of a memory device
context with a translucent picture I loaded from a .png file. Becomes the
picture contains areas that are not 100% opaque, painting this picture into
the device context does not erase what was there before. To the extent the
picture is transparent, the old contents of the device context remain.

I intend to use the memory device context in a call to
UpdateLayeredWindow(), so the contents need to be the translucent picture
(and ONLY the translucent picture) I want to show on the screen.

The only way I've gotten to work is by starting with a new (and empty)
memory DC each time. But this is wasteful; I want to reuse the old one. So
is there a way to clear the old memory DC of its previous contents?

Thanks,
David
http://www.dcsoft.com



.



Relevant Pages

  • Re: One Thing I Noticed - Line Too Long
    ... > in memory plus a further bitmap, or "extra space on the Form wasting ... Turning on autoredraw keeps a copy of what's on the screen in memory. ... are drawing a bitmap to the screen and have the bitmap in memory then you ... > Picture Box and one Command Button. ...
    (microsoft.public.vb.general.discussion)
  • Re: One Thing I Noticed - Line Too Long
    ... > that creating a VB Autoredraw picture box automatically creates a separate ... > because you said it uses too much memory because it creates two bitmaps. ... > create an otherwise non existent bitmap in video card memory! ...
    (microsoft.public.vb.general.discussion)
  • Re: Graph Plotting - Mike
    ... the main picture box?". ... creates contains a bitmap and all of the details as to how Windows is to ... The device context that it creates is compatible with the device you ... in memory that contains the 'attribute'. ...
    (comp.lang.basic.visual.misc)
  • Re: Graph Plotting - Mike
    ... This was most probably because we were using both Autoredraw and also had a picture in the Picture property of the box, so I thought that we might as well use a different method altogether (which was to draw your graph into a memory device context and refresh the visible display with that whenever we felt the need to). ... We don't necessarily have to go to all the trouble of creating a memory device context and memory bitmap and all that stuff if we don't wish to do so. ...
    (comp.lang.basic.visual.misc)
  • Re: Graph Plotting - Mike
    ... it with Autoredraw set to True and also with a picture loaded into its ... Then we created a device context using the CreatCompatibleDC API. ... draw into that bitmap or when we want to "blit" it somewhere (pens, brushes, ... machines that are currenty running at full colour depth (which is most ...
    (comp.lang.basic.visual.misc)

Loading