Chromium Code Reviews| Index: include/images/SkBitmapRegionDecoder.h |
| diff --git a/include/images/SkBitmapRegionDecoder.h b/include/images/SkBitmapRegionDecoder.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..5e5e6237b1b4c50c7a2cb5e1ca123b69ae95c738 |
| --- /dev/null |
| +++ b/include/images/SkBitmapRegionDecoder.h |
| @@ -0,0 +1,54 @@ |
| +/* |
| + * Copyright 2011 The Android Open Source Project |
| + * |
| + * Use of this source code is governed by a BSD-style license that can be |
| + * found in the LICENSE file. |
| + */ |
| + |
| + |
| +#ifndef SkBitmapRegionDecoder_DEFINED |
| +#define SkBitmapRegionDecoder_DEFINED |
| + |
| +#include "SkBitmap.h" |
| +#include "SkImageDecoder.h" |
| +#include "SkStream.h" |
| + |
| +class SkIRect; |
| + |
| +/** |
| + * SkBitmapRegionDecoder can be used to decode a specified rect from an image. |
| + * This is particularly useful when the original image is large and you only |
| + * need parts of the image. |
| + * |
| + * However, not all image codecs on all platforms support this feature so be |
| + * prepared to fallback to standard decoding if decodeRegion(...) returns false. |
| + */ |
| +class SkBitmapRegionDecoder { |
|
scroggo
2013/03/13 16:04:14
I guess we decided not to change Region to Rect so
djsollen
2013/03/13 17:35:09
I don't want to change class names in this CL.
|
| +public: |
| + SkBitmapRegionDecoder(SkImageDecoder* decoder, SkStream* stream, |
| + int width, int height) { |
| + fDecoder = decoder; |
| + fStream = stream; |
| + fWidth = width; |
| + fHeight = height; |
| + } |
| + ~SkBitmapRegionDecoder() { |
| + SkDELETE(fDecoder); |
| + SkSafeUnref(fStream); |
| + } |
| + |
| + bool decodeRegion(SkBitmap* bitmap, const SkIRect& rect, |
|
robertphillips
2013/03/13 13:41:29
remove extras spaces?
djsollen
2013/03/13 16:02:48
Done.
|
| + SkBitmap::Config pref, int sampleSize); |
| + |
| + SkImageDecoder* getDecoder() const { return fDecoder; } |
| + int getWidth() const { return fWidth; } |
| + int getHeight() const { return fHeight; } |
| + |
| +private: |
| + SkImageDecoder* fDecoder; |
| + SkStream* fStream; |
| + int fWidth; |
| + int fHeight; |
| +}; |
| + |
| +#endif |