| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ui/gfx/codec/tiff_codec.h" |
| 6 |
| 7 #import <Cocoa/Cocoa.h> |
| 8 |
| 9 #include "base/memory/scoped_nsobject.h" |
| 10 #include "skia/ext/skia_utils_mac.h" |
| 11 #include "third_party/skia/include/core/SkBitmap.h" |
| 12 |
| 13 namespace gfx { |
| 14 |
| 15 bool TIFFCodec::Decode(const unsigned char* input, size_t input_size, |
| 16 std::vector<SkBitmap>& bitmaps) { |
| 17 scoped_nsobject<NSData> data([[NSData alloc] |
| 18 initWithBytesNoCopy:const_cast<unsigned char*>(input) |
| 19 length:input_size |
| 20 freeWhenDone:NO]); |
| 21 NSArray* image_reps = [NSBitmapImageRep imageRepsWithData:data]; |
| 22 if ([image_reps count] == 0) |
| 23 return false; |
| 24 |
| 25 for (NSBitmapImageRep* image_rep in image_reps) { |
| 26 SkBitmap bitmap(NSImageRepToSkBitmap(image_rep, [image_rep size], false)); |
| 27 if (bitmap.isNull()) |
| 28 return false; |
| 29 bitmaps.push_back(bitmap); |
| 30 } |
| 31 |
| 32 return true; |
| 33 } |
| 34 |
| 35 } // namespace gfx |
| OLD | NEW |