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

Unified Diff: chrome/browser/chromeos/login/simple_jpeg_encoder.cc

Issue 10883062: Resize and save custom wallpaper to large and small size (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/login/simple_jpeg_encoder.cc
diff --git a/chrome/browser/chromeos/login/simple_jpeg_encoder.cc b/chrome/browser/chromeos/login/simple_jpeg_encoder.cc
new file mode 100644
index 0000000000000000000000000000000000000000..93fd25c9593f171c96411317a26d53b8bc23c3c1
--- /dev/null
+++ b/chrome/browser/chromeos/login/simple_jpeg_encoder.cc
@@ -0,0 +1,57 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/chromeos/login/simple_jpeg_encoder.h"
+
+#include "base/bind.h"
+#include "base/location.h"
+#include "base/threading/worker_pool.h"
+#include "chrome/browser/chromeos/login/user_manager.h"
+#include "chrome/common/url_constants.h"
+#include "ui/gfx/codec/jpeg_codec.h"
+#include "ui/gfx/size.h"
+#include "ui/gfx/skia_util.h"
+
+namespace chromeos {
+
+namespace {
+const int quality = 90;
Ivan Korotkov 2012/08/30 16:47:34 Use kNaming, please.
bshe 2012/08/30 16:55:50 Done.
+}
+
+SimpleJpegEncoder::SimpleJpegEncoder(
+ scoped_refptr<base::RefCountedBytes> data,
+ SkBitmap image)
+ : data_(data),
+ image_(image) {
+}
+
+void SimpleJpegEncoder::Run(EncoderCallback callback) {
+ base::WorkerPool::PostTaskAndReply(
+ FROM_HERE,
+ base::Bind(&SimpleJpegEncoder::EncodeWallpaper, this),
+ base::Bind(callback, data_),
+ true /* task_is_slow */);
+}
+
+void SimpleJpegEncoder::EncodeWallpaper() {
+ if (cancel_flag_.IsSet())
+ return;
+ SkAutoLockPixels lock_input(image_);
+ gfx::JPEGCodec::Encode(
+ reinterpret_cast<unsigned char*>(image_.getAddr32(0, 0)),
+ gfx::JPEGCodec::FORMAT_SkBitmap,
+ image_.width(),
+ image_.height(),
+ image_.width() * image_.bytesPerPixel(),
+ quality, &data_->data());
+}
+
+void SimpleJpegEncoder::Cancel() {
+ cancel_flag_.Set();
+}
+
+SimpleJpegEncoder::~SimpleJpegEncoder() {
+}
+
+} // namespace chromeos
« no previous file with comments | « chrome/browser/chromeos/login/simple_jpeg_encoder.h ('k') | chrome/browser/chromeos/login/user_manager_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698