Pic.FileNew

OpenTuring

Pic.FileNewPart of Pic module

Syntax   Pic.FileNew (fileName : string) : int

Description   Pic.FileNew is used to obtain a picture from a file. The Pic.FileNew procedure allocates the memory for the picture, which can be very large for pictures of large areas. The memory is freed up when the program calls Pic.Free with the picture ID. The picture can be used with the Pic.Draw and Pic.Save.

The fileNameparameter must give the format of the file:

  GIF files   "GIF:filename" or "filename.GIF"
  JPG files   "JPG:filename" or "filename.JPG"
  BMP files   "BMP:filename" or "filename.BMP"

Details   Various versions of Turing can convert different formats of files. Turing 4.1 for Windows can load BMP, GIF and JPG files.

Details   For, multi-frame GIF files (GIF files that have several frames or pictures and are used for animation), Pic.FileNew will only load the first frame. See the Pic.FileNewFrames and Pic.Frame for information on loading and displaying a multi-frame GIF file.
Details   If the Pic.FileNew call fails, then it returns 0. Also Error.Last will return a non-zero value indicating the reason for the failure. Error.LastMsg will return a string which contains the textual version of the error.

Example   The program reads a graphic from the file mypic.bmp and then draws it 50 times.

        var picID: int
        var x, y : int
        
        picID := Pic.FileNew ("mypic.bmp")
        for i : 1 .. 50
            x := Rand.Int (0, maxx)     % Random x
            y := Rand.Int (0, maxy)     % Random y
            Pic.Draw (picID, x, y, picCopy)
        end for
        Pic.Free (picID)

Execute  

Status   Exported qualified.

This means that you can only call the function by calling Pic.FileNew, not by calling FileNew.