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 "printing/image.h" | 5 #include "printing/image.h" |
6 | 6 |
7 #include "printing/metafile.h" | 7 #include "printing/metafile.h" |
8 #include "skia/ext/platform_device.h" | 8 #include "skia/ext/platform_device.h" |
9 #include "ui/gfx/gdi_util.h" // EMF support | 9 #include "ui/gfx/gdi_util.h" // EMF support |
10 #include "ui/gfx/rect.h" | 10 #include "ui/gfx/rect.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 | 62 |
63 size_ = rect.size(); | 63 size_ = rect.size(); |
64 gfx::CreateBitmapV4Header(rect.width(), rect.height(), &hdr); | 64 gfx::CreateBitmapV4Header(rect.width(), rect.height(), &hdr); |
65 void* bits; | 65 void* bits; |
66 HBITMAP bitmap = CreateDIBSection(hdc, | 66 HBITMAP bitmap = CreateDIBSection(hdc, |
67 reinterpret_cast<BITMAPINFO*>(&hdr), 0, | 67 reinterpret_cast<BITMAPINFO*>(&hdr), 0, |
68 &bits, NULL, 0); | 68 &bits, NULL, 0); |
69 DCHECK(bitmap); | 69 DCHECK(bitmap); |
70 DCHECK(SelectObject(hdc, bitmap)); | 70 DCHECK(SelectObject(hdc, bitmap)); |
71 | 71 |
72 skia::PlatformDevice::InitializeDC(hdc); | 72 skia::InitializeDC(hdc); |
73 | 73 |
74 bool success = metafile.Playback(hdc, NULL); | 74 bool success = metafile.Playback(hdc, NULL); |
75 | 75 |
76 row_length_ = size_.width() * sizeof(uint32); | 76 row_length_ = size_.width() * sizeof(uint32); |
77 size_t bytes = row_length_ * size_.height(); | 77 size_t bytes = row_length_ * size_.height(); |
78 DCHECK(bytes); | 78 DCHECK(bytes); |
79 | 79 |
80 data_.resize(bytes); | 80 data_.resize(bytes); |
81 memcpy(&*data_.begin(), bits, bytes); | 81 memcpy(&*data_.begin(), bits, bytes); |
82 | 82 |
83 DeleteDC(hdc); | 83 DeleteDC(hdc); |
84 DeleteObject(bitmap); | 84 DeleteObject(bitmap); |
85 | 85 |
86 return success; | 86 return success; |
87 } | 87 } |
88 | 88 |
89 } // namespace printing | 89 } // namespace printing |
OLD | NEW |