| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/ui/window_snapshot/window_snapshot.h" | 5 #include "chrome/browser/ui/window_snapshot/window_snapshot.h" |
| 6 | 6 |
| 7 #include "base/win/scoped_gdi_object.h" | 7 #include "base/win/scoped_gdi_object.h" |
| 8 #include "base/win/scoped_hdc.h" | 8 #include "base/win/scoped_hdc.h" |
| 9 #include "gfx/codec/png_codec.h" | 9 #include "ui/gfx/codec/png_codec.h" |
| 10 #include "gfx/gdi_util.h" | 10 #include "ui/gfx/gdi_util.h" |
| 11 #include "gfx/rect.h" | 11 #include "ui/gfx/rect.h" |
| 12 | 12 |
| 13 namespace browser { | 13 namespace browser { |
| 14 | 14 |
| 15 gfx::Rect GrabWindowSnapshot(gfx::NativeWindow window_handle, | 15 gfx::Rect GrabWindowSnapshot(gfx::NativeWindow window_handle, |
| 16 std::vector<unsigned char>* png_representation) { | 16 std::vector<unsigned char>* png_representation) { |
| 17 // Create a memory DC that's compatible with the window. | 17 // Create a memory DC that's compatible with the window. |
| 18 HDC window_hdc = GetWindowDC(window_handle); | 18 HDC window_hdc = GetWindowDC(window_handle); |
| 19 base::win::ScopedHDC mem_hdc(CreateCompatibleDC(window_hdc)); | 19 base::win::ScopedHDC mem_hdc(CreateCompatibleDC(window_hdc)); |
| 20 | 20 |
| 21 // Create a DIB that's the same size as the window. | 21 // Create a DIB that's the same size as the window. |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 gfx::PNGCodec::Encode(bit_ptr, gfx::PNGCodec::FORMAT_BGRA, | 63 gfx::PNGCodec::Encode(bit_ptr, gfx::PNGCodec::FORMAT_BGRA, |
| 64 width, height, width * 4, true, | 64 width, height, width * 4, true, |
| 65 png_representation); | 65 png_representation); |
| 66 | 66 |
| 67 ReleaseDC(window_handle, window_hdc); | 67 ReleaseDC(window_handle, window_hdc); |
| 68 | 68 |
| 69 return gfx::Rect(width, height); | 69 return gfx::Rect(width, height); |
| 70 } | 70 } |
| 71 | 71 |
| 72 } // namespace browser | 72 } // namespace browser |
| OLD | NEW |