00001 00002 /*---------------------------------------------------------------------------- 00003 00004 File name : conversions.h 00005 Author : Nicolas Devillard 00006 Created on : Nov 14, 1995 00007 Description : pixel value conversion routines 00008 00009 ---------------------------------------------------------------------------*/ 00010 /* 00011 $Id: conversions.h,v 1.7 2000/10/11 13:56:58 ndevilla Exp $ 00012 $Author: ndevilla $ 00013 $Date: 2000/10/11 13:56:58 $ 00014 $Revision: 1.7 $ 00015 */ 00016 00017 #ifndef _CONVERSIONS_H_ 00018 #define _CONVERSIONS_H_ 00019 00020 00021 /* 00022 * ---------------------------- IMPORTANT ----------------------------------- 00023 * 00024 * 00025 * Portability is an issue in this module ! 00026 * The FITS standard assumes the following: 00027 * 00028 * type # of bits 00029 * 00030 * char 8 00031 * short 16 00032 * long 32 00033 * float 32 00034 * double 64 00035 * 00036 * All these types are converted to the local internal float representation 00037 * thus bringing portability issues. To handle this: 00038 * 00039 * - FITS types are assumed, i.e. the above sizes are hardcoded, 00040 * instead of using sizeof, the numerical values are used (2, 4, and 8) 00041 * 00042 * - Only Intel and Motorola endian schemes shall be supported in this 00043 * version. Other schemes require much smarter algorithms and prevent 00044 * any optimization in these loops, increasing I/O a lot. 00045 * 00046 * - All types have been redefined, indicating bit numbers. It is 00047 * therefore COMPULSORY to use these types and no char, short, long 00048 * whenever the number of bits may be a problem, i.e. EVERYWHERE! 00049 */ 00050 00051 /*--------------------------------------------------------------------------- 00052 Includes 00053 ---------------------------------------------------------------------------*/ 00054 00055 #include <stdio.h> 00056 #include <stdlib.h> 00057 #include <math.h> 00058 #include <limits.h> 00059 00060 #include "local_types.h" 00061 #include "byteswap.h" 00062 #include "cube_defs.h" 00063 #include "image_stats.h" 00064 00065 00066 /*--------------------------------------------------------------------------- 00067 Defines 00068 ---------------------------------------------------------------------------*/ 00069 00070 00071 /* 00072 * The following include file has been generated at compile time to reflect 00073 * the local machine's endian-ness. 00074 * The trick is to compile "endian.c" before any other compilation, then 00075 * to use it to generate the endian_affairs include file. 00076 */ 00077 00078 #include "endian_affairs.h" 00079 00080 #define BPP_8_UNSIGNED (8) 00081 #define BPP_16_SIGNED (16) 00082 #define BPP_32_SIGNED (32) 00083 #define BPP_IEEE_FLOAT (-32) 00084 #define BPP_IEEE_DOUBLE (-64) 00085 00086 #define BPP_DEFAULT BPP_IEEE_FLOAT 00087 00088 #define BYTESPERPIXEL(x) ( ((x) == BPP_8_UNSIGNED) ? 1 : \ 00089 ((x) == BPP_16_SIGNED) ? 2 : \ 00090 ((x) == BPP_32_SIGNED) ? 4 : \ 00091 ((x) == BPP_IEEE_FLOAT) ? 4 : \ 00092 ((x) == BPP_IEEE_DOUBLE) ? 8 : 0 ) 00093 00094 00095 /*--------------------------------------------------------------------------- 00096 Function ANSI C prototypes 00097 ---------------------------------------------------------------------------*/ 00098 00099 /*-------------------------------------------------------------------------*/ 00123 /*--------------------------------------------------------------------------*/ 00124 00125 00126 void 00127 convert_fits_to_local( 00128 pixelvalue * p_dest, 00129 BYTE * p_source, 00130 int nbpix, 00131 int pixel_type, 00132 double b_scale, 00133 double b_zero 00134 ) ; 00135 00136 00137 /*-------------------------------------------------------------------------*/ 00160 /*--------------------------------------------------------------------------*/ 00161 00162 00163 void 00164 convert_local_to_fits( 00165 BYTE *p_dest, 00166 pixelvalue *p_source, 00167 int nbpix, 00168 int pixel_type 00169 ) ; 00170 00171 00172 00173 /*-------------------------------------------------------------------------*/ 00190 /*--------------------------------------------------------------------------*/ 00191 00192 00193 BYTE * 00194 convert_local_to_ppm( 00195 OneImage *In, 00196 BYTE *lut 00197 ) ; 00198 00199 00200 /*-------------------------------------------------------------------------*/ 00219 /*--------------------------------------------------------------------------*/ 00220 00221 BYTE * 00222 get_LUT( 00223 char *filename 00224 ) ; 00225 00226 00227 00228 #endif
1.2.13.1 written by Dimitri van Heesch,
© 1997-2001