PICTURE TO GIF

4D - Documentation   Français   English   German   4th Dimension 2004, Command Theme List   4th Dimension 2004, Command Alphabetical List   4th Dimension 2004, Constant Theme List   Back   Previous   Next

version 6.7 (Modified)


PICTURE TO GIF (pict; blobGIF)

ParameterTypeDescription
pictPicturePicture field or picture variable
blobGIFBLOBBLOB containing the GIF picture

Description

The PICTURE TO GIF command allows you to convert a PICT picture stored in a variable or in a 4D field into a GIF picture.

You pass a picture variable or a picture field in pict and a BLOB variable or a BLOB field in blobGIF. After executing the command, blobGIF contains the image in GIF format.

Note: The GIF picture format cannot contain more than 256 colors. If the original PICT picture contains more colors, some may be lost. The command reduces the number of colors according to the system palette. The GIF generated is of type 87a (opaque) and normal (not interlaced).

You can then save the picture located in blobGIF in a file using the BLOB TO DOCUMENT command or you can even publish it on the Web.

If the conversion was successful, the OK system variable is set to 1. Otherwise, it will be equal to 0.

Example

Let us assume that you want to generate a GIF picture on the fly by displaying a connection counter. In the database's picture library, place all the numbers as pictures:

In the On Web Connection Database Method, you write the following code:

   If (Web Context)
      ...
   Else
      C_BLOB ($blob)
      Case of 
         ...
         : ($1="/4dcgi/counter") `Generating a GIF counter
               `When 4D detects this URL while sending the static page
            $blob:=gifcounter (<>nbHits)    `Calculates the GIF picture
               `The <>nbHits variable contains the number of connections 
            SEND HTML BLOB ($blob;"image/gif")
               `Insert the picture and send it to the browser
            ...
         End case
   End if

Here is the gifcounter method:

   C_LONGINT($1)
   C_PICTURE($img)
   C_BLOB($0)
   If ($1=0)
      $ndigits:=1
   Else 
      $ndigits:=1+Length(String($1))
   End if
   If ($ndigits<5)
      $ndigits:=5
   End if

   $div:=10^($ndigits-1)
   For ($i;1;$ndigits)
      $ref:=Int($1/$div)%10
      GET PICTURE FROM LIBRARY($ref+1000;picture)
      $img:=$img+picture
      $div:=$div/10
   End for

   PICTURE TO GIF($img;$0)

When sending a page to the Web browser, 4D displays a GIF picture that looks like the following picture:


4D - Documentation   Français   English   German   4th Dimension 2004, Command Theme List   4th Dimension 2004, Command Alphabetical List   4th Dimension 2004, Constant Theme List   Back   Previous   Next