1 // Copyright 2013 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef CHROME_UTILITY_CLOUD_PRINT_PWG_ENCODER_H_ 6 #define CHROME_UTILITY_CLOUD_PRINT_PWG_ENCODER_H_ 7 8 #include <string> 9 10 #include "base/basictypes.h" 11 12 namespace cloud_print { 13 14 class BitmapImage; 15 16 struct PwgHeaderInfo { PwgHeaderInfoPwgHeaderInfo17 PwgHeaderInfo() 18 : dpi(300), 19 total_pages(1), 20 flipx(false), 21 flipy(false), 22 color_space(SRGB), 23 duplex(false), 24 tumble(false) {} 25 enum ColorSpace { SGRAY = 18, SRGB = 19 }; 26 uint32 dpi; 27 uint32 total_pages; 28 bool flipx; 29 bool flipy; 30 ColorSpace color_space; 31 bool duplex; 32 bool tumble; 33 }; 34 35 class PwgEncoder { 36 public: 37 PwgEncoder(); 38 39 void EncodeDocumentHeader(std::string *output) const; 40 bool EncodePage(const BitmapImage& image, 41 const PwgHeaderInfo& pwg_header_info, 42 std::string* output) const; 43 44 private: 45 void EncodePageHeader(const BitmapImage& image, 46 const PwgHeaderInfo& pwg_header_info, 47 std::string* output) const; 48 49 template <typename InputStruct, class RandomAccessIterator> 50 void EncodeRow(RandomAccessIterator pos, 51 RandomAccessIterator row_end, 52 bool monochrome, 53 std::string* output) const; 54 55 template <typename InputStruct> 56 bool EncodePageWithColorspace(const BitmapImage& image, 57 const PwgHeaderInfo& pwg_header_info, 58 std::string* output) const; 59 60 const uint8* GetRow(const BitmapImage& image, int row, bool flipy) const; 61 }; 62 63 } // namespace cloud_print 64 65 #endif // CHROME_UTILITY_CLOUD_PRINT_PWG_ENCODER_H_ 66