X-Git-Url: https://cads.iiap.res.in/gitview/?p=fits2jpeg.git;a=blobdiff_plain;f=src%2Fimage.c;h=819158bd06ba1d82b70b4098b6b66778e8b09230;hp=6c48d6754c59c4a847efa4c7b26c3e09ef9ca44c;hb=ca5520b0c818f4ad57e2e57d557fc999f9dfe3c7;hpb=2ca6f2c81fda4aaafc2f754241b103370241ff05 diff --git a/src/image.c b/src/image.c index 6c48d67..819158b 100644 --- a/src/image.c +++ b/src/image.c @@ -24,6 +24,9 @@ /*Header Definitions*/ #include "fits2jpeg.h" +/*---------------------------------------------------------------------------* + * READ_FITS: To reads data from a fits image file.. (isn't that obvious?) + *---------------------------------------------------------------------------*/ void read_fits(char * fits_file_name, long * xdim, long * ydim, float ** data) { fitsfile *fptr; @@ -79,6 +82,9 @@ void scale_pixels(int scale, unsigned int npixels, float *data, /* the dynamic range is reduced to 255 for jpeg */ scl_data = (datamax - datamin)/(float)JMAXVAL; + /* we will end up with segfaults if scl_data = 0 */ + if (scl_data == 0) scl_data = 1; + for (i = 0; i < npixels; ++i) data[i] = (data[i] - datamin)/scl_data;