| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 | 9 |
| 10 #ifndef SkImageDecoder_DEFINED | 10 #ifndef SkImageDecoder_DEFINED |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 /** | 209 /** |
| 210 * Given a stream, build an index for doing tile-based decode. | 210 * Given a stream, build an index for doing tile-based decode. |
| 211 * The built index will be saved in the decoder, and the image size will | 211 * The built index will be saved in the decoder, and the image size will |
| 212 * be returned in width and height. | 212 * be returned in width and height. |
| 213 * | 213 * |
| 214 * Return true for success or false on failure. | 214 * Return true for success or false on failure. |
| 215 */ | 215 */ |
| 216 bool buildTileIndex(SkStream*, int *width, int *height); | 216 bool buildTileIndex(SkStream*, int *width, int *height); |
| 217 | 217 |
| 218 /** | 218 /** |
| 219 * Decode a rectangle region in the image specified by rect. | 219 * Decode a rectangle subset in the image. |
| 220 * The method can only be called after buildTileIndex(). | 220 * The method can only be called after buildTileIndex(). |
| 221 * | 221 * |
| 222 * Return true for success. | 222 * Return true for success. |
| 223 * Return false if the index is never built or failing in decoding. | 223 * Return false if the index is never built or failing in decoding. |
| 224 */ | 224 */ |
| 225 bool decodeRegion(SkBitmap* bitmap, const SkIRect& rect, SkBitmap::Config pr
ef); | 225 bool decodeSubset(SkBitmap* bm, const SkIRect& subset, SkBitmap::Config pref
); |
| 226 |
| 227 /** |
| 228 * @Deprecated |
| 229 * Use decodeSubset instead. |
| 230 */ |
| 231 bool decodeRegion(SkBitmap* bitmap, const SkIRect& rect, SkBitmap::Config pr
ef) { |
| 232 return this->decodeSubset(bitmap, rect, pref); |
| 233 } |
| 226 | 234 |
| 227 /** Given a stream, this will try to find an appropriate decoder object. | 235 /** Given a stream, this will try to find an appropriate decoder object. |
| 228 If none is found, the method returns NULL. | 236 If none is found, the method returns NULL. |
| 229 */ | 237 */ |
| 230 static SkImageDecoder* Factory(SkStream*); | 238 static SkImageDecoder* Factory(SkStream*); |
| 231 | 239 |
| 232 /** Decode the image stored in the specified file, and store the result | 240 /** Decode the image stored in the specified file, and store the result |
| 233 in bitmap. Return true for success or false on failure. | 241 in bitmap. Return true for success or false on failure. |
| 234 | 242 |
| 235 If pref is kNo_Config, then the decoder is free to choose the most natur
al | 243 If pref is kNo_Config, then the decoder is free to choose the most natur
al |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 virtual bool onDecode(SkStream*, SkBitmap* bitmap, Mode) = 0; | 345 virtual bool onDecode(SkStream*, SkBitmap* bitmap, Mode) = 0; |
| 338 | 346 |
| 339 // If the decoder wants to support tiled based decoding, | 347 // If the decoder wants to support tiled based decoding, |
| 340 // this method must be overridden. This guy is called by buildTileIndex(...) | 348 // this method must be overridden. This guy is called by buildTileIndex(...) |
| 341 virtual bool onBuildTileIndex(SkStream*, int *width, int *height) { | 349 virtual bool onBuildTileIndex(SkStream*, int *width, int *height) { |
| 342 return false; | 350 return false; |
| 343 } | 351 } |
| 344 | 352 |
| 345 // If the decoder wants to support tiled based decoding, | 353 // If the decoder wants to support tiled based decoding, |
| 346 // this method must be overridden. This guy is called by decodeRegion(...) | 354 // this method must be overridden. This guy is called by decodeRegion(...) |
| 347 virtual bool onDecodeRegion(SkBitmap* bitmap, const SkIRect& rect) { | 355 virtual bool onDecodeSubset(SkBitmap* bitmap, const SkIRect& rect) { |
| 348 return false; | 356 return false; |
| 349 } | 357 } |
| 350 | 358 |
| 351 /* | 359 /* |
| 352 * Crop a rectangle from the src Bitmap to the dest Bitmap. src and dst are | 360 * Crop a rectangle from the src Bitmap to the dest Bitmap. src and dst are |
| 353 * both sampled by sampleSize from an original Bitmap. | 361 * both sampled by sampleSize from an original Bitmap. |
| 354 * | 362 * |
| 355 * @param dst the destination bitmap. | 363 * @param dst the destination bitmap. |
| 356 * @param src the source bitmap that is sampled by sampleSize from the | 364 * @param src the source bitmap that is sampled by sampleSize from the |
| 357 * original bitmap. | 365 * original bitmap. |
| 358 * @param sampleSize the sample size that src is sampled from the original b
itmap. | 366 * @param sampleSize the sample size that src is sampled from the original b
itmap. |
| 359 * @param (dstX, dstY) the upper-left point of the dest bitmap in terms of | 367 * @param (dstX, dstY) the upper-left point of the dest bitmap in terms of |
| 360 * the coordinate in the original bitmap. | 368 * the coordinate in the original bitmap. |
| 361 * @param (width, height) the width and height of the unsampled dst. | 369 * @param (width, height) the width and height of the unsampled dst. |
| 362 * @param (srcX, srcY) the upper-left point of the src bitimap in terms of | 370 * @param (srcX, srcY) the upper-left point of the src bitmap in terms of |
| 363 * the coordinate in the original bitmap. | 371 * the coordinate in the original bitmap. |
| 372 * @return bool Whether or not it succeeded. |
| 364 */ | 373 */ |
| 365 void cropBitmap(SkBitmap *dst, SkBitmap *src, int sampleSize, | 374 bool cropBitmap(SkBitmap *dst, SkBitmap *src, int sampleSize, |
| 366 int dstX, int dstY, int width, int height, | 375 int dstX, int dstY, int width, int height, |
| 367 int srcX, int srcY); | 376 int srcX, int srcY); |
| 368 | 377 |
| 369 | 378 |
| 370 | 379 |
| 371 /** Can be queried from within onDecode, to see if the user (possibly in | 380 /** Can be queried from within onDecode, to see if the user (possibly in |
| 372 a different thread) has requested the decode to cancel. If this returns | 381 a different thread) has requested the decode to cancel. If this returns |
| 373 true, your onDecode() should stop and return false. | 382 true, your onDecode() should stop and return false. |
| 374 Each subclass needs to decide how often it can query this, to balance | 383 Each subclass needs to decide how often it can query this, to balance |
| 375 responsiveness with performance. | 384 responsiveness with performance. |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 // not all of these will be available | 474 // not all of these will be available |
| 466 DECLARE_DECODER_CREATOR(BMPImageDecoder); | 475 DECLARE_DECODER_CREATOR(BMPImageDecoder); |
| 467 DECLARE_DECODER_CREATOR(GIFImageDecoder); | 476 DECLARE_DECODER_CREATOR(GIFImageDecoder); |
| 468 DECLARE_DECODER_CREATOR(ICOImageDecoder); | 477 DECLARE_DECODER_CREATOR(ICOImageDecoder); |
| 469 DECLARE_DECODER_CREATOR(JPEGImageDecoder); | 478 DECLARE_DECODER_CREATOR(JPEGImageDecoder); |
| 470 DECLARE_DECODER_CREATOR(PNGImageDecoder); | 479 DECLARE_DECODER_CREATOR(PNGImageDecoder); |
| 471 DECLARE_DECODER_CREATOR(WBMPImageDecoder); | 480 DECLARE_DECODER_CREATOR(WBMPImageDecoder); |
| 472 DECLARE_DECODER_CREATOR(WEBPImageDecoder); | 481 DECLARE_DECODER_CREATOR(WEBPImageDecoder); |
| 473 | 482 |
| 474 #endif | 483 #endif |
| OLD | NEW |