Commit 9cff6a66 authored by Michael Natterer's avatar Michael Natterer 😴

file-fits: change data types to CamelCase and constants to CAPS

parent 95d7edf7
This diff is collapsed.
......@@ -29,61 +29,73 @@
#define FITS_NADD_CARDS 128
/* Data representations */
typedef unsigned char FITS_BITPIX8;
typedef short FITS_BITPIX16;
typedef long FITS_BITPIX32;
typedef float FITS_BITPIXM32;
typedef double FITS_BITPIXM64;
typedef int FITS_BOOL;
typedef long FITS_LONG;
typedef double FITS_DOUBLE;
typedef char FITS_STRING[FITS_CARD_SIZE];
typedef unsigned char FitsBitpix8;
typedef short FitsBitpix16;
typedef long FitsBitpix32;
typedef float FitsBitpixM32;
typedef double FitsBitpixM64;
typedef int FitsBool;
typedef long FitsLong;
typedef double FitsDouble;
typedef char FitsString[FITS_CARD_SIZE];
typedef enum
{
typ_bitpix8,
typ_bitpix16,
typ_bitpix32,
typ_bitpixm32,
typ_bitpixm64,
typ_fbool,
typ_flong,
typ_fdouble,
typ_fstring
} FITS_DATA_TYPES;
FITS_DATA_TYPE_BITPIX_8,
FITS_DATA_TYPE_BITPIX_16,
FITS_DATA_TYPE_BITPIX_32,
FITS_DATA_TYPE_BITPIX_M32,
FITS_DATA_TYPE_BITPIX_M64,
FITS_DATA_TYPE_FBOOL,
FITS_DATA_TYPE_FLONG,
FITS_DATA_TYPE_FDOUBLE,
FITS_DATA_TYPE_FSTRING
} FitsDataType;
typedef union
{
FitsBitpix8 bitpix8;
FitsBitpix16 bitpix16;
FitsBitpix32 bitpix32;
FitsBitpixM32 bitpixm32;
FitsBitpixM64 bitpixm64;
FitsBool fbool;
FitsLong flong;
FitsDouble fdouble;
FitsString fstring;
} FitsData;
/* How to transform FITS pixel values */
typedef struct
typedef struct _FitsPixTransform FitsPixTransform;
struct _FitsPixTransform
{
gdouble pixmin, pixmax; /* Pixel values [pixmin,pixmax] should be mapped */
gdouble datamin, datamax; /* to [datamin,datamax] */
gdouble replacement; /* datavalue to use for blank or NaN pixels */
gchar dsttyp; /* Destination typ ('c' = char) */
} FITS_PIX_TRANSFORM;
};
typedef union
{
FITS_BITPIX8 bitpix8;
FITS_BITPIX16 bitpix16;
FITS_BITPIX32 bitpix32;
FITS_BITPIXM32 bitpixm32;
FITS_BITPIXM64 bitpixm64;
FITS_BOOL fbool;
FITS_LONG flong;
FITS_DOUBLE fdouble;
FITS_STRING fstring;
} FITS_DATA;
typedef struct fits_record_list /* Record list */
/* Record list */
typedef struct _FitsRecordList FitsRecordList;
struct _FitsRecordList
{
gchar data[FITS_RECORD_SIZE];
struct fits_record_list *next_record;
} FITS_RECORD_LIST;
gchar data[FITS_RECORD_SIZE];
FitsRecordList *next_record;
};
/* Header and Data Unit List */
typedef struct fits_hdu_list /* Header and Data Unit List */
typedef struct _FitsHduList FitsHduList;
struct _FitsHduList
{
glong header_offset; /* Offset of header in the file */
glong data_offset; /* Offset of data in the file */
......@@ -125,13 +137,15 @@ typedef struct fits_hdu_list /* Header and Data Unit List */
gint groups; /* Random groups indicator */
gint extend; /* Extend flag */
FITS_RECORD_LIST *header_record_list; /* Header records read in */
FitsRecordList *header_record_list; /* Header records read in */
FitsHduList *next_hdu;
};
struct fits_hdu_list *next_hdu;
} FITS_HDU_LIST;
typedef struct _FitsFile FitsFile;
typedef struct
struct _FitsFile
{
FILE *fp; /* File pointer to fits file */
gchar openmode; /* Mode the file was opened (0, 'r', 'w') */
......@@ -141,43 +155,45 @@ typedef struct
gboolean nan_used; /* NaN's used in the file ? */
gboolean blank_used; /* Blank's used in the file ? */
FITS_HDU_LIST *hdu_list; /* Header and Data Unit List */
} FITS_FILE;
FitsHduList *hdu_list; /* Header and Data Unit List */
};
/* User callable functions of the FITS-library */
FITS_FILE * fits_open (const gchar *filename,
const gchar *openmode);
void fits_close (FITS_FILE *ff);
FITS_HDU_LIST * fits_add_hdu (FITS_FILE *ff);
gint fits_add_card (FITS_HDU_LIST *hdulist,
const gchar *card);
gint fits_write_header (FITS_FILE *ff,
FITS_HDU_LIST *hdulist);
FITS_HDU_LIST * fits_image_info (FITS_FILE *ff,
gint picind,
gint *hdupicind);
FITS_HDU_LIST * fits_seek_image (FITS_FILE *ff,
gint picind);
void fits_print_header (FITS_HDU_LIST *hdr);
FITS_DATA * fits_decode_card (const gchar *card,
FITS_DATA_TYPES data_type);
gchar * fits_search_card (FITS_RECORD_LIST *rl,
gchar *keyword);
gint fits_read_pixel (FITS_FILE *ff,
FITS_HDU_LIST *hdulist,
gint npix,
FITS_PIX_TRANSFORM *trans,
void *buf);
gchar * fits_get_error (void);
FitsFile * fits_open (const gchar *filename,
const gchar *openmode);
void fits_close (FitsFile *ff);
FitsHduList * fits_add_hdu (FitsFile *ff);
gint fits_add_card (FitsHduList *hdulist,
const gchar *card);
gint fits_write_header (FitsFile *ff,
FitsHduList *hdulist);
FitsHduList * fits_image_info (FitsFile *ff,
gint picind,
gint *hdupicind);
FitsHduList * fits_seek_image (FitsFile *ff,
gint picind);
void fits_print_header (FitsHduList *hdr);
FitsData * fits_decode_card (const gchar *card,
FitsDataType data_type);
gchar * fits_search_card (FitsRecordList *rl,
gchar *keyword);
gint fits_read_pixel (FitsFile *ff,
FitsHduList *hdulist,
gint npix,
FitsPixTransform *trans,
void *buf);
gchar * fits_get_error (void);
/* Demo functions */
#define FITS_NO_DEMO
gint fits_to_pgmraw (gchar *fitsfile,
gchar *pgmfile);
gint pgmraw_to_fits (gchar *pgmfile,
gchar *fitsfile);
gint fits_to_pgmraw (gchar *fitsfile,
gchar *pgmfile);
gint pgmraw_to_fits (gchar *pgmfile,
gchar *fitsfile);
#endif /* __FITS_IO_H__ */
......@@ -66,46 +66,46 @@ typedef struct
/* Declare some local functions.
*/
static void query (void);
static void run (const gchar *name,
gint nparams,
const GimpParam *param,
gint *nreturn_vals,
GimpParam **return_vals);
static gint32 load_image (const gchar *filename,
GError **error);
static gint save_image (const gchar *filename,
gint32 image_ID,
gint32 drawable_ID,
GError **error);
static FITS_HDU_LIST *create_fits_header (FITS_FILE *ofp,
guint width,
guint height,
guint bpp);
static gint save_fits (FITS_FILE *ofp,
gint32 image_ID,
gint32 drawable_ID);
static gint32 create_new_image (const gchar *filename,
guint pagenum,
guint width,
guint height,
GimpImageBaseType itype,
GimpImageType dtype,
gint32 *layer_ID,
GeglBuffer **buffer);
static void check_load_vals (void);
static gint32 load_fits (const gchar *filename,
FITS_FILE *ifp,
guint picnum,
guint ncompose);
static gboolean load_dialog (void);
static void show_fits_errors (void);
static void query (void);
static void run (const gchar *name,
gint nparams,
const GimpParam *param,
gint *nreturn_vals,
GimpParam **return_vals);
static gint32 load_image (const gchar *filename,
GError **error);
static gint save_image (const gchar *filename,
gint32 image_ID,
gint32 drawable_ID,
GError **error);
static FitsHduList * create_fits_header (FitsFile *ofp,
guint width,
guint height,
guint bpp);
static gint save_fits (FitsFile *ofp,
gint32 image_ID,
gint32 drawable_ID);
static gint32 create_new_image (const gchar *filename,
guint pagenum,
guint width,
guint height,
GimpImageBaseType itype,
GimpImageType dtype,
gint32 *layer_ID,
GeglBuffer **buffer);
static void check_load_vals (void);
static gint32 load_fits (const gchar *filename,
FitsFile *ifp,
guint picnum,
guint ncompose);
static gboolean load_dialog (void);
static void show_fits_errors (void);
static FITSLoadVals plvals =
......@@ -340,13 +340,13 @@ static gint32
load_image (const gchar *filename,
GError **error)
{
gint32 image_ID, *image_list, *nl;
guint picnum;
gint k, n_images, max_images, hdu_picnum;
gint compose;
FILE *fp;
FITS_FILE *ifp;
FITS_HDU_LIST *hdu;
gint32 image_ID, *image_list, *nl;
guint picnum;
gint k, n_images, max_images, hdu_picnum;
gint compose;
FILE *fp;
FitsFile *ifp;
FitsHduList *hdu;
fp = g_fopen (filename, "rb");
if (!fp)
......@@ -438,7 +438,7 @@ save_image (const gchar *filename,
gint32 drawable_ID,
GError **error)
{
FITS_FILE *ofp;
FitsFile *ofp;
GimpImageType drawable_type;
gint retval;
......@@ -535,22 +535,22 @@ create_new_image (const gchar *filename,
*/
static gint32
load_fits (const gchar *filename,
FITS_FILE *ifp,
FitsFile *ifp,
guint picnum,
guint ncompose)
{
register guchar *dest, *src;
guchar *data, *data_end, *linebuf;
int width, height, tile_height, scan_lines;
int i, j, max_scan;
double a, b;
gint32 layer_ID, image_ID;
GeglBuffer *buffer;
GimpImageBaseType itype;
GimpImageType dtype;
gint err = 0;
FITS_HDU_LIST *hdulist;
FITS_PIX_TRANSFORM trans;
register guchar *dest, *src;
guchar *data, *data_end, *linebuf;
int width, height, tile_height, scan_lines;
int i, j, max_scan;
double a, b;
gint32 layer_ID, image_ID;
GeglBuffer *buffer;
GimpImageBaseType itype;
GimpImageType dtype;
gint err = 0;
FitsHduList *hdulist;
FitsPixTransform trans;
hdulist = fits_seek_image (ifp, (int)picnum);
if (hdulist == NULL)
......@@ -740,14 +740,14 @@ load_fits (const gchar *filename,
}
static FITS_HDU_LIST *
create_fits_header (FITS_FILE *ofp,
guint width,
guint height,
guint bpp)
static FitsHduList *
create_fits_header (FitsFile *ofp,
guint width,
guint height,
guint bpp)
{
FITS_HDU_LIST *hdulist;
int print_ctype3 = 0; /* The CTYPE3-card may not be FITS-conforming */
FitsHduList *hdulist;
gint print_ctype3 = 0; /* The CTYPE3-card may not be FITS-conforming */
static const char *ctype3_card[] =
{
......@@ -812,9 +812,9 @@ create_fits_header (FITS_FILE *ofp,
/* Save direct colours (GRAY, GRAYA, RGB, RGBA) */
static gint
save_fits (FITS_FILE *ofp,
gint32 image_ID,
gint32 drawable_ID)
save_fits (FitsFile *ofp,
gint32 image_ID,
gint32 drawable_ID)
{
gint height, width, i, j, channel;
gint tile_height, bpp, bpsl;
......@@ -822,7 +822,7 @@ save_fits (FITS_FILE *ofp,
guchar *data, *src;
GeglBuffer *buffer;
const Babl *format = NULL;
FITS_HDU_LIST *hdu;
FitsHduList *hdu;
buffer = gimp_drawable_get_buffer (drawable_ID);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment