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 true and set bitmap to those pixels. In this case the client | |
81 * must still call lockPixels/unlockPixels to access them, and must NOT | |
82 * modify the pixels in any way. | |
83 * | |
84 * If this direct exposing of the pixels is not valid, return false and | |
85 * bitmap will unmodified. | |
scroggo
2014/02/05 17:16:07
nit: will be*
| |
86 */ | |
87 bool peekPixels(SkBitmap* bitmap) const; | |
bsalomon
2014/02/05 17:13:37
Maybe this should return a const pointer, an image
scroggo
2014/02/05 17:16:43
+1
reed1
2014/02/05 17:47:52
Interesting. That is precisely what I first typed,
| |
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. Aany pixels in the bitmap that do not | |
scroggo
2014/02/05 17:16:07
Any*
| |
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); | |
scroggo
2014/02/05 17:16:07
Should this function be const also?
In the case o
| |
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 |