[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

Graphics

Posted on 2000-01-20
17
Medium Priority
?
231 Views
Last Modified: 2010-04-10
How to Animate a picture .
( Can setviewport can be used. if yes explain with prog. )
0
Comment
Question by:senexpert
  • 7
  • 5
  • 4
  • +1
17 Comments
 
LVL 22

Expert Comment

by:nietod
ID: 2370702
Standard C++ does not have any graphics features.  This has to be done through OS-specific techniques.  So what OS is this for?
0
 
LVL 7

Expert Comment

by:KangaRoo
ID: 2370720
And which compiler?
0
 
LVL 1

Expert Comment

by:noescom
ID: 2371373
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
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
LVL 7

Expert Comment

by:KangaRoo
ID: 2371403
Is dat 'noescom' als in No-Escom ;)
0
 
LVL 1

Expert Comment

by:noescom
ID: 2371412
Yup :)
0
 
LVL 22

Expert Comment

by:nietod
ID: 2371843
>> 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
 
LVL 1

Expert Comment

by:noescom
ID: 2372131
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
 
LVL 22

Expert Comment

by:nietod
ID: 2372230
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
 
LVL 22

Expert Comment

by:nietod
ID: 2374372
senexpert, why did you reject the answer?
0
 
LVL 1

Expert Comment

by:noescom
ID: 2374804
I think i am at least entitled to an explaination why my answer was rejected. IMHO it anwered the question quite well.
0
 
LVL 22

Expert Comment

by:nietod
ID: 2375187
>> 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
 
LVL 7

Expert Comment

by:KangaRoo
ID: 2392750
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
 
LVL 22

Expert Comment

by:nietod
ID: 2392772
Any hope of an explanation for the linguistically challenged.
0
 
LVL 7

Expert Comment

by:KangaRoo
ID: 2392815
noescom, since you turn out to be dutch you might want to leave a mark at:
<and the url's>
0
 
LVL 7

Expert Comment

by:KangaRoo
ID: 2392821
Cool, it's working! I'v gotten IE to diplay the comments in a monospaced font!
0
 
LVL 3

Accepted Solution

by:
techpage earned 60 total points
ID: 2499453
use OpenGL!!! or DirectDraw!!!... get all complete header files and libs and start working !!!
0
 
LVL 22

Expert Comment

by:nietod
ID: 2499903
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

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

591 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question