Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(234)

Side by Side Diff: samples/image_diff_png.cc

Issue 1847583004: Move the fpdfsdk/include/javascript folder (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pdfium.gyp ('k') | xfa/fxjse/runtime.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // This is a duplicate of chromium's src/tools/imagediff/image_diff_png.cc 5 // This is a duplicate of chromium's src/tools/imagediff/image_diff_png.cc
6 // that has been modified to build in a pdfium environment, which itself 6 // that has been modified to build in a pdfium environment, which itself
7 // was duplicated as follows: 7 // was duplicated as follows:
8 8
9 // This is a duplicate of ui/gfx/codec/png_codec.cc, after removing code related 9 // This is a duplicate of ui/gfx/codec/png_codec.cc, after removing code related
10 // to Skia, that we can use when running layout tests with minimal dependencies. 10 // to Skia, that we can use when running layout tests with minimal dependencies.
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 const unsigned char* pixel_in = &rgba[x * 4]; 62 const unsigned char* pixel_in = &rgba[x * 4];
63 unsigned char* pixel_out = &rgb[x * 3]; 63 unsigned char* pixel_out = &rgb[x * 3];
64 pixel_out[0] = pixel_in[0]; 64 pixel_out[0] = pixel_in[0];
65 pixel_out[1] = pixel_in[1]; 65 pixel_out[1] = pixel_in[1];
66 pixel_out[2] = pixel_in[2]; 66 pixel_out[2] = pixel_in[2];
67 } 67 }
68 } 68 }
69 69
70 } // namespace 70 } // namespace
71 71
72 // Decoder -------------------------------------------------------------------- 72 // Decoder
73 // 73 //
74 // This code is based on WebKit libpng interface (PNGImageDecoder), which is 74 // This code is based on WebKit libpng interface (PNGImageDecoder), which is
75 // in turn based on the Mozilla png decoder. 75 // in turn based on the Mozilla png decoder.
76 76
77 namespace { 77 namespace {
78 78
79 // Gamma constants: We assume we're on Windows which uses a gamma of 2.2. 79 // Gamma constants: We assume we're on Windows which uses a gamma of 2.2.
80 const double kMaxGamma = 21474.83; // Maximum gamma accepted by png library. 80 const double kMaxGamma = 21474.83; // Maximum gamma accepted by png library.
81 const double kDefaultGamma = 2.2; 81 const double kDefaultGamma = 2.2;
82 const double kInverseGamma = 1.0 / kDefaultGamma; 82 const double kInverseGamma = 1.0 / kDefaultGamma;
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 // this file must be truncated. 348 // this file must be truncated.
349 output->clear(); 349 output->clear();
350 return false; 350 return false;
351 } 351 }
352 352
353 *w = state.width; 353 *w = state.width;
354 *h = state.height; 354 *h = state.height;
355 return true; 355 return true;
356 } 356 }
357 357
358 // Encoder -------------------------------------------------------------------- 358 // Encoder
359 // 359 //
360 // This section of the code is based on nsPNGEncoder.cpp in Mozilla 360 // This section of the code is based on nsPNGEncoder.cpp in Mozilla
361 // (Copyright 2005 Google Inc.) 361 // (Copyright 2005 Google Inc.)
362 362
363 namespace { 363 namespace {
364 364
365 // Passed around as the io_ptr in the png structs so our callbacks know where 365 // Passed around as the io_ptr in the png structs so our callbacks know where
366 // to write data. 366 // to write data.
367 struct PngEncoderState { 367 struct PngEncoderState {
368 explicit PngEncoderState(std::vector<unsigned char>* o) : out(o) {} 368 explicit PngEncoderState(std::vector<unsigned char>* o) : out(o) {}
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 int height, 635 int height,
636 int row_byte_width, 636 int row_byte_width,
637 bool discard_transparency, 637 bool discard_transparency,
638 std::vector<unsigned char>* output) { 638 std::vector<unsigned char>* output) {
639 return Encode(input, FORMAT_BGRA, 639 return Encode(input, FORMAT_BGRA,
640 width, height, row_byte_width, discard_transparency, 640 width, height, row_byte_width, discard_transparency,
641 std::vector<Comment>(), output); 641 std::vector<Comment>(), output);
642 } 642 }
643 643
644 } // namespace image_diff_png 644 } // namespace image_diff_png
OLDNEW
« no previous file with comments | « pdfium.gyp ('k') | xfa/fxjse/runtime.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698