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

Side by Side Diff: ui/gfx/color_analysis.cc

Issue 1499423004: Remove kint32max. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@kint9
Patch Set: rebase Created 5 years 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 | « ppapi/shared_impl/id_assignment.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "ui/gfx/color_analysis.h" 5 #include "ui/gfx/color_analysis.h"
6 6
7 #include <stdint.h>
8
7 #include <algorithm> 9 #include <algorithm>
8 #include <limits> 10 #include <limits>
9 #include <vector> 11 #include <vector>
10 12
11 #include "base/logging.h" 13 #include "base/logging.h"
12 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
13 #include "third_party/skia/include/core/SkBitmap.h" 15 #include "third_party/skia/include/core/SkBitmap.h"
14 #include "third_party/skia/include/core/SkUnPreMultiply.h" 16 #include "third_party/skia/include/core/SkUnPreMultiply.h"
15 #include "ui/gfx/codec/png_codec.h" 17 #include "ui/gfx/codec/png_codec.h"
16 #include "ui/gfx/color_utils.h" 18 #include "ui/gfx/color_utils.h"
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 } 181 }
180 182
181 SkColor FindClosestColor(const uint8_t* image, 183 SkColor FindClosestColor(const uint8_t* image,
182 int width, 184 int width,
183 int height, 185 int height,
184 SkColor color) { 186 SkColor color) {
185 uint8_t in_r = SkColorGetR(color); 187 uint8_t in_r = SkColorGetR(color);
186 uint8_t in_g = SkColorGetG(color); 188 uint8_t in_g = SkColorGetG(color);
187 uint8_t in_b = SkColorGetB(color); 189 uint8_t in_b = SkColorGetB(color);
188 // Search using distance-squared to avoid expensive sqrt() operations. 190 // Search using distance-squared to avoid expensive sqrt() operations.
189 int best_distance_squared = kint32max; 191 int best_distance_squared = std::numeric_limits<int32_t>::max();
190 SkColor best_color = color; 192 SkColor best_color = color;
191 const uint8_t* byte = image; 193 const uint8_t* byte = image;
192 for (int i = 0; i < width * height; ++i) { 194 for (int i = 0; i < width * height; ++i) {
193 uint8_t b = *(byte++); 195 uint8_t b = *(byte++);
194 uint8_t g = *(byte++); 196 uint8_t g = *(byte++);
195 uint8_t r = *(byte++); 197 uint8_t r = *(byte++);
196 uint8_t a = *(byte++); 198 uint8_t a = *(byte++);
197 // Ignore fully transparent pixels. 199 // Ignore fully transparent pixels.
198 if (a == 0) 200 if (a == 0)
199 continue; 201 continue;
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 gfx::Matrix3F covariance = ComputeColorCovariance(source_bitmap); 575 gfx::Matrix3F covariance = ComputeColorCovariance(source_bitmap);
574 gfx::Matrix3F eigenvectors = gfx::Matrix3F::Zeros(); 576 gfx::Matrix3F eigenvectors = gfx::Matrix3F::Zeros();
575 gfx::Vector3dF eigenvals = covariance.SolveEigenproblem(&eigenvectors); 577 gfx::Vector3dF eigenvals = covariance.SolveEigenproblem(&eigenvectors);
576 gfx::Vector3dF principal = eigenvectors.get_column(0); 578 gfx::Vector3dF principal = eigenvectors.get_column(0);
577 if (eigenvals == gfx::Vector3dF() || principal == gfx::Vector3dF()) 579 if (eigenvals == gfx::Vector3dF() || principal == gfx::Vector3dF())
578 return false; // This may happen for some edge cases. 580 return false; // This may happen for some edge cases.
579 return ApplyColorReduction(source_bitmap, principal, true, target_bitmap); 581 return ApplyColorReduction(source_bitmap, principal, true, target_bitmap);
580 } 582 }
581 583
582 } // color_utils 584 } // color_utils
OLDNEW
« no previous file with comments | « ppapi/shared_impl/id_assignment.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698