[comp.windows.ms.programmer] animation in Windows?

neves@aristotle.ils.nwu.edu (David Neves) (05/14/91)

We want to do some simple animation in Windows.  If anyone has some
pointers on this I would appreciate them.

One way we are considering is to prepare several bitmapped objects and
bitblt them (using BITBLT) to a complicated bitmapped background.  The
problem as I perceive it is how to specify the part of the bitmap you
want copied to the screen.  For example, lets say you have a donut
picture and want to send it to the screen.  The bitmap of the donut is
rectangular but the object is circular and it has an interior circle
that also must show the background.  Is there some secret transparent
color that one can use to construct the bitmap?  Or?

-thanks, david
--
neves@ils.nwu.edu
Institute for the Learning Sciences, 1890 Maple, Evanston Il 60201

ebergman@isis.cs.du.edu (Eric Bergman-Terrell) (05/15/91)

I've done some rudimentary animation with Windows bitmaps.  I'm not sure
what you're asking for when you say "secret invisible color"...

If you mean can your program construct a bitmap (perhaps a composite of
several bitmaps) that is not visible and then bitblt it to the screen
all at once when it's fully constructed, the answer is yes.

Terrell

neves@aristotle.ils.nwu.edu (David Neves) (05/15/91)

>I've done some rudimentary animation with Windows bitmaps.  I'm not sure
>what you're asking for when you say "secret invisible color"...

The MAC allows you to paint using transparent color.  This color
allows the background to show through.  I am not sure how it is implemented.

I want to do this
  Source bitmap    Destination bitmap     Result

     O               *z*z*z*z            *z*O*z*z
   / X \             *z*z*z*z            */*X*\*z
    / \              *z*z*z*z            *z/z\z*z

I assume that my source bitmap will have all white in the none body
parts and that I would get the following if I did a srccopy.

     O               *z*z*z*z            *  O   z
   / X \             *z*z*z*z            */ X \ z
    / \              *z*z*z*z            * / \  z


--
neves@ils.nwu.edu
Institute for the Learning Sciences, 1890 Maple, Evanston Il 60201

gpsteffl@sunee.waterloo.edu (Glenn Steffler) (05/19/91)

In article <1688@anaxagoras.ils.nwu.edu> neves@aristotle.ils.nwu.edu (David Neves) writes:
>
>We want to do some simple animation in Windows.  If anyone has some
>pointers on this I would appreciate them.

This is a topic which most programmers find difficult in Windows due to
the "uncommon" choice of API for bitmapped video.  An easy way to draw
a particular bitmap to the screen is BitBlt ().  Unfortunately the
Windows graphics primatives provide only a source bitmap device a
destination bitmap device and a SMALL (is that in caps or what?!)
pattern bitmap.  The pattern bitmap determines what parts of the source
will be copied to the destination (hey lets just deal in these terms as
a new developer may not realize the multitudinal useage variety
provided by ROP modes -ed).  Like I said, this pattern bitmap is a
small 8x8 bitmap (actually it's a brush) that is selected before the
drawing operation.

The only way to draw a non rectangular shape is to "erase" the destination
in those areas that are going to be changed, and joining (as opposed
to copying) the source bitmap with the destination bitmap using SRCPAINT
(or whatever...don't have manuals on me, or near me for that matter :-)

There are certain companies (not saying Gold Disk is one of them, and
likewise not denying it...) which could provide an authoring system
(video based in Gold Disks theoretical case) for animations in
Windows.  Anyway I think I should reserve any further...
***<paragraph halted due to big mouth>***

>One way we are considering is to prepare several bitmapped objects and
>bitblt them (using BITBLT) to a complicated bitmapped background.  The
>problem as I perceive it is how to specify the part of the bitmap you
>want copied to the screen.  For example, lets say you have a donut
>picture and want to send it to the screen.  The bitmap of the donut is
>rectangular but the object is circular and it has an interior circle
>that also must show the background.  Is there some secret transparent
>color that one can use to construct the bitmap?  Or?

Quick answer...NO.  Longer answer would ask you to phone those 
nice people at Microsoft and inquire about the Multimedia Toolkit
or Developement Kit for Windows.

>
>-thanks, david
>--
>neves@ils.nwu.edu
>Institute for the Learning Sciences, 1890 Maple, Evanston Il 60201

Take Care!

-- 
Windows Sumo Wrestler                "Bo doesn't know software" - George Brett
  --(Windows 3.0, a combination of modern moodring technology and voodoo)--
"I guess she had a way, of making every night seem bright as day"
`I Don't Believe In Love`   -Queensryche (Oper. Mindcrime)     Glenn Steffler

mcdonald@aries.scs.uiuc.edu (Doug McDonald) (05/19/91)

In article <1991May19.152505.11357@sunee.waterloo.edu> gpsteffl@sunee.waterloo.edu (Glenn Steffler) writes:
>In article <1688@anaxagoras.ils.nwu.edu> neves@aristotle.ils.nwu.edu (David Neves) writes:
>>
>>We want to do some simple animation in Windows.  If anyone has some
>>pointers on this I would appreciate them.
>
>This is a topic which most programmers find difficult in Windows due to
>the "uncommon" choice of API for bitmapped video.  An easy way to draw
>a particular bitmap to the screen is BitBlt ().  Unfortunately the
>Windows graphics primatives provide only a source bitmap device a
>destination bitmap device and a SMALL (is that in caps or what?!)
>pattern bitmap.  The pattern bitmap determines what parts of the source
>will be copied to the destination (hey lets just deal in these terms as
>a new developer may not realize the multitudinal useage variety
>provided by ROP modes -ed).  Like I said, this pattern bitmap is a
>small 8x8 bitmap (actually it's a brush) that is selected before the
>drawing operation.
>

Yep. It is a serious problem. There is really only one way to do
any serious general animation in Windows, so far as I have figured out. 
You have to keep a memory bitmap - of the same type as the screen,
that is, device dependent, and keep your whole image on it. You draw to
it however you please (for moderate speed you use Windows primitives,
for top speed you do it directly yourself, to memory) and keep track of
all the rectangular areas you modify, then you just COPY those areas
to the screen with bitblt.

This of course also has the advantage that repainting the screen if
it gets zapped is trivial.


Doug McDonald

jerry@polygen.uucp (Jerry Shekhel) (05/20/91)

neves@aristotle.ils.nwu.edu (David Neves) writes:
>
>We want to do some simple animation in Windows.  If anyone has some
>pointers on this I would appreciate them.
>
>One way we are considering is to prepare several bitmapped objects and
>bitblt them (using BITBLT) to a complicated bitmapped background.  The
>problem as I perceive it is how to specify the part of the bitmap you
>want copied to the screen.  For example, lets say you have a donut
>picture and want to send it to the screen.  The bitmap of the donut is
>rectangular but the object is circular and it has an interior circle
>that also must show the background.  Is there some secret transparent
>color that one can use to construct the bitmap?  Or?
>

I have written a Windows game which I will be releasing as shareware shortly,
and I had exactly the same problem.  Fortunately, I came up with a solution.

What you want to do is this.  For each bitmap you need to display, you also
create another, called the 'mask'.  The mask is black wherever you want your
bitmap to overlay the background, and white wherever you want the background
to show through.  Now, to display the bitmap, you first BITBLT the mask
in SRCAND mode, and then BITBLT the bitmap in SRCPAINT mode.  Of course, if
you then want to move the bitmap, you'll have to restore the background bits
first.

Hope this helped!

>
>-thanks, david
>
--
+-------------------+----------------------+---------------------------------+
| JERRY J. SHEKHEL  | POLYGEN CORPORATION  | When I was young, I had to walk |
| Drummers do it... | Waltham, MA USA      | to school and back every day -- |
|    ... In rhythm! | (617) 890-2175       | 20 miles, uphill both ways.     |
+-------------------+----------------------+---------------------------------+
|           ...! [ princeton mit-eddie bu sunne ] !polygen!jerry             |
|                            jerry@polygen.com                               |
+----------------------------------------------------------------------------+

matts@microsoft.UUCP (Matt SAETTLER) (05/25/91)

In article <1991May19.152505.11357@sunee.waterloo.edu> gpsteffl@sunee.waterloo.edu (Glenn Steffler) writes:
Glenn>In article <1688@anaxagoras.ils.nwu.edu> neves@aristotle.ils.nwu.edu (David Neves) writes:
David>
David>We want to do some simple animation in Windows.  If anyone has some
David>pointers on this I would appreciate them.
[...]
David>One way we are considering is to prepare several bitmapped objects and
David>bitblt them (using BITBLT) to a complicated bitmapped background.  The
David>problem as I perceive it is how to specify the part of the bitmap you
David>want copied to the screen.  For example, lets say you have a donut
David>picture and want to send it to the screen.  The bitmap of the donut is
David>rectangular but the object is circular and it has an interior circle
David>that also must show the background.  Is there some secret transparent
David>color that one can use to construct the bitmap?  Or?
[...]
Glenn>
Glenn>Quick answer...NO.  Longer answer would ask you to phone those 
Glenn>nice people at Microsoft and inquire about the Multimedia Toolkit
Glenn>or Developement Kit for Windows.
Glenn>

Glenn "two days" Steffler,

Multimedia Windows DOES provide a transparent BLIT that does what
you want.  The background color in the source bitmap is not copied 
while everything else is...

Another way to avoid complete rectangular updates is to use the RLE
format of DIBs to do a delta-frame.  This method is available under
regular Windows.  The DIB format is not very well documented in the
regular Windows documentation, but the final Multimedia Development Kit 
(MDK) will document it pretty completely.

We have also improved the speed of graphic operations using DIBs  in
the Multimedia Extensions by implementing these operations directly 
in the video drivers instead of letting GDI simulate.

If anyone would like the Beta for the Multimedia Extensions, please
call 206 936-4082 and request an application packet.


Matt Saettler
Microsoft Multimedia Systems

Opinions expressed are my own.....

jeroen_pluimers@f521.n281.z2.fidonet.org (Jeroen Pluimers) (06/02/91)

Hello Matt!

In a msg of <24 May 91>, Matt SAETTLER writes to All:

 MS> Multimedia Windows DOES provide a transparent BLIT that does what
 MS> you want.  The background color in the source bitmap is not copied
 MS> while everything else is...

Why is does back-ground of an icon use the wallpaper as background, even if I 
specify it to be as see trough?

When I drag an icon around over another window, I can see trough it at the 
parts where I defined that color, but as soon as I leave it over (for instance) 
a white window, gray parts are visible in that area. Will this be fixed in Win 
3.1?


jeroen

internet: fthsmuld@rulgl.leidenuniv.nl
bitnet:   fthsmuld@hlerul52.bitnet

risto@tuura.UUCP (Risto Lankinen) (06/10/91)

jeroen_pluimers@f521.n281.z2.fidonet.org (Jeroen Pluimers) writes:

>Hello Matt!

>In a msg of <24 May 91>, Matt SAETTLER writes to All:

> MS> Multimedia Windows DOES provide a transparent BLIT that does what
> MS> you want.  The background color in the source bitmap is not copied
> MS> while everything else is...

>Why is does back-ground of an icon use the wallpaper as background, even if I 
>specify it to be as see trough?

>When I drag an icon around over another window, I can see trough it at the 
>parts where I defined that color, but as soon as I leave it over (for instance) 
>a white window, gray parts are visible in that area. Will this be fixed in Win 
>3.1?

Hi!

The iconic windows receive WM_ICONERASEBKGND messages, at which point they
ask their *parent* window (and not the window. which might be laid directly
underneath ie. between the icon and its parent) to repaint, with the iconic
window's window rectangle as the clipping region.  This is the case with the
draggable 'desktop icons', so the transparent part of them is the desktop
bitmap or color, on top of which the solid part is painted.

If, on the other hand, you use the DrawIcon() within a WinProc(), the icon
is not a window, and will not receive WM_ICONERASEBKGND by itself.  In that
case, the window procedure that drew the icon is responsible of handling
the transparency.

Ob.tip!!!  To make a window 'transparent' with regard to its direct parent,
one could use 'wndclass.hbrBackground = NULL' and handle the WM_ERASEBKGND
with the 'return DefWindowProc( hWnd,WM_ICONERASEBKGND,wPara,lParam)' even
if the window doing so were far from being iconic...

Terveisin: Risto Lankinen
-- 
Risto Lankinen / product specialist ***************************************
Nokia Data Systems, Technology Dept *  2                              3   *
THIS SPACE INTENTIONALLY LEFT BLANK * 2 +1 is PRIME!  Now working on 2 -1 *
replies: risto@yj.data.nokia.fi     ***************************************