| Extracted from Pike v7.8 release 700 at 2013-06-08.

[Top]
Image
Image.GIF

# Method Image.GIF.render_block()

Method render_block

  `string render_block(object img, object colortable, int x, int y, int localpalette)`
  `string render_block(object img, object colortable, int x, int y, int localpalette, object alpha)`
  `string render_block(object img, object colortable, int x, int y, int localpalette, object alpha, int r, int g, int b)`
  `string render_block(object img, object colortable, int x, int y, int localpalette, int delay, int transp_index, int interlace, int user_input, int disposal)`
  `string render_block(object img, object colortable, int x, int y, int localpalette, object alpha, int r, int g, int b, int delay, int interlace, int user_input, int disposal)`

Description

  This function gives a image block for placement in a GIF file, with or without transparency. The some options actually gives two blocks, the first with graphic control extensions for such things as delay or transparency.

  Example:

      img1=Image.Image ([...]);
      img2=Image.Image ([...]);
      [...] // make your very-nice images
      nct=Image.Colortable ([...]); // make a nice colortable
      write(Image.GIF.header_block (xsize,ysize,nct)); // write a GIF header
      write(Image.GIF.render_block (img1,nct,0,0,0,10)); // write a render block
      write(Image.GIF.render_block (img2,nct,0,0,0,10)); // write a render block
      [...]
      write(Image.GIF.end_block ()); // write end block
      // voila! A GIF animation on stdout.

  The above animation is thus created:

      object nct=Image.Colortable(lena,32,({({0,0,0})}));
      string s=GIF.header_block(lena->xsize(),lena->ysize(),nct);
      foreach ( ({lena->xsize(),
                  (int)(lena->xsize()*0.75),
                  (int)(lena->xsize()*0.5),
                  (int)(lena->xsize()*0.25),
                  (int)(1),
                  (int)(lena->xsize()*0.25),
                  (int)(lena->xsize()*0.5),
                  (int)(lena->xsize()*0.75)}),int xsize)
      {
         object o=lena->scale(xsize,lena->ysize());
         object p=lena->clear(0,0,0);
         p->paste(o,(lena->xsize()-o->xsize())/2,0);
         s+=Image.GIF.render_block(p,nct,0,0,0,25);
      }
      s+=Image.GIF.netscape_loop_block(200);
      s+=Image.GIF.end_block();
      write(s);

Parameter `img`

  The image.

Parameter `colortable`

  Colortable with colors to use and to write as palette.

Parameter `x`
Parameter `y`

  Position of this image.

Parameter `localpalette`

  If set, writes a local palette.

Parameter `alpha`

  Alpha channel image; black is transparent.

Parameter `r`
Parameter `g`
Parameter `b`

  Color of transparent pixels. Not all decoders understands transparency. This is ignored if localpalette isn't set.

Parameter `delay`

  View this image for this many centiseconds. Default is zero.

Parameter `transp_index`

  Index of the transparent color in the colortable. `-1` indicates no transparency.

Parameter `user_input`

  If set: wait the delay or until user input. If delay is zero, wait indefinitely for user input. May sound the bell upon decoding. Default is non-set.

Parameter `disposal`

  Disposal method number;

Note

  This is in the advanced sector of the GIF support; please read some about how GIFs are packed.

  The user_input and disposal method are unsupported in most decoders.

See also

  encode , header_block , end_block