Graphics

How to Animate a picture .
( Can setviewport can be used. if yes explain with prog. )
senexpertAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

nietodCommented:
Standard C++ does not have any graphics features.  This has to be done through OS-specific techniques.  So what OS is this for?
0
KangaRooCommented:
And which compiler?
0
noescomCommented:
Hi senexpert,

Because you mention SetViewPort() which is a Windows command, i'll assume you use Windows. Unfortunatly Windows has no native support for the kind of animations you are looking for. You'll have to write it yourself. How you ask? Pretty easy.

Create a bitmap with multiple 'frames'. You could store each frame vertically inside the bitmap, so if you have a bitmap 100 pixels high and with 3 frames, the resulting bitmap will end up being 300 pixels high. Now in your WM_PAINT bitblt one portion of your bitmap to the screen.

Start a timer using SetTimer(...) and in each timertick increase or decrease the framecount of your bitmap. After that send an InvalidateRect. In pseudo code this would be:

---- begin code ----

int frame = 0;

WM_CREATE:
    SetTimer(100ms);

WM_TIMER:
    frame++;

    if (frame == 3) {
        frame = 0;
    end

WM_PAINT:
    int h = height / 3;

    BeginPaint(...);

    BitBlt(hdc, 0, frame * h,
           width, (h * frame) + h,
           source_hdc,
           0, h * frame
    );
           
    EndPaint(...);

WM_DESTROY:
    KillTimer(...);
   
---- end code ----

This would be the easiest with the OOP Windows framework i'm writing. If you want a work-in-progress copy of this framework just send me an e-mail. I can make an example of this problem as well.

My e-mail is flvdberg@wxs.nl

Floris
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

KangaRooCommented:
Is dat 'noescom' als in No-Escom ;)
0
noescomCommented:
Yup :)
0
nietodCommented:
>> Because you mention SetViewPort() which is a Windows
You are probably right, but I think every graphical environment in the world has that command.  Macintosh certainlyd did.

Also in that code on the WM_TIMER you need to invalidate the window (or a portion of it) to make it repaint.

And what is "No-escom"?
0
noescomCommented:
You are absolutely right about the WM_TIMER missing an InvalidateRect. I put it in the descriptive text, but forgot to include it in the pseudo-code. Sorry for that.

I can't comment on the SetViewPort() being part of every graphical environment. So far i have only worked with Windows.

My nick comes from a german computer company named Escom which went bankrupt several years ago. When i bought an Escom computer it was so bad, i instantly thought of the irc nick NoEscom. And i use it still.
0
nietodCommented:
And Kangaroo picked up on that?   He's gotta be psychic.

I think MoveTo(), LineTo() and SetViewport() are part of every graphics environment I've ever used.  Lack of creativity among programmers?
0
nietodCommented:
senexpert, why did you reject the answer?
0
noescomCommented:
I think i am at least entitled to an explaination why my answer was rejected. IMHO it anwered the question quite well.
0
nietodCommented:
>> IMHO it anwered the question quite well.
I would agree, or at least he answered well enough that you could have asked him for clarification of any details he missed.
0
KangaRooCommented:
noescom, aangezien je nederlander blijkt te zijn moet je misschien ook eens een kruisje achterlaten bij:
http://www.experts-exchange.com/jsp/qShow.jsp?ta=lounge&qid=10111117 
      - of -
http://www.experts-exchange.com/Q.10111117 (non-cookie login)

0
nietodCommented:
Any hope of an explanation for the linguistically challenged.
0
KangaRooCommented:
noescom, since you turn out to be dutch you might want to leave a mark at:
<and the url's>
0
KangaRooCommented:
Cool, it's working! I'v gotten IE to diplay the comments in a monospaced font!
0
techpageCommented:
use OpenGL!!! or DirectDraw!!!... get all complete header files and libs and start working !!!
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
nietodCommented:
Techpage, have you read the question history?

The question was answered and that answer was rejected for no apparent reason.  How if you're answer is accepted, you will be "stealing" it from an expert that has done much more work and really deserves the credit.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.