1 /*****************************************************************************/ 2 // Copyright 2006-2012 Adobe Systems Incorporated 3 // All Rights Reserved. 4 // 5 // NOTICE: Adobe permits you to use, modify, and distribute this file in 6 // accordance with the terms of the Adobe license agreement accompanying it. 7 /*****************************************************************************/ 8 9 /* $Id: //mondo/dng_sdk_1_4/dng_sdk/source/dng_read_image.h#2 $ */ 10 /* $DateTime: 2012/06/05 11:05:39 $ */ 11 /* $Change: 833352 $ */ 12 /* $Author: tknoll $ */ 13 14 /** \file 15 * Support for DNG image reading. 16 */ 17 18 /*****************************************************************************/ 19 20 #ifndef __dng_read_image__ 21 #define __dng_read_image__ 22 23 /*****************************************************************************/ 24 25 #include "dng_auto_ptr.h" 26 #include "dng_classes.h" 27 #include "dng_image.h" 28 #include "dng_memory.h" 29 #include "dng_types.h" 30 31 /******************************************************************************/ 32 33 bool DecodePackBits (dng_stream &stream, 34 uint8 *dPtr, 35 int32 dstCount); 36 37 /*****************************************************************************/ 38 39 class dng_row_interleaved_image: public dng_image 40 { 41 42 private: 43 44 dng_image &fImage; 45 46 uint32 fFactor; 47 48 public: 49 50 dng_row_interleaved_image (dng_image &image, 51 uint32 factor); 52 53 virtual void DoGet (dng_pixel_buffer &buffer) const; 54 55 virtual void DoPut (const dng_pixel_buffer &buffer); 56 57 private: 58 59 int32 MapRow (int32 row) const; 60 61 }; 62 63 /*****************************************************************************/ 64 65 /// \brief 66 /// 67 /// 68 69 class dng_read_image 70 { 71 72 friend class dng_read_tiles_task; 73 74 protected: 75 76 enum 77 { 78 79 // Target size for buffer used to copy data to the image. 80 81 kImageBufferSize = 128 * 1024 82 83 }; 84 85 AutoPtr<dng_memory_block> fJPEGTables; 86 87 public: 88 89 dng_read_image (); 90 91 virtual ~dng_read_image (); 92 93 /// 94 /// \param 95 96 virtual bool CanRead (const dng_ifd &ifd); 97 98 /// 99 /// \param host Host used for memory allocation, progress updating, and abort testing. 100 /// \param ifd 101 /// \param stream Stream to read image data from. 102 /// \param image Result image to populate. 103 104 virtual void Read (dng_host &host, 105 const dng_ifd &ifd, 106 dng_stream &stream, 107 dng_image &image, 108 dng_jpeg_image *jpegImage, 109 dng_fingerprint *jpegDigest); 110 111 protected: 112 113 virtual bool ReadUncompressed (dng_host &host, 114 const dng_ifd &ifd, 115 dng_stream &stream, 116 dng_image &image, 117 const dng_rect &tileArea, 118 uint32 plane, 119 uint32 planes, 120 AutoPtr<dng_memory_block> &uncompressedBuffer, 121 AutoPtr<dng_memory_block> &subTileBlockBuffer); 122 123 virtual void DecodeLossyJPEG (dng_host &host, 124 dng_image &image, 125 const dng_rect &tileArea, 126 uint32 plane, 127 uint32 planes, 128 uint32 photometricInterpretation, 129 uint32 jpegDataSize, 130 uint8 *jpegDataInMemory); 131 132 virtual bool ReadBaselineJPEG (dng_host &host, 133 const dng_ifd &ifd, 134 dng_stream &stream, 135 dng_image &image, 136 const dng_rect &tileArea, 137 uint32 plane, 138 uint32 planes, 139 uint32 tileByteCount, 140 uint8 *jpegDataInMemory); 141 142 virtual bool ReadLosslessJPEG (dng_host &host, 143 const dng_ifd &ifd, 144 dng_stream &stream, 145 dng_image &image, 146 const dng_rect &tileArea, 147 uint32 plane, 148 uint32 planes, 149 uint32 tileByteCount, 150 AutoPtr<dng_memory_block> &uncompressedBuffer, 151 AutoPtr<dng_memory_block> &subTileBlockBuffer); 152 153 virtual bool CanReadTile (const dng_ifd &ifd); 154 155 virtual bool NeedsCompressedBuffer (const dng_ifd &ifd); 156 157 virtual void ByteSwapBuffer (dng_host &host, 158 dng_pixel_buffer &buffer); 159 160 virtual void DecodePredictor (dng_host &host, 161 const dng_ifd &ifd, 162 dng_pixel_buffer &buffer); 163 164 virtual void ReadTile (dng_host &host, 165 const dng_ifd &ifd, 166 dng_stream &stream, 167 dng_image &image, 168 const dng_rect &tileArea, 169 uint32 plane, 170 uint32 planes, 171 uint32 tileByteCount, 172 AutoPtr<dng_memory_block> &compressedBuffer, 173 AutoPtr<dng_memory_block> &uncompressedBuffer, 174 AutoPtr<dng_memory_block> &subTileBlockBuffer); 175 176 }; 177 178 /*****************************************************************************/ 179 180 #endif 181 182 /*****************************************************************************/ 183