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 |