lensfun  0.2.7.0
lensfun.h
Go to the documentation of this file.
00001 /*
00002     LensFun - a library for maintaining a database of photographical lenses,
00003     and providing the means to correct some of the typical lens distortions.
00004     Copyright (C) 2007 by Andrew Zabolotny
00005 
00006     This library is free software; you can redistribute it and/or
00007     modify it under the terms of the GNU Library General Public
00008     License as published by the Free Software Foundation; either
00009     version 2 of the License, or (at your option) any later version.
00010 
00011     This library is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014     Library General Public License for more details.
00015 
00016     You should have received a copy of the GNU Library General Public
00017     License along with this library; if not, write to the Free
00018     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00019 */
00020 
00021 #ifndef __LENSFUN_H__
00022 #define __LENSFUN_H__
00023 
00024 #include <stddef.h>
00025 
00026 #ifdef __cplusplus
00027 extern "C" {
00029 #  define C_TYPEDEF(t,c)
00030 #else
00031 #  define C_TYPEDEF(t,c) typedef t c c;
00032 #endif
00033 
00039 /*----------------------------------------------------------------------------*/
00040 
00047 
00048 #define LF_VERSION_MAJOR        0
00049 
00050 #define LF_VERSION_MINOR        2
00051 
00052 #define LF_VERSION_MICRO        7
00053 
00054 #define LF_VERSION_BUGFIX       0
00055 
00056 #define LF_VERSION      ((LF_VERSION_MAJOR << 24) | (LF_VERSION_MINOR << 16) | (LF_VERSION_MICRO << 8) | LF_VERSION_BUGFIX)
00057 
00058 #if defined CONF_LENSFUN_STATIC
00059 
00060 #   define LF_EXPORT
00061 #else
00062 #   ifdef CONF_SYMBOL_VISIBILITY
00063 #       if defined PLATFORM_WINDOWS
00064 #           define LF_EXPORT    __declspec(dllexport)
00065 #       elif defined CONF_COMPILER_GCC
00066 #           define LF_EXPORT    __attribute__((visibility("default")))
00067 #       else
00068 #           error "I don't know how to change symbol visibility for your compiler"
00069 #       endif
00070 #   else
00071 #       if defined PLATFORM_WINDOWS || defined _MSC_VER
00072 #           define LF_EXPORT    __declspec(dllimport)
00073 #       else
00074 #           define LF_EXPORT
00075 #       endif
00076 #   endif
00077 #endif
00078 
00080 #define cbool int
00081 
00090 typedef char *lfMLstr;
00091 
00093 enum lfError
00094 {
00096     LF_NO_ERROR = 0,
00098     LF_WRONG_FORMAT
00099 };
00100 
00101 C_TYPEDEF (enum, lfError)
00102 
00103 
00111 LF_EXPORT void lf_free (void *data);
00112 
00119 LF_EXPORT const char *lf_mlstr_get (const lfMLstr str);
00120 
00136 LF_EXPORT lfMLstr lf_mlstr_add (lfMLstr str, const char *lang, const char *trstr);
00137 
00145 LF_EXPORT lfMLstr lf_mlstr_dup (const lfMLstr str);
00146 
00149 /*----------------------------------------------------------------------------*/
00150 
00166 struct LF_EXPORT lfMount
00167 {
00169     lfMLstr Name;
00171     char **Compat;
00172 
00173 #ifdef __cplusplus
00174 
00177     lfMount ();
00178 
00182     lfMount &operator = (const lfMount &other);
00183 
00187     ~lfMount ();
00188 
00197     void SetName (const char *val, const char *lang = NULL);
00198 
00204     void AddCompat (const char *val);
00205 
00211     bool Check ();
00212 #endif
00213 };
00214 
00215 C_TYPEDEF (struct, lfMount)
00216 
00217 
00224 LF_EXPORT lfMount *lf_mount_new ();
00225 
00234 LF_EXPORT void lf_mount_destroy (lfMount *mount);
00235 
00245 LF_EXPORT void lf_mount_copy (lfMount *dest, const lfMount *source);
00246 
00248 LF_EXPORT cbool lf_mount_check (lfMount *mount);
00249 
00252 /*----------------------------------------------------------------------------*/
00253 
00272 struct LF_EXPORT lfCamera
00273 {
00275     lfMLstr Maker;
00277     lfMLstr Model;
00279     lfMLstr Variant;
00281     char *Mount;
00283     float CropFactor;
00285     int Score;
00286 
00287 #ifdef __cplusplus
00288 
00291     lfCamera ();
00292 
00296     lfCamera (const lfCamera &other);
00297 
00301     ~lfCamera ();
00302 
00306     lfCamera &operator = (const lfCamera &other);
00307 
00316     void SetMaker (const char *val, const char *lang = NULL);
00317 
00326     void SetModel (const char *val, const char *lang = NULL);
00327 
00336     void SetVariant (const char *val, const char *lang = NULL);
00337 
00343     void SetMount (const char *val);
00344 
00350     bool Check ();
00351 #endif
00352 };
00353 
00354 C_TYPEDEF (struct, lfCamera)
00355 
00356 
00363 LF_EXPORT lfCamera *lf_camera_new ();
00364 
00373 LF_EXPORT void lf_camera_destroy (lfCamera *camera);
00374 
00384 LF_EXPORT void lf_camera_copy (lfCamera *dest, const lfCamera *source);
00385 
00387 LF_EXPORT cbool lf_camera_check (lfCamera *camera);
00388 
00391 /*----------------------------------------------------------------------------*/
00392 
00408 enum lfDistortionModel
00409 {
00411     LF_DIST_MODEL_NONE,
00417     LF_DIST_MODEL_POLY3,
00422     LF_DIST_MODEL_POLY5,
00428     LF_DIST_MODEL_FOV1,
00433     LF_DIST_MODEL_PTLENS,
00434 };
00435 
00436 C_TYPEDEF (enum, lfDistortionModel)
00437 
00438 
00443 struct lfLensCalibDistortion
00444 {
00446     enum lfDistortionModel Model;
00448     float Focal;
00450     float Terms [3];
00451 };
00452 
00453 C_TYPEDEF (struct, lfLensCalibDistortion)
00454 
00455 
00464 enum lfTCAModel
00465 {
00467     LF_TCA_MODEL_NONE,
00474     LF_TCA_MODEL_LINEAR,
00475 
00482     LF_TCA_MODEL_POLY3
00483 };
00484 
00485 C_TYPEDEF (enum, lfTCAModel)
00486 
00487 
00493 struct lfLensCalibTCA
00494 {
00496     enum lfTCAModel Model;
00498     float Focal;
00500     float Terms [6];
00501 };
00502 
00503 C_TYPEDEF (struct, lfLensCalibTCA)
00504 
00505 
00516 enum lfVignettingModel
00517 {
00519     LF_VIGNETTING_MODEL_NONE,
00526     LF_VIGNETTING_MODEL_PA
00527 };
00528 
00529 C_TYPEDEF (enum, lfVignettingModel)
00530 
00531 
00538 struct lfLensCalibVignetting
00539 {
00541     enum lfVignettingModel Model;
00543     float Focal;
00545     float Aperture;
00547     float Distance;
00549     float Terms [3];
00550 };
00551 
00552 C_TYPEDEF (struct, lfLensCalibVignetting)
00553 
00554 
00557 enum lfCropMode
00558 {
00560     LF_NO_CROP,
00562     LF_CROP_RECTANGLE,
00564     LF_CROP_CIRCLE
00565 };
00566 
00567 C_TYPEDEF(enum, lfCropMode)
00568 
00569 
00572 struct lfLensCalibCrop
00573 {
00575     float Focal;
00577     enum lfCropMode CropMode;
00586     float Crop [4];
00587 };
00588 
00589 C_TYPEDEF (struct, lfLensCalibCrop)
00590 
00591 
00594 struct lfLensCalibFov
00595 {
00597     float Focal;
00604     float FieldOfView;
00605 };
00606 
00607 C_TYPEDEF (struct, lfLensCalibFov)
00608 
00609 
00612 struct lfParameter
00613 {
00615     const char *Name;
00617     float Min;
00619     float Max;
00621     float Default;
00622 };
00623 
00624 C_TYPEDEF (struct, lfParameter)
00625 
00626 
00629 enum lfLensType
00630 {
00632     LF_UNKNOWN,
00634     LF_RECTILINEAR,
00639     LF_FISHEYE,
00641     LF_PANORAMIC,
00646     LF_EQUIRECTANGULAR,
00648     LF_FISHEYE_ORTHOGRAPHIC,
00650     LF_FISHEYE_STEREOGRAPHIC,
00652     LF_FISHEYE_EQUISOLID,
00654     LF_FISHEYE_THOBY
00655 };
00656 
00657 C_TYPEDEF (enum, lfLensType)
00658 
00659 
00669 struct LF_EXPORT lfLens
00670 {
00672     lfMLstr Maker;
00674     lfMLstr Model;
00676     float MinFocal;
00678     float MaxFocal;
00680     float MinAperture;
00682     float MaxAperture;
00684     char **Mounts;
00694     float CenterX;
00696     float CenterY;
00698     float RedCCI;
00700     float GreenCCI;
00702     float BlueCCI;
00704     float CropFactor;
00706     lfLensType Type;
00708     lfLensCalibDistortion **CalibDistortion;
00710     lfLensCalibTCA **CalibTCA;
00712     lfLensCalibVignetting **CalibVignetting;
00714     lfLensCalibCrop **CalibCrop;
00716     lfLensCalibFov **CalibFov;
00718     int Score;
00719 
00720 #ifdef __cplusplus
00721 
00724     lfLens ();
00725 
00729     lfLens (const lfLens &other);
00730 
00734     ~lfLens ();
00735 
00739     lfLens &operator = (const lfLens &other);
00740 
00749     void SetMaker (const char *val, const char *lang = NULL);
00750 
00759     void SetModel (const char *val, const char *lang = NULL);
00760 
00767     void AddMount (const char *val);
00768 
00776     void AddCalibDistortion (const lfLensCalibDistortion *dc);
00777 
00783     bool RemoveCalibDistortion (int idx);
00784 
00792     void AddCalibTCA (const lfLensCalibTCA *tcac);
00793 
00799     bool RemoveCalibTCA (int idx);
00800 
00808     void AddCalibVignetting (const lfLensCalibVignetting *vc);
00809 
00815     bool RemoveCalibVignetting (int idx);
00816 
00824     void AddCalibCrop (const lfLensCalibCrop *cc);
00825 
00831     bool RemoveCalibCrop (int idx);
00832 
00840     void AddCalibFov (const lfLensCalibFov *cf);
00841 
00847     bool RemoveCalibFov (int idx);
00848 
00856     void GuessParameters ();
00857 
00863     bool Check ();
00864 
00880     static const char *GetDistortionModelDesc (
00881         lfDistortionModel model, const char **details, const lfParameter ***params);
00897     static const char *GetTCAModelDesc (
00898         lfTCAModel model, const char **details, const lfParameter ***params);
00899 
00915     static const char *GetVignettingModelDesc (
00916         lfVignettingModel model, const char **details, const lfParameter ***params);
00917 
00933     static const char *GetCropDesc (
00934         lfCropMode mode, const char **details, const lfParameter ***params);
00935 
00947     static const char *GetLensTypeDesc (lfLensType type, const char **details);
00948 
00956     bool InterpolateDistortion (float focal, lfLensCalibDistortion &res) const;
00957 
00965     bool InterpolateTCA (float focal, lfLensCalibTCA &res) const;
00966 
00979     bool InterpolateVignetting (
00980         float focal, float aperture, float distance, lfLensCalibVignetting &res) const;
00981 
00989     bool InterpolateCrop (float focal, lfLensCalibCrop &res) const;
00990 
00998     bool InterpolateFov (float focal, lfLensCalibFov &res) const;
00999 #endif
01000 };
01001 
01002 C_TYPEDEF (struct, lfLens)
01003 
01004 
01011 LF_EXPORT lfLens *lf_lens_new ();
01012 
01021 LF_EXPORT void lf_lens_destroy (lfLens *lens);
01022 
01032 LF_EXPORT void lf_lens_copy (lfLens *dest, const lfLens *source);
01033 
01035 LF_EXPORT cbool lf_lens_check (lfLens *lens);
01036 
01038 LF_EXPORT void lf_lens_guess_parameters (lfLens *lens);
01039 
01041 LF_EXPORT const char *lf_get_distortion_model_desc (
01042     enum lfDistortionModel model, const char **details, const lfParameter ***params);
01043 
01045 LF_EXPORT const char *lf_get_tca_model_desc (
01046     enum lfTCAModel model, const char **details, const lfParameter ***params);
01047 
01049 LF_EXPORT const char *lf_get_vignetting_model_desc (
01050     enum lfVignettingModel model, const char **details, const lfParameter ***params);
01051 
01053 LF_EXPORT const char *lf_get_crop_desc (
01054     enum lfCropMode mode, const char **details, const lfParameter ***params);
01055 
01057 LF_EXPORT const char *lf_get_lens_type_desc (
01058     enum lfLensType type, const char **details);
01059 
01061 LF_EXPORT cbool lf_lens_interpolate_distortion (const lfLens *lens, float focal,
01062     lfLensCalibDistortion *res);
01063 
01065 LF_EXPORT cbool lf_lens_interpolate_tca (const lfLens *lens, float focal, lfLensCalibTCA *res);
01066 
01068 LF_EXPORT cbool lf_lens_interpolate_vignetting (const lfLens *lens, float focal, float aperture,
01069     float distance, lfLensCalibVignetting *res);
01070 
01072 LF_EXPORT cbool lf_lens_interpolate_crop (const lfLens *lens, float focal,
01073     lfLensCalibCrop *res);
01074 
01076 LF_EXPORT cbool lf_lens_interpolate_fov (const lfLens *lens, float focal,
01077     lfLensCalibFov *res);
01078 
01080 LF_EXPORT void lf_lens_add_calib_distortion (lfLens *lens, const lfLensCalibDistortion *dc);
01081 
01083 LF_EXPORT cbool lf_lens_remove_calib_distortion (lfLens *lens, int idx);
01084 
01086 LF_EXPORT void lf_lens_add_calib_tca (lfLens *lens, const lfLensCalibTCA *tcac);
01087 
01089 LF_EXPORT cbool lf_lens_remove_calib_tca (lfLens *lens, int idx);
01090 
01092 LF_EXPORT void lf_lens_add_calib_vignetting (lfLens *lens, const lfLensCalibVignetting *vc);
01093 
01095 LF_EXPORT cbool lf_lens_remove_calib_vignetting (lfLens *lens, int idx);
01096 
01098 LF_EXPORT void lf_lens_add_calib_crop (lfLens *lens, const lfLensCalibCrop *cc);
01099 
01101 LF_EXPORT cbool lf_lens_remove_calib_crop (lfLens *lens, int idx);
01102 
01104 LF_EXPORT void lf_lens_add_calib_fov (lfLens *lens, const lfLensCalibFov *cf);
01105 
01107 LF_EXPORT cbool lf_lens_remove_calib_fov (lfLens *lens, int idx);
01108 
01111 /*----------------------------------------------------------------------------*/
01112 
01122 enum
01123 {
01129     LF_SEARCH_LOOSE = 1
01130 };
01131 
01154 struct LF_EXPORT lfDatabase
01155 {
01157     char *HomeDataDir;
01158 
01159 #ifdef __cplusplus
01160 
01163     static lfDatabase *Create ();
01164 
01168     void Destroy ();
01169 
01178     lfError Load ();
01179 
01191     lfError Load (const char *filename);
01192 
01206     lfError Load (const char *errcontext, const char *data, size_t data_size);
01207 
01215     lfError Save (const char *filename) const;
01216 
01230     lfError Save (const char *filename,
01231                   const lfMount *const *mounts,
01232                   const lfCamera *const *cameras,
01233                   const lfLens *const *lenses) const;
01234 
01247     static char *Save (const lfMount *const *mounts,
01248                        const lfCamera *const *cameras,
01249                        const lfLens *const *lenses);
01250 
01274     const lfCamera **FindCameras (const char *maker, const char *model) const;
01275 
01295     const lfCamera **FindCamerasExt (const char *maker, const char *model,
01296                                      int sflags = 0) const;
01297 
01305     const lfCamera *const *GetCameras () const;
01306 
01343     const lfLens **FindLenses (const lfCamera *camera, const char *maker,
01344                                const char *model, int sflags = 0) const;
01345 
01363     const lfLens **FindLenses (const lfLens *lens, int sflags = 0) const;
01364 
01372     const lfLens *const *GetLenses () const;
01373 
01381     const lfMount *FindMount (const char *mount) const;
01382 
01390     const char *MountName (const char *mount) const;
01391 
01399     const lfMount *const *GetMounts () const;
01400 
01401 protected:
01402     /* Prevent user from creating and destroying such objects */
01403     lfDatabase () {}
01404     ~lfDatabase () {}
01405 #endif
01406 };
01407 
01408 C_TYPEDEF (struct, lfDatabase)
01409 
01410 
01419 LF_EXPORT lfDatabase *lf_db_new (void);
01420 
01429 LF_EXPORT void lf_db_destroy (lfDatabase *db);
01430 
01432 LF_EXPORT lfError lf_db_load (lfDatabase *db);
01433 
01435 LF_EXPORT lfError lf_db_load_file (lfDatabase *db, const char *filename);
01436 
01438 LF_EXPORT lfError lf_db_load_data (lfDatabase *db, const char *errcontext,
01439                                    const char *data, size_t data_size);
01440 
01442 LF_EXPORT lfError lf_db_save_all (const lfDatabase *db, const char *filename);
01443 
01445 LF_EXPORT lfError lf_db_save_file (const lfDatabase *db, const char *filename,
01446                                    const lfMount *const *mounts,
01447                                    const lfCamera *const *cameras,
01448                                    const lfLens *const *lenses);
01449 
01451 LF_EXPORT char *lf_db_save (const lfMount *const *mounts,
01452                             const lfCamera *const *cameras,
01453                             const lfLens *const *lenses);
01454 
01456 LF_EXPORT const lfCamera **lf_db_find_cameras (
01457     const lfDatabase *db, const char *maker, const char *model);
01458 
01460 LF_EXPORT const lfCamera **lf_db_find_cameras_ext (
01461     const lfDatabase *db, const char *maker, const char *model, int sflags);
01462 
01464 LF_EXPORT const lfCamera *const *lf_db_get_cameras (const lfDatabase *db);
01465 
01467 LF_EXPORT const lfLens **lf_db_find_lenses_hd (
01468     const lfDatabase *db, const lfCamera *camera, const char *maker,
01469     const char *lens, int sflags);
01470 
01472 LF_EXPORT const lfLens **lf_db_find_lenses (
01473     const lfDatabase *db, const lfLens *lens, int sflags);
01474 
01476 LF_EXPORT const lfLens *const *lf_db_get_lenses (const lfDatabase *db);
01477 
01479 LF_EXPORT const lfMount *lf_db_find_mount (const lfDatabase *db, const char *mount);
01480 
01482 LF_EXPORT const char *lf_db_mount_name (const lfDatabase *db, const char *mount);
01483 
01485 LF_EXPORT const lfMount *const *lf_db_get_mounts (const lfDatabase *db);
01486 
01489 /*----------------------------------------------------------------------------*/
01490 
01499 enum
01500 {
01502     LF_MODIFY_TCA        = 0x00000001,
01504     LF_MODIFY_VIGNETTING = 0x00000002,
01506     LF_MODIFY_CCI        = 0x00000004,
01508     LF_MODIFY_DISTORTION = 0x00000008,
01510     LF_MODIFY_GEOMETRY   = 0x00000010,
01512     LF_MODIFY_SCALE      = 0x00000020,
01514     LF_MODIFY_ALL        = ~0
01515 };
01516 
01518 enum lfPixelFormat
01519 {
01521     LF_PF_U8,
01523     LF_PF_U16,
01525     LF_PF_U32,
01527     LF_PF_F32,
01529     LF_PF_F64
01530 };
01531 
01532 C_TYPEDEF (enum, lfPixelFormat)
01533 
01534 
01535 enum lfComponentRole
01536 {
01541     LF_CR_END = 0,
01548     LF_CR_NEXT,
01550     LF_CR_UNKNOWN,
01552     LF_CR_INTENSITY,
01554     LF_CR_RED,
01556     LF_CR_GREEN,
01558     LF_CR_BLUE
01559 };
01560 
01561 C_TYPEDEF (enum, lfComponentRole)
01562 
01563 
01564 #define LF_CR_1(a)              (LF_CR_ ## a)
01565 
01566 #define LF_CR_2(a,b)            ((LF_CR_ ## a) | ((LF_CR_ ## b) << 4))
01567 
01568 #define LF_CR_3(a,b,c)          ((LF_CR_ ## a) | ((LF_CR_ ## b) << 4) | \
01569                                  ((LF_CR_ ## c) << 8))
01570 
01571 #define LF_CR_4(a,b,c,d)        ((LF_CR_ ## a) | ((LF_CR_ ## b) << 4) | \
01572                                  ((LF_CR_ ## c) << 8) | ((LF_CR_ ## d) << 12))
01573 
01574 #define LF_CR_5(a,b,c,d,e)      ((LF_CR_ ## a) | ((LF_CR_ ## b) << 4) | \
01575                                  ((LF_CR_ ## c) << 8) | ((LF_CR_ ## d) << 12) | \
01576                                  ((LF_CR_ ## e) << 16))
01577 
01578 #define LF_CR_6(a,b,c,d,e,f)    ((LF_CR_ ## a) | ((LF_CR_ ## b) << 4) | \
01579                                  ((LF_CR_ ## c) << 8) | ((LF_CR_ ## d) << 12) | \
01580                                  ((LF_CR_ ## e) << 16) | ((LF_CR_ ## f) << 20))
01581 
01582 #define LF_CR_7(a,b,c,d,e,f,g)   ((LF_CR_ ## a) | ((LF_CR_ ## b) << 4) | \
01583                                  ((LF_CR_ ## c) << 8) | ((LF_CR_ ## d) << 12) | \
01584                                  ((LF_CR_ ## e) << 16) | ((LF_CR_ ## f) << 20) | \
01585                                  ((LF_CR_ ## g) << 24))
01586 
01587 #define LF_CR_8(a,b,c,d,e,f,g,h) ((LF_CR_ ## a) | ((LF_CR_ ## b) << 4) | \
01588                                  ((LF_CR_ ## c) << 8) | ((LF_CR_ ## d) << 12) | \
01589                                  ((LF_CR_ ## e) << 16) | ((LF_CR_ ## f) << 20) | \
01590                                  ((LF_CR_ ## g) << 24) | ((LF_CR_ ## h) << 28))
01591 
01606 typedef void (*lfSubpixelCoordFunc) (void *data, float *iocoord, int count);
01607 
01631 typedef void (*lfModifyColorFunc) (void *data, float x, float y,
01632                                    void *pixels, int comp_role, int count);
01633 
01645 typedef void (*lfModifyCoordFunc) (void *data, float *iocoord, int count);
01646 
01706 struct LF_EXPORT lfModifier
01707 {
01708 #ifdef __cplusplus
01709 
01729     static lfModifier *Create (const lfLens *lens, float crop, int width, int height);
01730 
01771     int Initialize (
01772         const lfLens *lens, lfPixelFormat format, float focal, float aperture,
01773         float distance, float scale, lfLensType targeom, int flags, bool reverse);
01774 
01779     void Destroy ();
01780 
01797     void AddCoordCallback (lfModifyCoordFunc callback, int priority,
01798                            void *data, size_t data_size);
01799 
01817     void AddSubpixelCallback (lfSubpixelCoordFunc callback, int priority,
01818                               void *data, size_t data_size);
01819 
01836     void AddColorCallback (lfModifyColorFunc callback, int priority,
01837                            void *data, size_t data_size);
01838 
01852     bool AddSubpixelCallbackTCA (lfLensCalibTCA &model, bool reverse = false);
01853 
01868     bool AddColorCallbackVignetting (lfLensCalibVignetting &model, lfPixelFormat format,
01869                                      bool reverse = false);
01870 
01885     bool AddColorCallbackCCI (const lfLens *lens, lfPixelFormat format,
01886                               bool reverse = false);
01887 
01900     bool AddCoordCallbackDistortion (lfLensCalibDistortion &model, bool reverse = false);
01901 
01914     bool AddCoordCallbackGeometry (lfLensType from, lfLensType to, float focal);
01915 
01931     bool AddCoordCallbackScale (float scale, bool reverse = false);
01932 
01945     float GetAutoScale (bool reverse);
01946 
01975     bool ApplySubpixelDistortion (float xu, float yu, int width, int height,
01976                                   float *res) const;
01977 
02006     bool ApplyColorModification (void *pixels, float x, float y, int width, int height,
02007                                  int comp_role, int row_stride) const;
02008 
02035     bool ApplyGeometryDistortion (float xu, float yu, int width, int height,
02036                                   float *res) const;
02037 
02065     bool ApplySubpixelGeometryDistortion (float xu, float yu, int width, int height,
02066                                           float *res) const;
02067 
02068 protected:
02069     /* Prevent user from creating and destroying such objects */
02070     lfModifier () {}
02071     ~lfModifier () {}
02072 #elif defined _MSC_VER
02073     /* Sucks, like always */
02074     void *dummy;
02075 #endif
02076 };
02077 
02078 C_TYPEDEF (struct, lfModifier)
02079 
02080 
02081 LF_EXPORT lfModifier *lf_modifier_new (
02082     const lfLens *lens, float crop, int width, int height);
02083 
02085 LF_EXPORT void lf_modifier_destroy (lfModifier *modifier);
02086 
02088 LF_EXPORT int lf_modifier_initialize (
02089     lfModifier *modifier, const lfLens *lens, lfPixelFormat format,
02090     float focal, float aperture, float distance, float scale,
02091     lfLensType targeom, int flags, cbool reverse);
02092 
02094 LF_EXPORT void lf_modifier_add_coord_callback (
02095     lfModifier *modifier, lfModifyCoordFunc callback, int priority,
02096     void *data, size_t data_size);
02097 
02099 LF_EXPORT void lf_modifier_add_subpixel_callback (
02100     lfModifier *modifier, lfSubpixelCoordFunc callback, int priority,
02101     void *data, size_t data_size);
02102 
02104 LF_EXPORT void lf_modifier_add_color_callback (
02105     lfModifier *modifier, lfModifyColorFunc callback, int priority,
02106     void *data, size_t data_size);
02107 
02109 LF_EXPORT cbool lf_modifier_add_subpixel_callback_TCA (
02110     lfModifier *modifier, lfLensCalibTCA *model, cbool reverse);
02111 
02113 LF_EXPORT cbool lf_modifier_add_color_callback_vignetting (
02114     lfModifier *modifier, lfLensCalibVignetting *model,
02115     lfPixelFormat format, cbool reverse);
02116 
02118 LF_EXPORT cbool lf_modifier_add_color_callback_CCI (
02119     lfModifier *modifier, const lfLens *lens,
02120     lfPixelFormat format, cbool reverse);
02121 
02123 LF_EXPORT cbool lf_modifier_add_coord_callback_distortion (
02124     lfModifier *modifier, lfLensCalibDistortion *model, cbool reverse);
02125 
02127 LF_EXPORT cbool lf_modifier_add_coord_callback_geometry (
02128     lfModifier *modifier, lfLensType from, lfLensType to, float focal);
02129 
02131 LF_EXPORT cbool lf_modifier_add_coord_callback_scale (
02132     lfModifier *modifier, float scale, cbool reverse);
02133 
02135 LF_EXPORT float lf_modifier_get_auto_scale (
02136     lfModifier *modifier, cbool reverse);
02137 
02139 LF_EXPORT cbool lf_modifier_apply_subpixel_distortion (
02140     lfModifier *modifier, float xu, float yu, int width, int height, float *res);
02141 
02143 LF_EXPORT cbool lf_modifier_apply_color_modification (
02144     lfModifier *modifier, void *pixels, float x, float y, int width, int height,
02145     int comp_role, int row_stride);
02146 
02148 LF_EXPORT cbool lf_modifier_apply_geometry_distortion (
02149     lfModifier *modifier, float xu, float yu, int width, int height, float *res);
02150 
02152 LF_EXPORT cbool lf_modifier_apply_subpixel_geometry_distortion (
02153     lfModifier *modifier, float xu, float yu, int width, int height, float *res);
02154 
02157 #undef cbool
02158 
02159 #ifdef __cplusplus
02160 }
02161 #endif
02162 
02163 #endif /* __LENSFUN_H__ */