OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SkImage_DEFINED | 8 #ifndef SkImage_DEFINED |
9 #define SkImage_DEFINED | 9 #define SkImage_DEFINED |
10 | 10 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 /** | 69 /** |
70 * Draw the image, cropped to the src rect, to the dst rect of a canvas. | 70 * Draw the image, cropped to the src rect, to the dst rect of a canvas. |
71 * If src is larger than the bounds of the image, the rest of the image is | 71 * If src is larger than the bounds of the image, the rest of the image is |
72 * filled with transparent black pixels. | 72 * filled with transparent black pixels. |
73 * | 73 * |
74 * See SkCanvas::drawBitmapRectToRect for similar behavior. | 74 * See SkCanvas::drawBitmapRectToRect for similar behavior. |
75 */ | 75 */ |
76 void draw(SkCanvas*, const SkRect* src, const SkRect& dst, const SkPaint*); | 76 void draw(SkCanvas*, const SkRect* src, const SkRect& dst, const SkPaint*); |
77 | 77 |
78 /** | 78 /** |
| 79 * If the image has direct access to its pixels (i.e. they are in local |
| 80 * RAM) return the (const) address of those pixels, and if not null, return |
| 81 * the ImageInfo and rowBytes. The returned address is only valid while |
| 82 * the image object is in scope. |
| 83 * |
| 84 * On failure, returns NULL and the info and rowBytes parameters are |
| 85 * ignored. |
| 86 */ |
| 87 const void* peekPixels(SkImageInfo* info, size_t* rowBytes) const; |
| 88 |
| 89 /** |
| 90 * Return a copy of the image's pixels, limiting them to the subset |
| 91 * rectangle's intersection wit the image bounds. If subset is NULL, then |
| 92 * the entire image will be considered. |
| 93 * |
| 94 * If the bitmap's pixels have already been allocated, then readPixels() |
| 95 * will succeed only if it can support converting the image's pixels into |
| 96 * the bitmap's ColorType/AlphaType. Any pixels in the bitmap that do not |
| 97 * intersect with the image's bounds and the subset (if not null) will be |
| 98 * left untouched. |
| 99 * |
| 100 * If the bitmap is initially empty/unallocated, then it will be allocated |
| 101 * using the default allocator, and the ColorType/AlphaType will be chosen |
| 102 * to most closely fit the image's configuration. |
| 103 * |
| 104 * On failure, false will be returned, and bitmap will unmodified. |
| 105 */ |
| 106 bool readPixels(SkBitmap* bitmap, const SkIRect* subset = NULL) const; |
| 107 |
| 108 /** |
79 * Encode the image's pixels and return the result as a new SkData, which | 109 * Encode the image's pixels and return the result as a new SkData, which |
80 * the caller must manage (i.e. call unref() when they are done). | 110 * the caller must manage (i.e. call unref() when they are done). |
81 * | 111 * |
82 * If the image type cannot be encoded, or the requested encoder type is | 112 * If the image type cannot be encoded, or the requested encoder type is |
83 * not supported, this will return NULL. | 113 * not supported, this will return NULL. |
84 */ | 114 */ |
85 SkData* encode(SkImageEncoder::Type t = SkImageEncoder::kPNG_Type, | 115 SkData* encode(SkImageEncoder::Type t = SkImageEncoder::kPNG_Type, |
86 int quality = 80) const; | 116 int quality = 80) const; |
87 | 117 |
88 protected: | 118 protected: |
(...skipping 10 matching lines...) Expand all Loading... |
99 const int fWidth; | 129 const int fWidth; |
100 const int fHeight; | 130 const int fHeight; |
101 const uint32_t fUniqueID; | 131 const uint32_t fUniqueID; |
102 | 132 |
103 static uint32_t NextUniqueID(); | 133 static uint32_t NextUniqueID(); |
104 | 134 |
105 typedef SkRefCnt INHERITED; | 135 typedef SkRefCnt INHERITED; |
106 }; | 136 }; |
107 | 137 |
108 #endif | 138 #endif |
OLD | NEW |