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 / getHDF.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-11-11  |  961 b   |  44 lines

  1. #include <exec/types.h>
  2. #include <exec/memory.h>
  3. #include <hdf/df.h>
  4. #include <hdf/dfproto.h>
  5. #include <proto/exec.h>
  6. #include "viewprotos.h"
  7.  
  8. extern char *image;
  9.  
  10. extern int width, height;
  11. extern BOOL isscale;
  12. extern char hdffile[81];
  13. extern float32 min, max;
  14. extern struct Window *gWindow;
  15.  
  16.  
  17. /* get the HDF image and (de)/allocate memory for the image*/
  18. int
  19. getHDF()
  20. {
  21.    int ret;
  22.    int ispalette;
  23.    int oldwidth, oldheight;
  24.  
  25.    oldwidth = width;
  26.    oldheight = height;
  27.       ret = getDataSize(hdffile,&width,&height,&min,&max);
  28.       if(ret==-1) return(-1);
  29.       ispalette = ret;
  30.       
  31.       if(image) FreeMem(image,oldwidth*oldheight*sizeof(char));
  32.       image=NULL;
  33.       
  34.       image = (char *)AllocMem(width*height*sizeof(char),
  35.                      MEMF_PUBLIC | MEMF_CLEAR);
  36.         if(image == NULL) return(-2);
  37.       
  38.       ret = getData(image, width, height, ispalette, hdffile);
  39.         if( ret == -1) return(-3);
  40.       
  41.       return(1);   
  42. }
  43.  
  44.