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_image.hGo to the documentation of this file.00001 /*****************************************************************************/ 00002 // Copyright 2006-2008 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/workarea/stern/camera_raw/dng_sdk/source/dng_image.h#18 $ */ 00010 /* $DateTime: 2009/06/18 13:51:29 $ */ 00011 /* $Change: 577552 $ */ 00012 /* $Author: stern $ */ 00013 00018 /*****************************************************************************/ 00019 00020 #ifndef __dng_image__ 00021 #define __dng_image__ 00022 00023 /*****************************************************************************/ 00024 00025 #include "dng_assertions.h" 00026 #include "dng_classes.h" 00027 #include "dng_pixel_buffer.h" 00028 #include "dng_point.h" 00029 #include "dng_rect.h" 00030 #include "dng_tag_types.h" 00031 #include "dng_types.h" 00032 00033 /*****************************************************************************/ 00034 00037 00038 class dng_tile_buffer: public dng_pixel_buffer 00039 { 00040 00041 protected: 00042 00043 const dng_image &fImage; 00044 00045 void *fRefData; 00046 00047 protected: 00048 00053 00054 dng_tile_buffer (const dng_image &image, 00055 const dng_rect &tile, 00056 bool dirty); 00057 00058 virtual ~dng_tile_buffer (); 00059 00060 public: 00061 00062 void SetRefData (void *refData) 00063 { 00064 fRefData = refData; 00065 } 00066 00067 void * GetRefData () const 00068 { 00069 return fRefData; 00070 } 00071 00072 private: 00073 00074 // Hidden copy constructor and assignment operator. 00075 00076 dng_tile_buffer (const dng_tile_buffer &buffer); 00077 00078 dng_tile_buffer & operator= (const dng_tile_buffer &buffer); 00079 00080 }; 00081 00082 /*****************************************************************************/ 00083 00086 00087 class dng_const_tile_buffer: public dng_tile_buffer 00088 { 00089 00090 public: 00091 00095 00096 dng_const_tile_buffer (const dng_image &image, 00097 const dng_rect &tile); 00098 00099 virtual ~dng_const_tile_buffer (); 00100 00101 }; 00102 00103 /*****************************************************************************/ 00104 00107 00108 class dng_dirty_tile_buffer: public dng_tile_buffer 00109 { 00110 00111 public: 00112 00116 00117 dng_dirty_tile_buffer (dng_image &image, 00118 const dng_rect &tile); 00119 00120 virtual ~dng_dirty_tile_buffer (); 00121 00122 }; 00123 00124 /*****************************************************************************/ 00125 00128 00129 class dng_image 00130 { 00131 00132 friend class dng_tile_buffer; 00133 00134 protected: 00135 00136 // Bounds for this image. 00137 00138 dng_rect fBounds; 00139 00140 // Number of image planes. 00141 00142 uint32 fPlanes; 00143 00144 // Basic pixel type (TIFF tag type code). 00145 00146 uint32 fPixelType; 00147 00148 public: 00149 00151 00152 enum edge_option 00153 { 00154 00156 00157 edge_none, 00158 00160 00161 edge_zero, 00162 00164 00165 edge_repeat, 00166 00168 00169 edge_repeat_zero_last 00170 00171 }; 00172 00173 protected: 00174 00175 dng_image (const dng_rect &bounds, 00176 uint32 planes, 00177 uint32 pixelType); 00178 00179 public: 00180 00181 virtual ~dng_image (); 00182 00183 virtual dng_image * Clone () const; 00184 00186 00187 const dng_rect & Bounds () const 00188 { 00189 return fBounds; 00190 } 00191 00193 00194 dng_point Size () const 00195 { 00196 return Bounds ().Size (); 00197 } 00198 00200 00201 uint32 Width () const 00202 { 00203 return Bounds ().W (); 00204 } 00205 00207 00208 uint32 Height () const 00209 { 00210 return Bounds ().H (); 00211 } 00212 00214 00215 uint32 Planes () const 00216 { 00217 return fPlanes; 00218 } 00219 00223 00224 uint32 PixelType () const 00225 { 00226 return fPixelType; 00227 } 00228 00231 00232 virtual void SetPixelType (uint32 pixelType); 00233 00236 00237 uint32 PixelSize () const; 00238 00243 00244 uint32 PixelRange () const; 00245 00247 00248 virtual dng_rect RepeatingTile () const; 00249 00257 00258 void Get (dng_pixel_buffer &buffer, 00259 edge_option edgeOption = edge_none, 00260 uint32 repeatV = 1, 00261 uint32 repeatH = 1) const; 00262 00265 00266 void Put (const dng_pixel_buffer &buffer); 00267 00270 00271 virtual void Trim (const dng_rect &r); 00272 00275 00276 virtual void Rotate (const dng_orientation &orientation); 00277 00284 00285 void CopyArea (const dng_image &src, 00286 const dng_rect &area, 00287 uint32 srcPlane, 00288 uint32 dstPlane, 00289 uint32 planes); 00290 00296 00297 void CopyArea (const dng_image &src, 00298 const dng_rect &area, 00299 uint32 plane, 00300 uint32 planes) 00301 { 00302 00303 CopyArea (src, area, plane, plane, planes); 00304 00305 } 00306 00312 00313 bool EqualArea (const dng_image &rhs, 00314 const dng_rect &area, 00315 uint32 plane, 00316 uint32 planes) const; 00317 00318 // Routines to set the entire image to a constant value. 00319 00320 void SetConstant_uint8 (uint8 value, 00321 const dng_rect &area) 00322 { 00323 00324 DNG_ASSERT (fPixelType == ttByte, "Mismatched pixel type"); 00325 00326 SetConstant ((uint32) value, area); 00327 00328 } 00329 00330 void SetConstant_uint8 (uint8 value) 00331 { 00332 SetConstant (value, Bounds ()); 00333 } 00334 00335 void SetConstant_uint16 (uint16 value, 00336 const dng_rect &area) 00337 { 00338 00339 DNG_ASSERT (fPixelType == ttShort, "Mismatched pixel type"); 00340 00341 SetConstant ((uint32) value, area); 00342 00343 } 00344 00345 void SetConstant_uint16 (uint16 value) 00346 { 00347 SetConstant_uint16 (value, Bounds ()); 00348 } 00349 00350 void SetConstant_int16 (int16 value, 00351 const dng_rect &area) 00352 { 00353 00354 DNG_ASSERT (fPixelType == ttSShort, "Mismatched pixel type"); 00355 00356 SetConstant ((uint32) (uint16) value, area); 00357 00358 } 00359 00360 void SetConstant_int16 (int16 value) 00361 { 00362 SetConstant_int16 (value, Bounds ()); 00363 } 00364 00365 void SetConstant_uint32 (uint32 value, 00366 const dng_rect &area) 00367 { 00368 00369 DNG_ASSERT (fPixelType == ttLong, "Mismatched pixel type"); 00370 00371 SetConstant (value, area); 00372 00373 } 00374 00375 void SetConstant_uint32 (uint32 value) 00376 { 00377 SetConstant_uint32 (value, Bounds ()); 00378 } 00379 00380 void SetConstant_real32 (real32 value, 00381 const dng_rect &area) 00382 { 00383 00384 DNG_ASSERT (fPixelType == ttFloat, "Mismatched pixel type"); 00385 00386 union 00387 { 00388 uint32 i; 00389 real32 f; 00390 } x; 00391 00392 x.f = value; 00393 00394 SetConstant (x.i, area); 00395 00396 } 00397 00398 void SetConstant_real32 (real32 value) 00399 { 00400 SetConstant_real32 (value, Bounds ()); 00401 } 00402 00403 virtual void GetRepeat (dng_pixel_buffer &buffer, 00404 const dng_rect &srcArea, 00405 const dng_rect &dstArea) const; 00406 00407 protected: 00408 00409 virtual void AcquireTileBuffer (dng_tile_buffer &buffer, 00410 const dng_rect &area, 00411 bool dirty) const; 00412 00413 virtual void ReleaseTileBuffer (dng_tile_buffer &buffer) const; 00414 00415 virtual void DoGet (dng_pixel_buffer &buffer) const; 00416 00417 virtual void DoPut (const dng_pixel_buffer &buffer); 00418 00419 void GetEdge (dng_pixel_buffer &buffer, 00420 edge_option edgeOption, 00421 const dng_rect &srcArea, 00422 const dng_rect &dstArea) const; 00423 00424 virtual void SetConstant (uint32 value, 00425 const dng_rect &area); 00426 00427 }; 00428 00429 /*****************************************************************************/ 00430 00431 #endif 00432 00433 /*****************************************************************************/ |