Animated Images - HeroesToolChest/HeroesDataParser GitHub Wiki

Overview

Both sprays and emoticons have animated images and will be extracted as a gif. However, due to quality limitations with gifs the texture sheet will also be extracted as a png to allow for a manual animation creation.

Emoticons seem to appear fine as gifs, sprays not so much.

Gif Examples

Here are three example of spray gifs along with their texture sheets.

  1. Booty Coffer - A background color is showing, though it should not
  2. Carbot Alarak - Transparency issues
  3. Snowglobe Cursed - The background of the globe is not a solid color, because it is supposed to be transparent

Basically any image in general that uses transparency will have quality issues when converted to a gif.

Gif Texture Sheet
booty_gif booty_texture
alarak_gif alarak_texture
snowglobe_gif snowglob_texture

Creating Animations

Creating an animation is pretty straight forward. Looking at the spray examples above, each texture image has two images. Each image is shown for a period of time and then the next image is shown for the exact period of time. Then repeat.

Emoticons are a little more complicated, having multiple columns and rows on the texture sheet.

Spray and Emoticon data both have the following available: texture, frames, and duration. Emoticons also have width and height.

Texture: the texture sheet in .png format.
Frames: how many "images" there are on a texture sheet.
Duration: how long each frame (image) will last before change to the next frame.
Width: the width size of the frame.
Height: the height size of the frame.

Emoticons

Pseudocode to get the frames from the texture sheet.

// load up the texture file
Set original_texture = data.texture

// calculate the frame height
Set image_height = original_texture.height
if (data.texture.rows is not null)
  image_height = original_texture.height / data.texture.rows

// calculate the frame width
Set image_width = original_texture.width
if (data.texture.columns is not null)
  image_width = original_texture.width / data.texture.columns

For i = 0 to data.frames
  // calculate the x and y position (0,0 is top left) to find location of frame on texture sheet
  set x_position = (i mod (original_texture.width / image_width)) * image_width
  set y_position = floor(i / (original_texture.width / image_width)) * image_height

  // to get the frame from the texture sheet
  // use the x_position and y_position along with the image_width and image_height
  Set image_frame = GetRectangle(Point(x_position, y_position), Size(image_width, image_height))

  // the time duration of the frame
  image_frame.duration = data.duration

Sprays

Though simpler than emoticons, the same algorithm from emoticons can be used except the calculation for frame width is different.

// calculate the frame width
Set image_width = original_texture.width
if (data.frames > 0)
  image_width = original_texture.width / data.frames

Notes

Depending on your application and libraries you are using, you may have to tweak the duration.

For HDP gif extraction, the duration was modified

  • sprays: duration / 20
  • emoticons: duration / 10