| Index: ui/gfx/codec/tiff_codec_mac.mm
|
| diff --git a/ui/gfx/codec/tiff_codec_mac.mm b/ui/gfx/codec/tiff_codec_mac.mm
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..20f9018a59cae859d9690fb989325bcef3458fcf
|
| --- /dev/null
|
| +++ b/ui/gfx/codec/tiff_codec_mac.mm
|
| @@ -0,0 +1,35 @@
|
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "ui/gfx/codec/tiff_codec.h"
|
| +
|
| +#import <Cocoa/Cocoa.h>
|
| +
|
| +#include "base/memory/scoped_nsobject.h"
|
| +#include "skia/ext/skia_utils_mac.h"
|
| +#include "third_party/skia/include/core/SkBitmap.h"
|
| +
|
| +namespace gfx {
|
| +
|
| +bool TIFFCodec::Decode(const unsigned char* input, size_t input_size,
|
| + std::vector<SkBitmap>& bitmaps) {
|
| + scoped_nsobject<NSData> data([[NSData alloc]
|
| + initWithBytesNoCopy:const_cast<unsigned char*>(input)
|
| + length:input_size
|
| + freeWhenDone:NO]);
|
| + NSArray* image_reps = [NSBitmapImageRep imageRepsWithData:data];
|
| + if ([image_reps count] == 0)
|
| + return false;
|
| +
|
| + for (NSBitmapImageRep* image_rep in image_reps) {
|
| + SkBitmap bitmap(NSImageRepToSkBitmap(image_rep, [image_rep size], false));
|
| + if (bitmap.isNull())
|
| + return false;
|
| + bitmaps.push_back(bitmap);
|
| + }
|
| +
|
| + return true;
|
| +}
|
| +
|
| +} // namespace gfx
|
|
|