| 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 "tools/imagediff/image_diff_png.h" | 5 #include "tools/imagediff/image_diff_png.h" |
| 6 | 6 |
| 7 #include <stdlib.h> | 7 #include <stdlib.h> |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 // This is the default Windows DIB order. | 30 // This is the default Windows DIB order. |
| 31 FORMAT_BGRA, | 31 FORMAT_BGRA, |
| 32 | 32 |
| 33 // 4 bytes per pixel, in pre-multiplied kARGB_8888_Config format. For use | 33 // 4 bytes per pixel, in pre-multiplied kARGB_8888_Config format. For use |
| 34 // with directly writing to a skia bitmap. | 34 // with directly writing to a skia bitmap. |
| 35 FORMAT_SkBitmap | 35 FORMAT_SkBitmap |
| 36 }; | 36 }; |
| 37 | 37 |
| 38 // Represents a comment in the tEXt ancillary chunk of the png. | 38 // Represents a comment in the tEXt ancillary chunk of the png. |
| 39 struct Comment { | 39 struct Comment { |
| 40 Comment(const std::string& k, const std::string& t) | |
| 41 : key(k), text(t) { | |
| 42 } | |
| 43 | |
| 44 ~Comment() { | |
| 45 }; | |
| 46 | |
| 47 std::string key; | 40 std::string key; |
| 48 std::string text; | 41 std::string text; |
| 49 }; | 42 }; |
| 50 | 43 |
| 51 // Converts BGRA->RGBA and RGBA->BGRA. | 44 // Converts BGRA->RGBA and RGBA->BGRA. |
| 52 void ConvertBetweenBGRAandRGBA(const unsigned char* input, int pixel_width, | 45 void ConvertBetweenBGRAandRGBA(const unsigned char* input, int pixel_width, |
| 53 unsigned char* output, bool* is_opaque) { | 46 unsigned char* output, bool* is_opaque) { |
| 54 for (int x = 0; x < pixel_width; x++) { | 47 for (int x = 0; x < pixel_width; x++) { |
| 55 const unsigned char* pixel_in = &input[x * 4]; | 48 const unsigned char* pixel_in = &input[x * 4]; |
| 56 unsigned char* pixel_out = &output[x * 4]; | 49 unsigned char* pixel_out = &output[x * 4]; |
| (...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 641 int height, | 634 int height, |
| 642 int row_byte_width, | 635 int row_byte_width, |
| 643 bool discard_transparency, | 636 bool discard_transparency, |
| 644 std::vector<unsigned char>* output) { | 637 std::vector<unsigned char>* output) { |
| 645 return Encode(input, FORMAT_BGRA, | 638 return Encode(input, FORMAT_BGRA, |
| 646 width, height, row_byte_width, discard_transparency, | 639 width, height, row_byte_width, discard_transparency, |
| 647 std::vector<Comment>(), output); | 640 std::vector<Comment>(), output); |
| 648 } | 641 } |
| 649 | 642 |
| 650 } // image_diff_png | 643 } // image_diff_png |
| OLD | NEW |