DocumentationOverviewBuilding ASL Documentation Library Wiki Docs Indices Browse Perforce More InfoRelease NotesWiki Site Search License Success Stories Contributors MediaDownloadPerforce Depots SupportASL SourceForge HomeMailing Lists Discussion Forums Report Bugs Suggest Features Contribute to ASL RSSShort-text newsFull-text news File releases Other Adobe ProjectsAdobe AirAdobe GIL Adobe Labs Adobe Media Gallery Adobe XMP Tamarin project (Mozilla Foundation) Other ResourcesBoostRIAForge SGI STL |
dng_resample.h00001 /*****************************************************************************/ 00002 // Copyright 2006-2007 Adobe Systems Incorporated 00003 // All Rights Reserved. 00004 // 00005 // NOTICE: Adobe permits you to use, modify, and distribute this file in 00006 // accordance with the terms of the Adobe license agreement accompanying it. 00007 /*****************************************************************************/ 00008 00009 /* $Id: //mondo/dng_sdk_1_2/dng_sdk/source/dng_resample.h#1 $ */ 00010 /* $DateTime: 2008/03/09 14:29:54 $ */ 00011 /* $Change: 431850 $ */ 00012 /* $Author: tknoll $ */ 00013 00014 /*****************************************************************************/ 00015 00016 #ifndef __dng_resample__ 00017 #define __dng_resample__ 00018 00019 /*****************************************************************************/ 00020 00021 #include "dng_assertions.h" 00022 #include "dng_auto_ptr.h" 00023 #include "dng_classes.h" 00024 #include "dng_memory.h" 00025 #include "dng_types.h" 00026 00027 /*****************************************************************************/ 00028 00029 class dng_resample_function 00030 { 00031 00032 public: 00033 00034 dng_resample_function () 00035 { 00036 } 00037 00038 virtual ~dng_resample_function () 00039 { 00040 } 00041 00042 virtual real64 Extent () const = 0; 00043 00044 virtual real64 Evaluate (real64 x) const = 0; 00045 00046 }; 00047 00048 /*****************************************************************************/ 00049 00050 class dng_resample_bicubic: public dng_resample_function 00051 { 00052 00053 public: 00054 00055 virtual real64 Extent () const; 00056 00057 virtual real64 Evaluate (real64 x) const; 00058 00059 static const dng_resample_function & Get (); 00060 00061 }; 00062 00063 /******************************************************************************/ 00064 00065 const uint32 kResampleSubsampleBits = 7; 00066 const uint32 kResampleSubsampleCount = 1 << kResampleSubsampleBits; 00067 const uint32 kResampleSubsampleMask = kResampleSubsampleCount - 1; 00068 00069 /*****************************************************************************/ 00070 00071 class dng_resample_coords 00072 { 00073 00074 protected: 00075 00076 int32 fOrigin; 00077 00078 AutoPtr<dng_memory_block> fCoords; 00079 00080 public: 00081 00082 dng_resample_coords (); 00083 00084 virtual ~dng_resample_coords (); 00085 00086 void Initialize (int32 srcOrigin, 00087 int32 dstOrigin, 00088 uint32 srcCount, 00089 uint32 dstCount, 00090 dng_memory_allocator &allocator); 00091 00092 const int32 * Coords (int32 index) const 00093 { 00094 return fCoords->Buffer_int32 () + (index - fOrigin); 00095 } 00096 00097 const int32 Pixel (int32 index) const 00098 { 00099 return Coords (index) [0] >> kResampleSubsampleBits; 00100 } 00101 00102 }; 00103 00104 /*****************************************************************************/ 00105 00106 class dng_resample_weights 00107 { 00108 00109 protected: 00110 00111 uint32 fRadius; 00112 00113 uint32 fWeightStep; 00114 00115 AutoPtr<dng_memory_block> fWeights32; 00116 AutoPtr<dng_memory_block> fWeights16; 00117 00118 public: 00119 00120 dng_resample_weights (); 00121 00122 virtual ~dng_resample_weights (); 00123 00124 void Initialize (real64 scale, 00125 const dng_resample_function &kernel, 00126 dng_memory_allocator &allocator); 00127 00128 uint32 Radius () const 00129 { 00130 return fRadius; 00131 } 00132 00133 uint32 Width () const 00134 { 00135 return fRadius * 2; 00136 } 00137 00138 int32 Offset () const 00139 { 00140 return 1 - (int32) fRadius; 00141 } 00142 00143 uint32 Step () const 00144 { 00145 return fWeightStep; 00146 } 00147 00148 const real32 *Weights32 (uint32 fract) const 00149 { 00150 00151 DNG_ASSERT (fWeights32->Buffer (), "Weights32 is NULL"); 00152 00153 return fWeights32->Buffer_real32 () + fract * fWeightStep; 00154 00155 } 00156 00157 const int16 *Weights16 (uint32 fract) const 00158 { 00159 00160 DNG_ASSERT (fWeights16->Buffer (), "Weights16 is NULL"); 00161 00162 return fWeights16->Buffer_int16 () + fract * fWeightStep; 00163 00164 } 00165 00166 }; 00167 00168 /*****************************************************************************/ 00169 00170 void ResampleImage (dng_host &host, 00171 const dng_image &srcImage, 00172 dng_image &dstImage, 00173 const dng_rect &srcBounds, 00174 const dng_rect &dstBounds, 00175 const dng_resample_function &kernel); 00176 00177 /*****************************************************************************/ 00178 00179 #endif 00180 00181 /*****************************************************************************/ | |||
