| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/md5.h" | 8 #include "base/md5.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "gfx/codec/png_codec.h" | 10 #include "gfx/codec/png_codec.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 private: | 53 private: |
| 54 bool enable_again_; | 54 bool enable_again_; |
| 55 | 55 |
| 56 DISALLOW_COPY_AND_ASSIGN(DisableFontSmoothing); | 56 DISALLOW_COPY_AND_ASSIGN(DisableFontSmoothing); |
| 57 }; | 57 }; |
| 58 | 58 |
| 59 } // namespace | 59 } // namespace |
| 60 | 60 |
| 61 namespace printing { | 61 namespace printing { |
| 62 | 62 |
| 63 Image::Image(const std::wstring& filename) | 63 Image::Image(const FilePath& path) |
| 64 : row_length_(0), | 64 : row_length_(0), |
| 65 ignore_alpha_(true) { | 65 ignore_alpha_(true) { |
| 66 std::string data; | 66 std::string data; |
| 67 file_util::ReadFileToString(filename, &data); | 67 file_util::ReadFileToString(path, &data); |
| 68 std::wstring ext = file_util::GetFileExtensionFromPath(filename); | |
| 69 bool success = false; | 68 bool success = false; |
| 70 if (LowerCaseEqualsASCII(ext, "png")) { | 69 if (path.MatchesExtension(FILE_PATH_LITERAL(".png"))) { |
| 71 success = LoadPng(data); | 70 success = LoadPng(data); |
| 72 } else if (LowerCaseEqualsASCII(ext, "emf")) { | 71 } else if (path.MatchesExtension(FILE_PATH_LITERAL(".emf"))) { |
| 73 success = LoadMetafile(data); | 72 success = LoadMetafile(data); |
| 74 } else { | 73 } else { |
| 75 DCHECK(false); | 74 DCHECK(false); |
| 76 } | 75 } |
| 77 if (!success) { | 76 if (!success) { |
| 78 size_.SetSize(0, 0); | 77 size_.SetSize(0, 0); |
| 79 row_length_ = 0; | 78 row_length_ = 0; |
| 80 data_.clear(); | 79 data_.clear(); |
| 81 } | 80 } |
| 82 } | 81 } |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 true, false, false, false); | 253 true, false, false, false); |
| 255 } | 254 } |
| 256 #else | 255 #else |
| 257 NOTIMPLEMENTED(); | 256 NOTIMPLEMENTED(); |
| 258 #endif | 257 #endif |
| 259 | 258 |
| 260 return false; | 259 return false; |
| 261 } | 260 } |
| 262 | 261 |
| 263 } // namespace printing | 262 } // namespace printing |
| OLD | NEW |