OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <algorithm> | 5 #include <algorithm> |
6 #include <iomanip> | 6 #include <iomanip> |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 std::vector<unsigned char> png; | 194 std::vector<unsigned char> png; |
195 gfx::PNGCodec::ColorFormat color_format = gfx::PNGCodec::FORMAT_RGBA; | 195 gfx::PNGCodec::ColorFormat color_format = gfx::PNGCodec::FORMAT_RGBA; |
196 if (!gfx::PNGCodec::Encode( | 196 if (!gfx::PNGCodec::Encode( |
197 reinterpret_cast<const unsigned char*>(bmp.getPixels()), | 197 reinterpret_cast<const unsigned char*>(bmp.getPixels()), |
198 color_format, gfx::Size(bmp.width(), bmp.height()), | 198 color_format, gfx::Size(bmp.width(), bmp.height()), |
199 static_cast<int>(bmp.rowBytes()), | 199 static_cast<int>(bmp.rowBytes()), |
200 false, std::vector<gfx::PNGCodec::Comment>(), &png)) { | 200 false, std::vector<gfx::PNGCodec::Comment>(), &png)) { |
201 FAIL() << "Failed to encode image"; | 201 FAIL() << "Failed to encode image"; |
202 } | 202 } |
203 | 203 |
204 const FilePath fpath(path); | 204 const base::FilePath fpath(path); |
205 const int num_written = | 205 const int num_written = |
206 file_util::WriteFile(fpath, reinterpret_cast<const char*>(&png[0]), | 206 file_util::WriteFile(fpath, reinterpret_cast<const char*>(&png[0]), |
207 png.size()); | 207 png.size()); |
208 if (num_written != static_cast<int>(png.size())) { | 208 if (num_written != static_cast<int>(png.size())) { |
209 FAIL() << "Failed to write dest \"" << path << '"'; | 209 FAIL() << "Failed to write dest \"" << path << '"'; |
210 } | 210 } |
211 } | 211 } |
212 #endif // #if DEBUG_BITMAP_GENERATION | 212 #endif // #if DEBUG_BITMAP_GENERATION |
213 | 213 |
214 void CheckResampleToSame(skia::ImageOperations::ResizeMethod method) { | 214 void CheckResampleToSame(skia::ImageOperations::ResizeMethod method) { |
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
625 ADD_FAILURE() << "Maximum observed color distance: " | 625 ADD_FAILURE() << "Maximum observed color distance: " |
626 << max_observed_distance; | 626 << max_observed_distance; |
627 | 627 |
628 #if DEBUG_BITMAP_GENERATION | 628 #if DEBUG_BITMAP_GENERATION |
629 SaveBitmapToPNG(src, "/tmp/CompareLanczosMethods_source.png"); | 629 SaveBitmapToPNG(src, "/tmp/CompareLanczosMethods_source.png"); |
630 SaveBitmapToPNG(dest_l2, "/tmp/CompareLanczosMethods_lanczos2.png"); | 630 SaveBitmapToPNG(dest_l2, "/tmp/CompareLanczosMethods_lanczos2.png"); |
631 SaveBitmapToPNG(dest_l3, "/tmp/CompareLanczosMethods_lanczos3.png"); | 631 SaveBitmapToPNG(dest_l3, "/tmp/CompareLanczosMethods_lanczos3.png"); |
632 #endif // #if DEBUG_BITMAP_GENERATION | 632 #endif // #if DEBUG_BITMAP_GENERATION |
633 } | 633 } |
634 } | 634 } |
OLD | NEW |