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

Unified Diff: content/browser/devtools/protocol/page_handler_image_utils.cc

Issue 2592983002: [devtools] Support different encodings for Page.CaptureScreenshot. (Closed)
Patch Set: Return gfx::Image from ui snapshot methods instead. Created 3 years, 11 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: content/browser/devtools/protocol/page_handler_image_utils.cc
diff --git a/content/browser/devtools/protocol/page_handler_image_utils.cc b/content/browser/devtools/protocol/page_handler_image_utils.cc
new file mode 100644
index 0000000000000000000000000000000000000000..e7fe3ca62c1bc88d3441215c32f9553994a3f2d1
--- /dev/null
+++ b/content/browser/devtools/protocol/page_handler_image_utils.cc
@@ -0,0 +1,29 @@
+// Copyright 2017 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 "content/browser/devtools/protocol/page_handler.h"
+
+
+namespace content {
+namespace protocol {
+
+scoped_refptr<base::RefCountedMemory> EncodeScreenshotImageAsJpeg(
pfeldman 2017/01/07 01:13:27 Is this dead code?
Eric Seckler 2017/01/09 14:52:04 Yeah, I thought I had deleted these files.. Gone n
+ const SkBitmap& bitmap,
+ int quality) {
+ scoped_refptr<base::RefCountedBytes> data(new base::RefCountedBytes());
+ SkAutoLockPixels lock_image(bitmap);
+ bool encoded = gfx::JPEGCodec::Encode(
+ reinterpret_cast<unsigned char*>(bitmap.getPixels()),
+ gfx::JPEGCodec::FORMAT_SkBitmap, bitmap.width(), bitmap.height(),
+ base::checked_cast<int>(bitmap.rowBytes()), quality, &data->data());
+
+ if (!encoded)
+ return nullptr;
+ else
+ return data;
+}
+
+
+} // namespace protocol
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698