PA_GetPictureInArray

4D - Documentation   Français   English   German   4D Plugin API, Command Theme List   4D Plugin API, Command Alphabetical List   Back   Previous   Next

version 2003


PA_GetPictureInArray (array; index; picture; info) long

ParameterTypeDescription
arrayPA_VariableArray to access
indexlongIndex of the element to access
picturevoid *Pointer to the data filled with the picture
infoPA_PictureInfo *Pointer to the infos of the picture
Function resultlongSize of the picture in bytes

Description

The routine PA_GetPictureInArray fills the data pointed to by picture with the picture data of the index element of the picture array array, and returns the size of the picture. In addition, the picture information is also returned in the PA_PictureInfo structure pointed to by info.

First, pass zero in picture to get the size of the picture, then allocate a buffer with the correct size and again call the routine passing it this buffer. See the example below.

4th Dimension uses Macintosh Pictures internally. The data returned by this function is the content of a Macintosh Picture Handle. If you want to draw the picture using Macintosh Toolbox or Mac2Win under Windows, it may be more convenient using PA_GetPictureHandleInArray, but in this case you are not the owner of the handle -- it still belongs to the array.

A Macintosh Picture starts with 5 short values that gives the size and the rectangle of the picture respectively. Under Windows, these 5 short values are byte swapped into the Windows byte order. If you want to store your picture on a PICT file, you need to byte swap these values back to the Macintosh byte order so to write a regular Macintosh PICT file.

If the array is not a eVK_ArrayPicture or if index is out of range, the routine returns 0 and leaves picture and info unchanged.

Example

Get a picture element (no error checking here) and its information.

      long size;
      PA_PictureInfo   info;
      char *buffer;

   // First, call the routine with 0L as the picture pointer to get its size
      size = PA_GetPictureInArray( anArray, index, 0L, 0L );
   // Then allocate a buffer...
      buffer = malloc( size );
   // ... and fill it with the data
      size = PA_GetPictureInArray( anArray, index, buffer, &info );
      /* . . . */
   // Cleanup here if necessary
      free( buffer );

See Also

PA_GetPictureHandleInArray.

Error Handling

None.


4D - Documentation   Français   English   German   4D Plugin API, Command Theme List   4D Plugin API, Command Alphabetical List   Back   Previous   Next