OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "printing/image.h" | 5 #include "printing/image.h" |
6 | 6 |
| 7 #include <algorithm> |
| 8 |
7 #include "base/file_util.h" | 9 #include "base/file_util.h" |
8 #include "base/md5.h" | 10 #include "base/md5.h" |
9 #include "base/string_number_conversions.h" | 11 #include "base/string_number_conversions.h" |
10 #include "printing/metafile.h" | 12 #include "printing/metafile.h" |
11 #include "printing/metafile_impl.h" | 13 #include "printing/metafile_impl.h" |
12 #include "third_party/skia/include/core/SkColor.h" | 14 #include "third_party/skia/include/core/SkColor.h" |
13 #include "ui/gfx/codec/png_codec.h" | 15 #include "ui/gfx/codec/png_codec.h" |
14 | 16 |
15 namespace printing { | 17 namespace printing { |
16 | 18 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 bool success = gfx::PNGCodec::Decode( | 141 bool success = gfx::PNGCodec::Decode( |
140 reinterpret_cast<const unsigned char*>(compressed.c_str()), | 142 reinterpret_cast<const unsigned char*>(compressed.c_str()), |
141 compressed.size(), gfx::PNGCodec::FORMAT_BGRA, &data_, &w, &h); | 143 compressed.size(), gfx::PNGCodec::FORMAT_BGRA, &data_, &w, &h); |
142 size_.SetSize(w, h); | 144 size_.SetSize(w, h); |
143 row_length_ = size_.width() * sizeof(uint32); | 145 row_length_ = size_.width() * sizeof(uint32); |
144 return success; | 146 return success; |
145 } | 147 } |
146 | 148 |
147 bool Image::LoadMetafile(const std::string& data) { | 149 bool Image::LoadMetafile(const std::string& data) { |
148 DCHECK(!data.empty()); | 150 DCHECK(!data.empty()); |
149 printing::NativeMetafile metafile; | 151 NativeMetafile metafile; |
150 if (!metafile.InitFromData(data.data(), data.size())) | 152 if (!metafile.InitFromData(data.data(), data.size())) |
151 return false; | 153 return false; |
152 return LoadMetafile(metafile); | 154 return LoadMetafile(metafile); |
153 } | 155 } |
154 | 156 |
155 } // namespace printing | 157 } // namespace printing |
OLD | NEW |