The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: masitecno on May 23, 2012, 03:22:15 AM

Title: BitBlt Motion
Post by: masitecno on May 23, 2012, 03:22:15 AM
Hi everybody.

I'm trying to scroll an image like a cilinder, i had an idea using bitblt but i think something was wrong in the implementation:


Paint_Proc proc hWin:DWORD, hDC:DWORD, movit:DWORD
    LOCAL hOld :DWORD
    LOCAL hNew :DWORD
    LOCAL memDC:DWORD
    LOCAL memDCBack:DWORD
    invoke CreateCompatibleDC,hDC
    mov memDC, eax                   
    invoke SelectObject,memDC,hBmp
    mov hOld, eax                         
    invoke CreateCompatibleDC,hDC   
    mov memDCBack, eax
    invoke SelectObject,memDC,hBmp
    mov hNew, eax
    .if movit == 0
      invoke BitBlt,hDC,10,10,768,576,memDC,0,0,SRCCOPY
    .else
    mov var3, 0
    .while var3 < 2     ;<< set the number of times image is looped
      mov var1, 0
      .while var1 < 768 ;<<  Bitmap width
         invoke BitBlt,memDCBack,0,0,767,576,memDC,1,0,SRCCOPY     ;take from pixel 1 to width
         invoke BitBlt,memDCBack,767,0,1,576,memDC,767,0,SRCCOPY  ;take pixel 1 to  last column
         invoke BitBlt,hDC,10,10,768,576,memDCBack,var1,0,SRCCOPY    ;draw the image

        inc var1
      .endw

    inc var3
    .endw
    .endif
    invoke SelectObject,hDC,hOld
    invoke DeleteDC,memDC
    invoke SelectObject,hDC,hNew
    invoke DeleteDC,memDCBack
    return 0
Paint_Proc endp

(The original code was taken from a masm32 example)

I think bitblt can copy from the second column to the end of the bitmap, then copy the first column to the last column then paint that in the window but.
It just doesnt work.

I would appreciate some help. Thanks.
Title: Re: BitBlt Motion
Post by: dedndave on May 23, 2012, 04:46:09 AM
this loop will kill you   :P
      .while var1 < 768 ;<<  Bitmap width
         invoke BitBlt,memDCBack,0,0,767,576,memDC,1,0,SRCCOPY     ;take from pixel 1 to width
         invoke BitBlt,memDCBack,767,0,1,576,memDC,767,0,SRCCOPY  ;take pixel 1 to  last column
         invoke BitBlt,hDC,10,10,768,576,memDCBack,var1,0,SRCCOPY    ;draw the image

        inc var1
      .endw

i would think you can do it with 3 BitBlt's and no loop - if the "split" offset is 0, only 2
all you have to have as a variable is the x-offset of the "split" - which could change with a timer or something
Title: Re: BitBlt Motion
Post by: dedndave on May 23, 2012, 10:28:50 PM
remember those old beer signs ???   :bg

It's Miller Time ! (http://dedndave.x10hosting.com/MillerTime.zip)
Title: Re: BitBlt Motion
Post by: dedndave on May 24, 2012, 04:49:18 AM
what ?
no one likes my beer sign   :red
maybe a pic would help...

(http://i1154.photobucket.com/albums/p527/DednDave/pic.png)
Title: Re: BitBlt Motion
Post by: RHL on May 24, 2012, 07:48:07 AM
lol very nice dave!  :clap: I like it  :bg
Title: Re: BitBlt Motion
Post by: Bill Cravener on May 24, 2012, 01:38:02 PM
Quote from: dedndave on May 24, 2012, 04:49:18 AM
what ?
no one likes my beer sign   :red
maybe a pic would help...

(http://i1154.photobucket.com/albums/p527/DednDave/pic.png)

Thats pretty neat Dave. I do Flash banners for websites that have scrolling backgrounds like that (usually the sky) but this is the first time I've seen an ad banner done in asm.

How come you guys are still posting in the old forum? You should post your example over in the new forum. The only reason I found your example is I accidentally clicked on the old Masm32 link.

Title: Re: BitBlt Motion
Post by: dedndave on May 24, 2012, 02:32:35 PM
yah - the guy is a newbie
if i moved to the other forum, he might not find it   :P
anyways - it is on an external host

the miller beer signs came to mind when he mentioned "cylinder" scrolling
hamm's beer used to have some, too
i wish i could get a look at some of the old ones
they worked by having areas in the front with holes in it
then - the water and/or beer looked like it flowed from the scrolling back

we could do a player piano, too   :bg
my mom probably has about 100 scrolls of music
we could have a keyboard with keys moving up and down - lol
of course - we give them the program for free - then sell them the music scroll files   :bdg
Title: Re: BitBlt Motion
Post by: masitecno on May 24, 2012, 11:33:13 PM
Thank's I've moved to the new Forum.

could you please continue helping? I didn't undestand about the offset.

Yes i'm a newbie.