News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Bitmap Scrolling

Started by masitecno, June 21, 2012, 08:44:32 AM

Previous topic - Next topic

masitecno


This is my first aproach of what i need to do.

I need a bitmap to scroll left very fast and my code does it very slowly, I need to know how can I make it faster.

Thanks.

qWord

Do not use Set/GetPixel - it is extreme slow! Instead use Get/SetDIBits() to manipulate a image. Search the old/new forum for examples.

For scrolling/looping the image left, use BitBlt:
BitBlt(hBufferDC,width-1,0,1,heigth,hSrc,0,0) ; move left column
BitBlt(hBufferDC,0,0,width-1,heigth,hSrc,1,0) ; move remaining columns
BitBlt(hSrc,....,hBufferDC)


Also, use a timer (SetTimer->WM_TIMER) for scrolling.
MREAL macros - when you need floating point arithmetic while assembling!

masitecno

Thanks qWord.

That was an excellent advice (BitBlit x 3).
It's awsome the speed.
But, how can i remove the tear effect or flicker effect?

I'm trying now to implement the timer.

Attached: new version with bitblits

Farabi

Quote from: masitecno on June 21, 2012, 11:06:16 AM
Thanks qWord.

That was an excellent advice (BitBlit x 3).
It's awsome the speed.
But, how can i remove the tear effect or flicker effect?

I'm trying now to implement the timer.

Attached: new version with bitblits

Double the buffer. Create a buffer for you to draw everything as like to are goin to draw to the main screen. And after youre done, blit it to the main screen.
GDI performance on Bliting is outstanding. It is very fast even on an old card like mine. Just allocate as big screen as you like, and just scroll it. GDI will handle it.
http://farabidatacenter.url.ph/MySoftware/
My 3D Game Engine Demo.

Contact me at Whatsapp: 6283818314165

masitecno

Thanks Farabi.

This is what i undestood.


    mov var3, 0

    .while var3 < 13000     ;<< set the number of times image is looped

        mov eax, maxX
        dec eax
        invoke BitBlt,memDCBack,eax,0,1,maxY,memDC,0,0,SRCCOPY  ;HERE IS DE DOUBLE BUFFER MEMDCBACK
        mov eax, maxX
        dec eax
        invoke BitBlt,memDCBack,0,0,eax,maxY,memDC,1,0,SRCCOPY
        invoke BitBlt,memDC,0,0,maxX,maxY,memDCBack,0,0,SRCCOPY

        invoke Sleep, 30
        invoke BitBlt,hDC,0,0,maxX,maxY,memDCBack,0,0,SRCCOPY
        inc var3
    .endw



But it still flickers.

:(

dedndave

how fast do you need to be able to scroll 1024 pixels width ?

Farabi

I dont know what do you mean with flicker but that should be remove the flickers. Maybe you will need to wait the vsync retrate or something.
http://farabidatacenter.url.ph/MySoftware/
My 3D Game Engine Demo.

Contact me at Whatsapp: 6283818314165

CodeDog

You may also want to check out
INVOKE ScrollWindowEx, hWnd, 0, INC_SIZEY*50, NULL, NULL, NULL, NULL, 0

It is optimized for scrolling windows. You can scroll any part of the window you like and then blit the rest. I'm not sure how fast this is compared to blitting only, but it is supposed to be optimized for scrolling.