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

Side by Side Diff: printing/image_mac.cc

Issue 6826027: Connect the right metafiles for print preview on Linux and Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix compile issues and rename MetafileInterface to Metafile Created 9 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 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 <ApplicationServices/ApplicationServices.h> 7 #include <ApplicationServices/ApplicationServices.h>
8 8
9 #include "base/mac/scoped_cftyperef.h" 9 #include "base/mac/scoped_cftyperef.h"
10 #include "ui/gfx/rect.h" 10 #include "ui/gfx/rect.h"
11 11
12 namespace printing { 12 namespace printing {
13 13
14 bool Image::LoadMetafile(const NativeMetafile& metafile) { 14 bool Image::LoadMetafile(const Metafile& metafile) {
15 // The printing system uses single-page metafiles (page indexes are 1-based). 15 // The printing system uses single-page metafiles (page indexes are 1-based).
16 const unsigned int page_number = 1; 16 const unsigned int page_number = 1;
17 gfx::Rect rect(metafile.GetPageBounds(page_number)); 17 gfx::Rect rect(metafile.GetPageBounds(page_number));
18 if (rect.width() < 1 || rect.height() < 1) 18 if (rect.width() < 1 || rect.height() < 1)
19 return false; 19 return false;
20 20
21 size_ = rect.size(); 21 size_ = rect.size();
22 row_length_ = size_.width() * sizeof(uint32); 22 row_length_ = size_.width() * sizeof(uint32);
23 size_t bytes = row_length_ * size_.height(); 23 size_t bytes = row_length_ * size_.height();
24 DCHECK(bytes); 24 DCHECK(bytes);
25 25
26 data_.resize(bytes); 26 data_.resize(bytes);
27 base::mac::ScopedCFTypeRef<CGColorSpaceRef> color_space( 27 base::mac::ScopedCFTypeRef<CGColorSpaceRef> color_space(
28 CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB)); 28 CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB));
29 base::mac::ScopedCFTypeRef<CGContextRef> bitmap_context( 29 base::mac::ScopedCFTypeRef<CGContextRef> bitmap_context(
30 CGBitmapContextCreate(&*data_.begin(), size_.width(), size_.height(), 30 CGBitmapContextCreate(&*data_.begin(), size_.width(), size_.height(),
31 8, row_length_, color_space, 31 8, row_length_, color_space,
32 kCGImageAlphaPremultipliedLast)); 32 kCGImageAlphaPremultipliedLast));
33 DCHECK(bitmap_context.get()); 33 DCHECK(bitmap_context.get());
34 34
35 metafile.RenderPage(page_number, bitmap_context, 35 metafile.RenderPage(page_number, bitmap_context,
36 CGRectMake(0, 0, size_.width(), size_.height()), 36 CGRectMake(0, 0, size_.width(), size_.height()),
37 true, false, false, false); 37 true, false, false, false);
38 38
39 return true; 39 return true;
40 } 40 }
41 41
42 } // namespace printing 42 } // namespace printing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698