Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

Diff of /panorama.h [000000] .. [2a97a8] Maximize Restore

  Switch to unified view

a b/panorama.h
1
/* Panorama_Tools -   Generate, Edit and Convert Panoramic Images
2
   Copyright (C) 1998,1999 - Helmut Dersch  der@fh-furtwangen.de
3
   
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)
7
   any later version.
8
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.
13
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.  */
17
18
/*------------------------------------------------------------*/
19
20
21
22
#ifndef PANORAMA_H
23
#define PANORAMA_H
24
25
26
#include "version.h"
27
28
29
// Determine which machine we are using. Macs are set to BIGENDIAN, all others not
30
31
// If you need BIGENDIAN, and don't use MacOS, define it here:
32
// #define BIGENDIAN          1
33
34
35
// Create a definition if we're on a Windows machine:
36
#ifndef __Win__
37
  #if (defined(MSDOS) || defined(WIN32) || defined(__INTEL__))
38
      #define __Win__         1
39
  #endif
40
#endif
41
42
43
// Create a definition if we're on a Macintosh:
44
#ifndef __Mac__
45
  #if (defined(macintosh) || defined(__MC68K__) || defined(__POWERPC__) || defined(__powerc))
46
      #define __Mac__         1
47
      #define BIGENDIAN       1
48
  #endif
49
#endif
50
51
52
53
// Use FSSpec on Macs as Path-specifyers, else strings
54
#define PATH_SEP                          '/'
55
56
#ifdef __Mac__
57
58
  #include <Files.h>
59
  #define         fullPath                            FSSpec
60
  #undef  PATH_SEP
61
  #define PATH_SEP                                    ':'
62
63
#else // __Mac__, use ANSI-filefunctions
64
65
  #ifdef __Win__
66
      #ifndef __NO_SYSTEM__
67
          #include <windows.h> // including this causes problems with libjpeg
68
      #endif
69
      #define MAX_PATH_LENGTH     260
70
      // was MAX_PATH
71
      #undef  PATH_SEP
72
      #define PATH_SEP                            '\\'
73
  #else
74
      #define MAX_PATH_LENGTH     512
75
  #endif
76
77
  typedef struct{char name[MAX_PATH_LENGTH];} fullPath;
78
79
#endif
80
81
82
83
84
85
// Enumerates for TrFormStr.tool
86
87
enum{                         // Panorama Tools
88
      _perspective,                   
89
      _correct,
90
      _remap,
91
      _adjust,
92
      _interpolate,
93
      _sizep,                 // dummy for size-preferences
94
      _version,               // dummy for version
95
      _panright,              // Pan Controls
96
      _panleft,
97
      _panup,
98
      _pandown,
99
      _zoomin,
100
      _zoomout,
101
      _apply,
102
      _getPano,
103
      _increment
104
  };
105
106
// Enumerates for TrFormStr.mode
107
108
enum{                         // Modes
109
      _interactive,           // display dialogs and do Xform
110
      _useprefs,              // load saved prefs and do Xform/ no dialogs
111
      _setprefs,              // display dialogs and set preferences, no Xform    
112
      _usedata,               // use supplied data in TrFormStr.data, do Xform
113
      _honor_valid    = 8,    // Use only pixels with alpha channel set
114
      _show_progress  = 16,   // Interpolator displays progress bar
115
      _hostCanResize  = 32,   // o-no; 1-yes (Photoshop: no; GraphicConverter: yes)
116
      _destSupplied   = 64,   // Destination image allocated by plug-in host
117
      _wrapX      = 128   // Wrap image horizontally (if HFOV==360 degrees)
118
  };
119
      
120
121
// Enumerates for Image.dataformat
122
123
enum{                         
124
      _RGB,                   
125
      _Lab,
126
      _Grey
127
  };
128
129
// Enumerates for TrFormStr.interpolator
130
131
enum{                         // Interpolators
132
      _poly3      = 0,        // Third order polynomial fitting 16 nearest pixels
133
      _spline16   = 1,        // Cubic Spline fitting 16 nearest pixels
134
      _spline36   = 2,        // Cubic Spline fitting 36 nearest pixels
135
      _sinc256    = 3,        // Sinc windowed to 8 pixels
136
      _spline64,              // Cubic Spline fitting 64 nearest pixels
137
      _bilinear,              // Bilinear interpolation
138
      _nn ,                   // Nearest neighbor
139
      _sinc1024
140
  };
141
142
// Corrections
143
144
struct  correct_Prefs{                            //  Preferences structure for tool correct
145
      unsigned long   magic;                  //  File validity check, must be 20
146
      int             radial;                 //  Radial correction requested?
147
      double          radial_params[3][5];    //  3 colors x (4 coeffic. for 3rd order polys + correction radius)
148
      int             vertical;               //  Vertical shift requested ?
149
      double          vertical_params[3];     //  3 colors x vertical shift value
150
      int         horizontal;             //  horizontal tilt ( in screenpoints)
151
      double          horizontal_params[3];   //  3 colours x horizontal shift value
152
      int         shear;                  //  shear correction requested?
153
      double          shear_x;                //  horizontal shear values
154
      double          shear_y;                //  vertical shear values
155
      int             resize;                 //  scaling requested ?
156
      long            width;                  //  new width
157
      long            height;                 //  new height
158
      int         luminance;              //  correct luminance variation?
159
      double          lum_params[3];          //  parameters for luminance corrections
160
      int         correction_mode;        //  0 - radial correction;1 - vertical correction;2 - deregistration
161
      int         cutFrame;               //  remove frame? 0 - no; 1 - yes
162
      int         fwidth;
163
      int             fheight;
164
      int         frame;
165
      int         fourier;                //  Fourier filtering requested?
166
      int         fourier_mode;           //  _faddBlurr vs _fremoveBlurr
167
      fullPath        psf;                    //  Point Spread Function, full path/fsspec to psd-file
168
      int         fourier_nf;             //  Noise filtering: _nf_internal vs _nf_custom
169
      fullPath        nff;                    //  noise filtered file: full path/fsspec to psd-file
170
      double          filterfactor;           //  Hunt factor
171
      double          fourier_frame;          //  To correct edge errors
172
      } ;
173
174
typedef struct correct_Prefs cPrefs;
175
176
enum{
177
  correction_mode_radial      = 0,
178
  correction_mode_vertical    = 1,
179
  correction_mode_deregister  = 2,
180
  correction_mode_morph       = 4
181
  };
182
  
183
184
enum{
185
  _faddBlurr,
186
  _fremoveBlurr,
187
  _nf_internal,
188
  _nf_custom,
189
  _fresize
190
  };
191
  
192
193
enum{             // Enumerates for Image.format
194
  _rectilinear    = 0,
195
  _panorama       = 1,
196
  _fisheye_circ   = 2,
197
  _fisheye_ff     = 3,
198
  _equirectangular= 4,
199
  _spherical_cp   = 5,
200
  _spherical_tp   = 6,
201
  _mirror         = 7,
202
  _orthographic   = 8,
203
  _cubic          = 9
204
  };
205
206
// A large rectangle
207
208
typedef struct{
209
  long    top;
210
  long    bottom;
211
  long    left;
212
  long    right;
213
  }   PTRect;
214
215
216
217
struct Image{
218
      // Pixel data
219
      long            width;
220
      long            height;
221
      long            bytesPerLine;
222
      long            bitsPerPixel;   // Must be 24 or 32
223
      unsigned long   dataSize; 
224
      unsigned char** data;
225
      long            dataformat;     // rgb, Lab etc
226
      long            format;         // Projection: rectilinear etc
227
      double          hfov;
228
      double          yaw;
229
      double          pitch;
230
      double          roll;
231
      cPrefs          cP;             // How to correct the image
232
      char            name[256];
233
      PTRect          selection;
234
  };
235
      
236
typedef struct Image Image;
237
238
239
struct TrformStr              // This structure holds all image information
240
  {
241
      Image *src;             // Source image, must be supplied on entry
242
      Image *dest;            // Destination image data, valid if success = 1 
243
      long success;           // 0 - no, 1 - yes 
244
245
246
      long tool;              // Panorama Tool requested
247
      long mode;              // how to run transformation
248
      void *data;             // data for tool requested.
249
                              // Required only if mode = _usedata; then it
250
                              // must point to valid preferences structure
251
                              // for requested tool (see filter.h).
252
253
      long interpolator;      // Select interpolator
254
      double gamma;           // Gamma value for internal gamma correction
255
  };
256
257
typedef struct TrformStr TrformStr;   
258
259
260
// Useful for looping through images
261
262
#define LOOP_IMAGE( image, action ) {     int x,y,bpp=(image)->bitsPerPixel/8; \
263
                  unsigned char *idata;                                       \
264
                  for(y=0; y<(image)->height; y++){                           \
265
                      idata = *((image)->data) + y * (image)->bytesPerLine;   \
266
                      for(x=0; x<(image)->width;x++, idata+=bpp){             \
267
                          action;} } }                                
268
                                          
269
                                          
270
                                          
271
                                          
272
                                          
273
274
void filter_main();
275
276
277
#endif // PANORAMA_H
278
279