Victor Image Processing Library How-to Tips

Create an animated JPEG



Growing image created with Victor resizeex function.


The animation is contained in a series of image areas as in a filmstrip. For this example the original image is resized into each of the areas. The smallest size is placed in the first area and each area receives a larger size. The entire image contains 8 frames and is saved as a JPEG image file. The final JPEG image is in growing.jpg.

To display the animation place the Java applets and image together in the same directory and insert the applet-calling code below into your .html document.

Create a Growing Image Animation

Requires Victor Image Processing Library v 5.
// Use src image to make a film strip of growing image. Desimg is empty imgdes to be allocated here.
int makegrowfilmstrip(int frames, imgdes *srcimg, imgdes *desimg)
{
   int rcode = NO_ERROR;
   int cols, rows;
   int j;
   int wd, ht;
   cols = CALC_WIDTH(srcimg);
   rows = CALC_HEIGHT(srcimg);
   wd = cols/frames/2;
   ht = rows/frames/2;
   rcode = allocimage(desimg, cols * frames, rows, srcimg->bmh->biBitCount);
   zeroimage(255, desimg);// Create a white background
   if(rcode == NO_ERROR) { 
      for(j = 0; j < frames; j++) {
            // Set destination region to resize into before each call to resizeex
         setimagearea(desimg, cols * (frames-j-1) + wd*j, ht*j, cols * (frames-j-1) + cols-wd*j-1, rows-ht*j-1);
         resizeex(srcimg, desimg, 1 /*RESAMPLEBILINEAR*/);
         }
            // Restore image area to entire image before saving
      setimagearea(desimg, 0, 0, desimg->bmh->biWidth-1, desimg->bmh->biHeight-1);
            // Save as sequential optimized JPEG at quality = 75
      rcode = savejpgex("growing.jpg", desimg, 75, 2); 
      }
   return (rcode);
}

Insert these lines into your .html document.

<applet code="JavaLogo.class" width="278" height="63">
   <param name="link"     value="http://www.catenary.com">
   <param name="image"    value="growing.jpg">
   <param name="bgcolor"  value="ffffff">
   <param name="delay"    value="100">
   <param name="number"   value="8">
</applet>

Download the required Java applets (3 kb). For more information about the Java applets visit http://java.sun.com/openstudio/applets/logo.html


Copyright © 1999 Catenary Systems Inc. All rights reserved. Victor Image Processing Library is a trademark of Catenary Systems.


Victor Image Processing Library homepage | Victor Sample Code