Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

int phColorRead int  fd,
uint32_t  max_colors,
uint32_t num_colors,
phColor **  colors
 

This loads an array of phColor values from a file descriptor which could be stdin. If the function succeeds in reading from the file descriptor, the color buffer will be allocated and will contain the phColor information that is in the file. If colors == NULL, no allocation will take place.

Make sure to call phFree on the colors buffer.

 phColor  *colors     = NULL; 
 uint32_t  ncolors    = 0;
 int       rc         = phSUCCESS;
 int       fd         = 0;
 
 fd = open("file.colors",O_RDONLY);

 if (fd == -1) goto error;

 rc = phColorRead( fd, 0, &ncolors, &colors );
 if (rc == phSUCCESS)
 {
      int i = 0;
      for(i = 0; i < ncolors; i++ )
      {
          // Do something with colors[i]
      }
 }
 return phSUCCESS;
 error:
 return phFAIL;

Parameters:
[in] fd The file descriptor id to read from
[in] max_colors This will limit the total number of colors read from a file. If max_colors is 0 then all the colors will be loaded.
[out] num_colors The number of colors loaded from the file is written here. This can be NULL
[out] colors This is a buffer of phColors allocated within the function.
Returns:
The success or failure of the function's ability to load the colors from a file.
Return values:
phSUCCESS 
phFAIL 

Definition at line 575 of file ImageDefinitions.c.





Copyright (C) 2002 - 2007 Philip D.S. Thoren ( pthoren@users.sourceforge.net )
University Of Massachusetts at Lowell
Robotics Lab
SourceForge.net Logo

Generated on Sat Jun 16 02:45:26 2007 for phission by  doxygen 1.4.4