1 /* Panorama_Tools - Generate, Edit and Convert Panoramic Images
2 Copyright (C) 1998,1999 - Helmut Dersch der@fh-furtwangen.de
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
18 /*------------------------------------------------------------*/
29 // Determine which machine we are using. Macs are set to BIGENDIAN, all others not
31 // If you need BIGENDIAN, and don't use MacOS, define it here:
32 // #define BIGENDIAN 1
35 // Create a definition if we're on a Windows machine:
37 #if (defined(MSDOS) || defined(WIN32) || defined(__INTEL__))
43 // Create a definition if we're on a Macintosh:
45 #if (defined(macintosh) || defined(__MC68K__) || defined(__POWERPC__) || defined(__powerc))
53 // Use FSSpec on Macs as Path-specifyers, else strings
59 #define fullPath FSSpec
63 #else // __Mac__, use ANSI-filefunctions
66 // #include <windows.h>; including this causes problems with libjpeg
67 #define MAX_PATH_LENGTH 260
72 #define MAX_PATH_LENGTH 512
75 typedef struct{char name[MAX_PATH_LENGTH];} fullPath;
83 // Enumerates for TrFormStr.tool
85 enum{ // Panorama Tools
91 _sizep, // dummy for size-preferences
92 _version, // dummy for version
93 _panright, // Pan Controls
104 // Enumerates for TrFormStr.mode
107 _interactive, // display dialogs and do Xform
108 _useprefs, // load saved prefs and do Xform/ no dialogs
109 _setprefs, // display dialogs and set preferences, no Xform
110 _usedata, // use supplied data in TrFormStr.data, do Xform
111 _honor_valid = 8, // Use only pixels with alpha channel set
112 _show_progress = 16, // Interpolator displays progress bar
113 _hostCanResize = 32, // o-no; 1-yes (Photoshop: no; GraphicConverter: yes)
114 _destSupplied = 64, // Destination image allocated by plug-in host
115 _wrapX =128 // Wrap image horizontally (if HFOV==360 degrees)
119 // Enumerates for Image.dataformat
127 // Enumerates for TrFormStr.interpolator
129 enum{ // Interpolators
130 _poly3 = 0, // Third order polynomial fitting 16 nearest pixels
131 _spline16 = 1, // Cubic Spline fitting 16 nearest pixels
132 _spline36 = 2, // Cubic Spline fitting 36 nearest pixels
133 _sinc256 = 3, // Sinc windowed to 8 pixels
134 _spline64, // Cubic Spline fitting 64 nearest pixels
135 _bilinear, // Bilinear interpolation
136 _nn , // Nearest neighbor
142 struct correct_Prefs{ // Preferences structure for tool correct
143 unsigned long magic; // File validity check, must be 20
144 int radial; // Radial correction requested?
145 double radial_params[3][5]; // 3 colors x (4 coeffic. for 3rd order polys + correction radius)
146 int vertical; // Vertical shift requested ?
147 double vertical_params[3]; // 3 colors x vertical shift value
148 int horizontal; // horizontal tilt ( in screenpoints)
149 double horizontal_params[3]; // 3 colours x horizontal shift value
150 int shear; // shear correction requested?
151 double shear_x; // horizontal shear values
152 double shear_y; // vertical shear values
153 int resize; // scaling requested ?
154 long width; // new width
155 long height; // new height
156 int luminance; // correct luminance variation?
157 double lum_params[3]; // parameters for luminance corrections
158 int correction_mode; // 0 - radial correction;1 - vertical correction;2 - deregistration
159 int cutFrame; // remove frame? 0 - no; 1 - yes
163 int fourier; // Fourier filtering requested?
164 int fourier_mode; // _faddBlurr vs _fremoveBlurr
165 fullPath psf; // Point Spread Function, full path/fsspec to psd-file
166 int fourier_nf; // Noise filtering: _nf_internal vs _nf_custom
167 fullPath nff; // noise filtered file: full path/fsspec to psd-file
168 double filterfactor; // Hunt factor
169 double fourier_frame; // To correct edge errors
172 typedef struct correct_Prefs cPrefs;
175 correction_mode_radial = 0,
176 correction_mode_vertical = 1,
177 correction_mode_deregister = 2,
178 correction_mode_morph = 4
191 enum{ // Enumerates for Image.format
211 long bitsPerPixel; // Must be 24 or 32
213 unsigned char** data;
214 long dataformat; // rgb, Lab etc
215 long format; // Projection: rectilinear etc
220 cPrefs cP; // How to correct the image
224 typedef struct Image Image;
227 struct TrformStr // This structure holds all image information
229 Image *src; // Source image, must be supplied on entry
230 Image *dest; // Destination image data, valid if success = 1
231 long success; // 0 - no, 1 - yes
234 long tool; // Panorama Tool requested
235 long mode; // how to run transformation
236 void *data; // data for tool requested.
237 // Required only if mode = _usedata; then it
238 // must point to valid preferences structure
239 // for requested tool (see filter.h).
241 long interpolator; // Select interpolator
242 double gamma; // Gamma value for internal gamma correction
245 typedef struct TrformStr TrformStr;
248 // Useful for looping through images
250 #define LOOP_IMAGE( image, action ) { int x,y,bpp=(image)->bitsPerPixel/8; \
251 unsigned char *idata; \
252 for(y=0; y<(image)->height; y++){ \
253 idata = *((image)->data) + y * (image)->bytesPerLine; \
254 for(x=0; x<(image)->width;x++, idata+=bpp){ \