4D v13.4

PICTURE TO GIF

Home

 
4D v13.4
PICTURE TO GIF

PICTURE TO GIF 


 

PICTURE TO GIF ( pict ; blobGIF ) 
Parameter Type   Description
pict  Picture in Picture field or picture variable
blobGIF  BLOB in BLOB containing the GIF picture

The PICTURE TO GIF command converts 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 Windows Ctrl down 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
          WEB SEND 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:

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

 
PROPERTIES 

Product: 4D
Theme: Pictures
Number: 671

The OK variable is changed by the command

 
INDEX

Alphabetical list of commands

 
HISTORY 

Modified: 4D v6.7