1 // Copyright 2016 The PDFium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 6 7 #ifndef CORE_FXCODEC_JPEG_JPEGMODULE_H_ 8 #define CORE_FXCODEC_JPEG_JPEGMODULE_H_ 9 10 #include <stdint.h> 11 12 #include <memory> 13 14 #include "build/build_config.h" 15 #include "third_party/abseil-cpp/absl/types/optional.h" 16 #include "third_party/base/span.h" 17 18 #if BUILDFLAG(IS_WIN) 19 #include "core/fxcrt/retain_ptr.h" 20 #endif 21 22 class CFX_DIBBase; 23 24 namespace fxcodec { 25 26 class ScanlineDecoder; 27 28 class JpegModule { 29 public: 30 struct ImageInfo { 31 uint32_t width; 32 uint32_t height; 33 int num_components; 34 int bits_per_components; 35 bool color_transform; 36 }; 37 38 static std::unique_ptr<ScanlineDecoder> CreateDecoder( 39 pdfium::span<const uint8_t> src_span, 40 uint32_t width, 41 uint32_t height, 42 int nComps, 43 bool ColorTransform); 44 45 static absl::optional<ImageInfo> LoadInfo( 46 pdfium::span<const uint8_t> src_span); 47 48 #if BUILDFLAG(IS_WIN) 49 static bool JpegEncode(const RetainPtr<CFX_DIBBase>& pSource, 50 uint8_t** dest_buf, 51 size_t* dest_size); 52 #endif // BUILDFLAG(IS_WIN) 53 54 JpegModule() = delete; 55 JpegModule(const JpegModule&) = delete; 56 JpegModule& operator=(const JpegModule&) = delete; 57 }; 58 59 } // namespace fxcodec 60 61 using JpegModule = fxcodec::JpegModule; 62 63 #endif // CORE_FXCODEC_JPEG_JPEGMODULE_H_ 64