00001 00002 /*---------------------------------------------------------------------------- 00003 E.S.O. 00004 ----------------------------------------------------------------------------- 00005 File name : conversions.c 00006 Author : Nicolas Devillard 00007 Created on : Nov 14, 1995 00008 Hardware : Sun Sparc 20 00009 Software : ANSI C under Solaris Unix 00010 Part of ECLIPSE library for Adonis 00011 Description : bitmap value conversion routines 00012 ---------------------------------------------------------------------------*/ 00013 00014 /* 00015 00016 $Id: conversions.h,v 1.1 2003/09/03 12:50:47 amodigli Exp $ 00017 $Author: amodigli $ 00018 $Date: 2003/09/03 12:50:47 $ 00019 $Revision: 1.1 $ 00020 00021 */ 00022 00023 #ifndef _CONVERSIONS_H_ 00024 #define _CONVERSIONS_H_ 00025 00026 00027 /* 00028 * ---------------------------- IMPORTANT ----------------------------------- 00029 * 00030 * 00031 * Portability is an issue in this module ! 00032 * The FITS standard assumes the following: 00033 * 00034 * type # of bits 00035 * 00036 * char 8 00037 * short 16 00038 * long 32 00039 * float 32 00040 * double 64 00041 * 00042 * All these types are converted to the local internal float representation 00043 * thus bringing portability issues. To handle this: 00044 * 00045 * - FITS types are assumed, i.e. the above sizes are hardcoded, 00046 * instead of using sizeof, the numerical values are used (2, 4, and 8) 00047 * 00048 * - Only Intel and Motorola endian schemes shall be supported in this 00049 * version. Other schemes require much smarter algorithms and prevent 00050 * any optimization in these loops, increasing I/O a lot. 00051 * 00052 * - All types have been redefined, indicating bit numbers. It is 00053 * therefore COMPULSORY to use these types and no char, short, long 00054 * whenever the number of bits may be a problem, i.e. EVERYWHERE! 00055 */ 00056 00057 /*--------------------------------------------------------------------------- 00058 Includes 00059 ---------------------------------------------------------------------------*/ 00060 00061 #include <stdio.h> 00062 #include <stdlib.h> 00063 #include <math.h> 00064 #include <limits.h> 00065 00066 #include "local_types.h" 00067 #include "byteswap.h" 00068 #include "cube_defs.h" 00069 #include "image_stats.h" 00070 00071 00072 /*--------------------------------------------------------------------------- 00073 Defines 00074 ---------------------------------------------------------------------------*/ 00075 00076 00077 /* 00078 * The following include file has been generated at compile time to reflect 00079 * the local machine's endian-ness. 00080 * The trick is to compile "endian.c" before any other compilation, then 00081 * to use it to generate the endian_affairs include file. 00082 */ 00083 00084 #include "endian_affairs.h" 00085 00086 #define BPP_8_UNSIGNED (8) 00087 #define BPP_16_SIGNED (16) 00088 #define BPP_32_SIGNED (32) 00089 #define BPP_IEEE_FLOAT (-32) 00090 #define BPP_IEEE_DOUBLE (-64) 00091 00092 #define BPP_DEFAULT BPP_IEEE_FLOAT 00093 00094 #define BYTESPERPIXEL(x) ( ((x) == BPP_8_UNSIGNED) ? 1 : \ 00095 ((x) == BPP_16_SIGNED) ? 2 : \ 00096 ((x) == BPP_32_SIGNED) ? 4 : \ 00097 ((x) == BPP_IEEE_FLOAT) ? 4 : \ 00098 ((x) == BPP_IEEE_DOUBLE) ? 8 : 0 ) 00099 00100 00101 /*--------------------------------------------------------------------------- 00102 Function ANSI C prototypes 00103 ---------------------------------------------------------------------------*/ 00104 00105 /*---------------------------------------------------------------------------- 00106 Function : convert_fits_to_local() 00107 In : Destination pointer to pixelvalue, Source pointer to 00108 a BYTE array 00109 Out : void 00110 Job : Converts a BYTE data zone (+ data type) to pixelvalue 00111 pixelvalue is stored in local endian type 00112 Notice : Destination structure must be already allocated 00113 ---------------------------------------------------------------------------*/ 00114 00115 void 00116 convert_fits_to_local( 00117 pixelvalue * p_dest, 00118 BYTE * p_source, 00119 ulong32 nbpix, 00120 int pixel_type, 00121 double b_scale, 00122 double b_zero 00123 ) ; 00124 00125 00126 /*---------------------------------------------------------------------------- 00127 Function : convert_local_to_fits() 00128 In : Data, pixelvalue format 00129 Out : Data, FitsPielValue format 00130 Job : Convert data from memory format to FITS 00131 Notice : No scaling at all ! Beware of truncations ! 00132 ---------------------------------------------------------------------------*/ 00133 00134 void 00135 convert_local_to_fits( 00136 BYTE *p_dest, 00137 pixelvalue *p_source, 00138 ulong32 nbpix, 00139 int pixel_type 00140 ) ; 00141 00142 00143 /*---------------------------------------------------------------------------- 00144 Function : convert_local_to_ppm() 00145 In : image, lookup table 00146 Out : pointer to allocated byte buffer in PPM format 00147 Job : beautifies an image to output it into PPM format 00148 Notice : no header written into the buffer. 00149 a LUT has to be provided by the caller. 00150 ---------------------------------------------------------------------------*/ 00151 00152 BYTE * 00153 convert_local_to_ppm( 00154 OneImage *In, 00155 BYTE *lut 00156 ) ; 00157 00158 00159 /*---------------------------------------------------------------------------- 00160 Function : get_LUT() 00161 In : filename 00162 Out : LUT in BYTE format: 256 x 3 bytes (RGB) 00163 Job : gets a LUT from a file, or provide a default one 00164 Notice : input on 256 entries, output on 256 triple entries (RGB) 00165 ---------------------------------------------------------------------------*/ 00166 00167 BYTE * 00168 get_LUT( 00169 char *filename 00170 ) ; 00171 00172 00173 00174 /*--------------------------------------------------------------------------*/ 00175 #endif
1.2.13.1 written by Dimitri van Heesch,
© 1997-2001