de en es fr
Let the machine help
Light teasing, exhibition, BDSM, sissyfication, watersports... with sounds and pictures


Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Layered images - gif animation?
PostPosted: Wed Jun 15, 2016 8:53 am 
Offline
Veteran
User avatar
I have "overlay" images working thanks to Liz (thanks again!), however I was now wanting to place a second overlay (third image) over the top as a "special effect" in the form of an animated gif.

The code I am using is:
Code:
def setImageEffect = { picture, opicture, epicture, xpos, ypos, expos, eypos ->
   def image = java.awt.Toolkit.getDefaultToolkit().getImage("images/"+picture)
   def width = image.getWidth()
   def height = image.getHeight()
   def oimage = java.awt.Toolkit.getDefaultToolkit().getImage("images/"+opicture)
   def owidth = oimage.getWidth()
   def oheight = oimage.getHeight()
   def eimage = java.awt.Toolkit.getDefaultToolkit().getImage("images/"+epicture)
   def ewidth = eimage.getWidth()
   def eheight = eimage.getHeight()
   
   def frameBuffer = new java.awt.image.BufferedImage(width, height, java.awt.image.BufferedImage.TYPE_4BYTE_ABGR)
   def sprite = javax.imageio.ImageIO.read(new File("images/"+picture))
   def osprite = javax.imageio.ImageIO.read(new File("images/"+opicture))
   def esprite = javax.imageio.ImageIO.read(new File("images/"+epicture))
   java.awt.Graphics2D graphics = frameBuffer.createGraphics()
   graphics.drawImage(sprite,0,0,width,height, null)
   graphics.drawImage(osprite,xpos,ypos,owidth,oheight, null)
   graphics.drawImage(esprite,expos,eypos,ewidth,eheight, null)
   
   java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream()
   javax.imageio.ImageIO.write(frameBuffer, "png", baos)
   setImage(baos.toByteArray(),0)
}

And this works! However, it only displays a single frame of the gif being called upon, rather than its usual animated (multi-frame) form.

What do I need to change in the code above to make the gif display normally (as it would if I just used setImage("somegif.gif")?

(I am open to an easier way of doing this, too, such as being able to overlay a gif on top of an already called image, but the above was the only way I could get it to work for now)


Top
 Profile Send private message 
 
 Re: Layered images - gif animation?
PostPosted: Wed Jun 15, 2016 7:44 pm 
Offline
Site Admin
User avatar
At last
Code:
javax.imageio.ImageIO.write(frameBuffer, "png", baos)

to
Code:
javax.imageio.ImageIO.write(frameBuffer, "gif", baos)

But frankly I don't know


Top
 Profile Send private message 
 
 Re: Layered images - gif animation?
PostPosted: Thu Jun 16, 2016 6:56 am 
Offline
Veteran
User avatar
doti wrote:
At last
Code:
javax.imageio.ImageIO.write(frameBuffer, "png", baos)

to
Code:
javax.imageio.ImageIO.write(frameBuffer, "gif", baos)

But frankly I don't know

Thanks. That didn't work, though.

After more testing, though, I now actually think the error isn't so much in the scripting but in how SexScripts plays gif animations.

I noticed that in more than the above case, gifs animate fine sometimes but not always. I *think* the difference is that it only works when a command that 'stops' SexScripts processing is used after displaying one (for example: displaying a gif followed by using showButton to continue). However, when the script is still running, it does not seem to animate the gif and just shows the first frame.

Could you please investigate this? Do gifs not animate in the "background" while other stuff is processing sometimes?

(on the subject of background running, I bumped an old thread about it, but I was also wondering how progress on a "continually loop background sound" function is going?)


Top
 Profile Send private message 
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Maroon Fusion theme created by Oxydo
Software, theme modifications, phpBB modification by Doti 2010 - 2020
This website uses session cookies only.