| 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 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/mac/scoped_cftyperef.h" | 10 #include "base/mac/scoped_cftyperef.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 scoped_nsobject<NSBitmapImageRep> rep( | 29 scoped_nsobject<NSBitmapImageRep> rep( |
| 30 [[NSBitmapImageRep alloc] initWithCGImage:windowSnapshot]); | 30 [[NSBitmapImageRep alloc] initWithCGImage:windowSnapshot]); |
| 31 NSData* data = [rep representationUsingType:NSPNGFileType properties:nil]; | 31 NSData* data = [rep representationUsingType:NSPNGFileType properties:nil]; |
| 32 const unsigned char* buf = static_cast<const unsigned char*>([data bytes]); | 32 const unsigned char* buf = static_cast<const unsigned char*>([data bytes]); |
| 33 NSUInteger length = [data length]; | 33 NSUInteger length = [data length]; |
| 34 if (buf == NULL || length == 0) | 34 if (buf == NULL || length == 0) |
| 35 return gfx::Rect(); | 35 return gfx::Rect(); |
| 36 | 36 |
| 37 png_representation->assign(buf, buf + length); | 37 png_representation->assign(buf, buf + length); |
| 38 DCHECK(png_representation->size() > 0); | 38 DCHECK(!png_representation->empty()); |
| 39 | 39 |
| 40 return gfx::Rect(static_cast<int>([rep pixelsWide]), | 40 return gfx::Rect(static_cast<int>([rep pixelsWide]), |
| 41 static_cast<int>([rep pixelsHigh])); | 41 static_cast<int>([rep pixelsHigh])); |
| 42 } | 42 } |
| 43 | 43 |
| 44 } // namespace browser | 44 } // namespace browser |
| OLD | NEW |