Jump to content



Photo
* * * * * 1 votes

Animated GIF with FreeImage?


  • Please log in to reply
28 replies to this topic

#21 rascal

rascal

    two-faced as they come

  • VIP
  • 1,374 posts
  • Location:Indiana USA

  • Flag: United States of America

  • Favorite Pinball: Bally Eight Ball



Posted 29 October 2012 - 12:01 AM

I played around with the latest VP source code to see if I could at least add a gif to a table. I changed two lines of code in the vpinball.cpp file. One line was for the Import button code in Image Manager and the other was for the Reimport From button also in the Image Manager. The lines I changed are the filters for the "Files of type:" box you see in the image below. I added the filter to allow *.gif.

Posted Image

It worked! I could now see and select gif files from the browse directory. YIPPY! Next I selected a gif file and clicked Open.
Posted Image

Wow! I see my gif image in the Image Manager! I'm two for two! Next I pick my gif image as the playfiled image in the editor.
Posted Image

There it is! My gif as the playfield image in VP!!! Man this might work yet. So now I play the table to see my gif in action.
Posted Image

WAH!!!! Nothing, zippo, the image becomes totally transparent rendered in VP with directx. :bye2:

I tried it on a wall side, the same thing, the wall became transparent. Same on a ramp, and a decal. I tied both animated gifs and non-aminated gifs. It's just not rendering. I'm not real swift with directx programming and I don't know what to do at this point. I hope that one of the developers will see this and maybe join the cause and see what they can do.

Anyway, not too bad for just changing two lines of code.

Edited by rascal, 29 October 2012 - 12:05 AM.

Posted Image


#22 maceman

maceman

    Home Pinball Machine Collector/ Restorer

  • VIP
  • 2,271 posts
  • Location:Canada, Eh!

  • Flag: Canada

  • Favorite Pinball: ....**Haunted House**....



Posted 29 October 2012 - 12:57 AM

Hi Rascal

Sorry if i am missing the point here, but wouldn't we rather have animated PNG's using the APNG format rather than gif? I mean, why restrict ourselves to a 256 colour palette when we can go with better quality. I still thing the APNG will take off in future. I think it had less support due to newer technologies.... This here image is an animated PNG btw :) Look at that reflection! Would be hard to do with a gif!

Posted Image

I understand what you are driving for however. I took me quite a while to learn how to do this, thanx to the help of JP. If you try my HM table, you will see a script called Chattering Skull, which uses two images going on and off. I also used it in a new beating heart animation as per below:


'***** Beating Heart *****
'add 2 variables: beatingPos, beatingCount, and initialize them to 0
Dim beatingPos, beatingCount
beatingPos = 0
beatingCount = 0

' Initialize both ramps used in the example
BH10.WidthBottom = 0: BH10.WidthTop = 0
BH1.WidthBottom = 0: BH1.WidthTop = 0
' and refresh under the ramps
' the alpha ramps need to be refreshed
' if not they do not change
' to refresh we use a black light (remember black = invisible in VP)
' to refresh the lights we change the state
Light3.State = ABS(Light3.state -1)

' those are 2 refresh and big lights takes a lot of cpu power, so one refresh is enough
Sub TriggerX_Hit()
'TriggerX.TimerInterval=1000
'TriggerX.TimerEnabled = True
beatingCount = 8
'Playsound "kicker_enter"
'AddScore = 1000
beatingTimer.Enabled = 1 'start the sub that makes the heart beat.
PlaySound "heartbeat"
End Sub

Sub TriggerX_UnHit()
'TriggerX.Timerenabled = False
'TriggerX.Kick 0,20
'PlaySound "kicker"

End Sub
' this is the sub to make the heart beat and unbeat
' it runs until the beatingCount is 0

Sub beatingTimer_Timer
Select Case beatingPos

Case 0: '... beat the heart
BH10.WidthBottom = 150: BH10.WidthTop = 150
BH1.WidthBottom = 0: BH1.WidthTop = 0
Light3.State = ABS(Light3.state -1)

Case 1: '... unbeat the heart
BH10.WidthBottom = 0: BH10.WidthTop = 0
BH1.WidthBottom = 150: BH1.WidthTop = 150
Light3.State = ABS(Light3.state -1)

End Select
beatingPos=ABS(beatingPos -1) 'this simply inverts the value between 0 and 1
beatingCount = beatingCount - 1
If beatingCount = 0 Then

'... make both ramps invisible
BH10.WidthBottom = 0: BH10.WidthTop = 0
BH1.WidthBottom = 0: BH1.WidthTop = 0
Light3.State = ABS(Light3.state -1)
beatingTimer.enabled = 0 ' turn off the timer
End If
End Sub


Just recently i was speaking with JP on how to make this with more images, which i have the answer for still in my PM's as i haven't had a chance to try it. It is tedious i admit, but a workaround until we gets some VP Dev support :)
Cheers,
Maceman

Edited by maceman, 29 October 2012 - 01:00 AM.

________________________________________________________________________________
Canada Eh!
hm_avatar.pngss_avatar.jpg MODS ys_avatar5.jpggenie_avatar.pngj2o_avatar.png

#23 koadic

koadic

    Pinball Fan

  • VIP
  • 1,363 posts
  • Location:Omaha, NE, USA

  • Flag: United States of America

  • Favorite Pinball: Addams Family/Fish Tales/Medieval Madness



Contributor

Posted 29 October 2012 - 02:34 AM

Agreed, apng would be ideal, but the concept is the same :)

And maceman, to optimize your script a bit and use less resources, instead of modifying the widthtop and widthbottom of those alpha ramps, use .alpha=1 to turn the ramp 'on' and .alpha=0 to turn the ramp 'off', or you can cycle the image of a single ramp with ramp.image="bh1", etc. with bh1 being the name of an image you have imported to the table, and of course refreshing with a light like normal.

#24 pinuck

pinuck

    Pinball Fan

  • VIP
  • 514 posts
  • Location:Toronto

  • Flag: Canada

  • Favorite Pinball: Jacks Open, AFM, TOM



Posted 29 October 2012 - 03:42 AM

Personally, I'm struggling to see much practical application for animated gif support. Aside from the reduced colour palette issue that maceman already mentioned, gifs aren't really controllable - the loop once/forever and frame timing is embedded in the gif, so the thought that it could replace a stack of images for a reel that you can flip through back and forth, stopping and starting as you desire seems rather unlikely to me.

Unless you wanted a constantly looping animation that you have no control over, then yes i guess it would be neat. But i've never wanted that, and if i did i would probably just use a timer and a few images, for the few (if ever) occasions that it was required.

just my 2¢

#25 rascal

rascal

    two-faced as they come

  • VIP
  • 1,374 posts
  • Location:Indiana USA

  • Flag: United States of America

  • Favorite Pinball: Bally Eight Ball



Posted 29 October 2012 - 09:51 AM

Advantages to using gif at this point:
1. FreeImage has a plugin that already supports animated gifs why not use it? (apng is not currently supported in FreeImage) <--- Biggest reason no apng, you get them to add it and I'm there too.
2. During the creation of a gif, you can set varying frame rates directly to each frame in the image file without messing with VP timers and/or additional script, that can cause lag to the game play.
3. 256 colors is more than enough for lights, most toys, and things such as DMDs.
4. You can use the ramp.Image method to load and unload sequences of animated gifs or static gifs (when animation is off) set to run once and still achieve fluid animation with less strain on VP itself.

Posted Image


#26 destruk

destruk

    VPF Veteran

  • VPF Staff
  • 6,307 posts
  • Location:Colorado Springs, CO

  • Flag: United States of America

  • Favorite Pinball: Ultrapin!



Posted 29 October 2012 - 12:00 PM

I just remember loading a GIF on an old computer and the timing was fine, and then loading it on a new computer and seeing it run through the frames at 4 billion fps... But I'm sure whatever implementation is used would fix that problem. :)

Build a fire, vipers love the heat.


#27 rascal

rascal

    two-faced as they come

  • VIP
  • 1,374 posts
  • Location:Indiana USA

  • Flag: United States of America

  • Favorite Pinball: Bally Eight Ball



Posted 30 October 2012 - 04:41 PM

Ok, there is some success! The gif displays on the backdrop, on a solid ramp, and on top of walls. It doesn't animate and it won't show on the side walls of any objects. However, the fact that I can get it to show in a rendered table at all is a great sign that it should be possible. However, I need my buddie Cupid or someone else that knows something about VP's graphic rendering to go any further.

Posted Image

Edited by rascal, 30 October 2012 - 04:49 PM.

Posted Image


#28 oooPLAYER1ooo

oooPLAYER1ooo

    habitual deflector

  • VIP
  • 806 posts
  • Location:sydney , Australia

  • Flag: Australia

  • Favorite Pinball: Al's Garage Band Goes On A World Tour

  • 360 Gamer Tag: oooPLAYER1ooo


Posted 31 October 2012 - 05:52 AM

cool rascal, nice find

°)つ◕_◕༽つ( ͡° ͜ʖ ͡°)つ◕_◕༽つ( ͡° ͜ʖ ͡°)つ◕_◕༽つ( ͡° ͜ʖ ͡°)つ◕_◕༽つ( ͡° ͜ʖ ͡°)つ◕_◕༽つ( ͡° ͜ʖ ͡°)つ◕_◕༽つ( ͡° ͜ʖ ͡°)つ◕_◕༽つ( ͡° ͜ʖ ͡°)つ◕_◕༽つ( ͡° ͜ʖ ͡°)つ◕_◕༽つ( ͡° ͜ʖ ͡°)つ◕_◕༽つ( ͡° ͜ʖ ͡°)つ◕_◕༽つ( ͡° ͜ʖ ͡°)つ◕_◕༽つ( ͡° ͜ʖ ͡°)つ◕_◕༽つ( ͡° ͜ʖ ͡°)つ◕_◕༽つ( ͡° ͜ʖ ͡°)つ◕_◕༽つ( ͡° ͜ʖ ͡°)つ◕_◕༽つ( ͡° ͜ʖ ͡°)つ◕_◕༽つ( ͡° ͜ʖ ͡°)つ◕_◕༽つ( ͡° ͜ʖ ͡°)つ◕_◕༽つ( ͡° ͜ʖ ͡°)





ozpin.gif


#29 cl4ve

cl4ve

    Neophyte

  • Members
  • Pip
  • 2 posts

  • Flag: United States of America

  • Favorite Pinball: Addams Family

Posted 23 February 2024 - 10:42 PM

i would like to know about this to add a bubbling lagoon to the creature table