OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/utility/cloud_print/pwg_encoder.h" | 5 #include "chrome/utility/cloud_print/pwg_encoder.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/big_endian.h" | 9 #include "base/big_endian.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 // put the compressed image data in the string. Returns true on success. | 195 // put the compressed image data in the string. Returns true on success. |
196 // The content of the string is undefined on failure. | 196 // The content of the string is undefined on failure. |
197 bool PwgEncoder::EncodePage(const BitmapImage& image, | 197 bool PwgEncoder::EncodePage(const BitmapImage& image, |
198 const PwgHeaderInfo& pwg_header_info, | 198 const PwgHeaderInfo& pwg_header_info, |
199 std::string* output) const { | 199 std::string* output) const { |
200 // pwg_header_info.color_space can only contain color spaces that are | 200 // pwg_header_info.color_space can only contain color spaces that are |
201 // supported, so no sanity check is needed. | 201 // supported, so no sanity check is needed. |
202 switch (image.colorspace()) { | 202 switch (image.colorspace()) { |
203 case BitmapImage::RGBA: | 203 case BitmapImage::RGBA: |
204 return EncodePageWithColorspace<RGBA8>(image, pwg_header_info, output); | 204 return EncodePageWithColorspace<RGBA8>(image, pwg_header_info, output); |
205 break; | 205 |
206 case BitmapImage::BGRA: | 206 case BitmapImage::BGRA: |
207 return EncodePageWithColorspace<BGRA8>(image, pwg_header_info, output); | 207 return EncodePageWithColorspace<BGRA8>(image, pwg_header_info, output); |
208 break; | 208 |
209 default: | 209 default: |
210 LOG(ERROR) << "Unsupported colorspace."; | 210 LOG(ERROR) << "Unsupported colorspace."; |
211 return false; | 211 return false; |
212 } | 212 } |
213 | |
214 EncodePageHeader(image, pwg_header_info, output); | |
215 } | 213 } |
216 | 214 |
217 template <typename InputStruct> | 215 template <typename InputStruct> |
218 bool PwgEncoder::EncodePageWithColorspace(const BitmapImage& image, | 216 bool PwgEncoder::EncodePageWithColorspace(const BitmapImage& image, |
219 const PwgHeaderInfo& pwg_header_info, | 217 const PwgHeaderInfo& pwg_header_info, |
220 std::string* output) const { | 218 std::string* output) const { |
221 bool monochrome = pwg_header_info.color_space == PwgHeaderInfo::SGRAY; | 219 bool monochrome = pwg_header_info.color_space == PwgHeaderInfo::SGRAY; |
222 EncodePageHeader(image, pwg_header_info, output); | 220 EncodePageHeader(image, pwg_header_info, output); |
223 | 221 |
224 // Ensure no integer overflow. | 222 // Ensure no integer overflow. |
(...skipping 30 matching lines...) Expand all Loading... |
255 EncodeRow<InputStruct>(std::reverse_iterator<const uint32*>(row_end), | 253 EncodeRow<InputStruct>(std::reverse_iterator<const uint32*>(row_end), |
256 std::reverse_iterator<const uint32*>(pos), | 254 std::reverse_iterator<const uint32*>(pos), |
257 monochrome, | 255 monochrome, |
258 output); | 256 output); |
259 } | 257 } |
260 } | 258 } |
261 return true; | 259 return true; |
262 } | 260 } |
263 | 261 |
264 } // namespace cloud_print | 262 } // namespace cloud_print |
OLD | NEW |