home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 580a.lha / HDFView_v3.01 / source.LZH / source / src / readData.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-10-22  |  1.0 KB  |  51 lines

  1. #include    <exec/types.h>
  2. #include    <string.h>
  3.  
  4. #include    "View_define.h"
  5. /* These are HDF header files. The dfproto.h file I made myself */
  6. #include    <hdf/dfproto.h>
  7. #include    <hdf/df.h>
  8. #include    "ViewProtos.h"
  9.  
  10. #define MAXRANK 10
  11.  
  12. int rank;
  13.  
  14. /* gets image size from HDF file */
  15. int
  16. getDataSize( char *filename, int *width, int *height,
  17.                float32 *min, float32 *max)
  18. {
  19.    int ret;
  20.    int ispalette;
  21.    int32 dimsizes[MAXRANK];
  22.    
  23.    
  24.    if( (ret=DFR8getdims(filename, width, height, &ispalette)) == -1)
  25.       return(ret);
  26.    
  27.    ret = DFSDgetdims(filename,&rank,dimsizes,MAXRANK);
  28.    ret = DFSDgetmaxmin(min,max);
  29.    if(ret==-1) { *max=0.0; *min=0.0; }
  30.    return(ispalette);
  31. }
  32.  
  33.  
  34.  
  35. /* gets the actual image from the file */
  36.  
  37. int getData(unsigned char *image, int width, int height, int ispal,
  38.             char *filename)
  39. {
  40.    int ret;
  41.    unsigned char palette[768];
  42.    
  43.    if( (ret=DFR8getimage(filename,image,width,height,palette)) == -1)
  44.       return(ret);
  45.       
  46.    if(ispal==1) setPal(palette);   
  47.    
  48.    return(1);
  49. }
  50.       
  51.