1 #ifndef IMAGE_IO_JPEG_JPEG_IMAGE_EXTRACTOR_H_ // NOLINT 2 #define IMAGE_IO_JPEG_JPEG_IMAGE_EXTRACTOR_H_ // NOLINT 3 4 #include "image_io/base/data_destination.h" 5 #include "image_io/base/data_source.h" 6 #include "image_io/base/message_handler.h" 7 #include "image_io/jpeg/jpeg_info.h" 8 9 namespace photos_editing_formats { 10 namespace image_io { 11 12 /// A class that can make use of the data in a JpegInfo instance to transfer 13 /// Apple depth and GDepth/GImage images from a DataSource and ship it to a 14 /// DataDestination. 15 class JpegImageExtractor { 16 public: 17 /// @param jpeg_info The JpegInfo instance containing depth/image data. 18 /// @param data_source The DataSource from which to transfer depth/image data. 19 /// @param message_handler An optional message handler to write messages to. JpegImageExtractor(const JpegInfo & jpeg_info,DataSource * data_source,MessageHandler * message_handler)20 JpegImageExtractor(const JpegInfo& jpeg_info, DataSource* data_source, 21 MessageHandler* message_handler) 22 : jpeg_info_(jpeg_info), 23 data_source_(data_source), 24 message_handler_(message_handler) {} 25 26 /// This function extracts the Apple depth image from the DataSource and sends 27 /// the bytes to the DataDestination. 28 /// @param image_destination The DataDestination to receive the image data. 29 /// @return True if an image was extracted. 30 bool ExtractAppleDepthImage(DataDestination* image_destination); 31 32 /// This function extracts the Apple matte image from the DataSource and sends 33 /// the bytes to the DataDestination. 34 /// @param image_destination The DataDestination to receive the image data. 35 /// @return True if an image was extracted. 36 bool ExtractAppleMatteImage(DataDestination* image_destination); 37 38 /// This function extracts the GDepth type image from the DataSource and 39 /// sends the bytes to the DataDestination. 40 /// @param image_destination The DataDestination to receive the image data. 41 /// @return True if an image was extracted. 42 bool ExtractGDepthImage(DataDestination* image_destination); 43 44 /// This function extracts the GImage type image from the DataSource and 45 /// sends the bytes to the DataDestination. 46 /// @param image_destination The DataDestination to receive the image data. 47 /// @return True if an image was extracted. 48 bool ExtractGImageImage(DataDestination* image_destination); 49 50 private: 51 /// Worker function called for GDepth/GImage type image extraction. 52 /// @param xmp_info_type The type of image to extract. 53 /// @param image_destination The DataDestination to receive the image data. 54 /// @return True if an image was extracted. 55 bool ExtractImage(JpegXmpInfo::Type xmp_info_type, 56 DataDestination* image_destination); 57 58 /// Worker function called for Apple depth/matte type image extraction. 59 /// @param image_range The range of the image data to extract. If invalid, 60 /// the image_destination's StartTransfer/FinishTransfer functions are 61 /// still called, and this function will return true (i.e., zero bytes 62 /// "successfully" transferred). 63 /// @param image_destination The DataDestination to receive the image data. 64 /// @return True if the transfer succeeded. 65 bool ExtractImage(const DataRange& image_range, 66 DataDestination* image_destination); 67 68 /// The jpeg info object contains the location of the Apple and Google images. 69 JpegInfo jpeg_info_; 70 71 /// The data source from which the images are extracted. 72 DataSource* data_source_; 73 74 /// An optional message handler to write messages to. 75 MessageHandler* message_handler_; 76 }; 77 78 } // namespace image_io 79 } // namespace photos_editing_formats 80 81 #endif // IMAGE_IO_JPEG_JPEG_IMAGE_EXTRACTOR_H_ // NOLINT 82