@@ -408,16 +408,19 @@ public Bitmap copy(Config config, boolean isMutable) {
408408 }
409409
410410 /**
411- * Creates a new bitmap, scaled from an existing bitmap.
411+ * Creates a new bitmap, scaled from an existing bitmap, when possible. If the
412+ * specified width and height are the same as the current width and height of
413+ * the source btimap, the source bitmap is returned and now new bitmap is
414+ * created.
412415 *
413416 * @param src The source bitmap.
414417 * @param dstWidth The new bitmap's desired width.
415418 * @param dstHeight The new bitmap's desired height.
416419 * @param filter true if the source should be filtered.
417- * @return the new scaled bitmap.
420+ * @return The new scaled bitmap or the source bitmap if no scaling is required .
418421 */
419- public static Bitmap createScaledBitmap (Bitmap src , int dstWidth ,
420- int dstHeight , boolean filter ) {
422+ public static Bitmap createScaledBitmap (Bitmap src , int dstWidth , int dstHeight ,
423+ boolean filter ) {
421424 Matrix m ;
422425 synchronized (Bitmap .class ) {
423426 // small pool of just 1 matrix
@@ -458,23 +461,29 @@ public static Bitmap createBitmap(Bitmap src) {
458461 /**
459462 * Returns an immutable bitmap from the specified subset of the source
460463 * bitmap. The new bitmap may be the same object as source, or a copy may
461- * have been made. It is
462- * initialized with the same density as the original bitmap.
464+ * have been made. It is initialized with the same density as the original
465+ * bitmap.
463466 *
464467 * @param source The bitmap we are subsetting
465468 * @param x The x coordinate of the first pixel in source
466469 * @param y The y coordinate of the first pixel in source
467470 * @param width The number of pixels in each row
468471 * @param height The number of rows
472+ * @return A copy of a subset of the source bitmap or the source bitmap itself.
469473 */
470474 public static Bitmap createBitmap (Bitmap source , int x , int y , int width , int height ) {
471475 return createBitmap (source , x , y , width , height , null , false );
472476 }
473477
474478 /**
475479 * Returns an immutable bitmap from subset of the source bitmap,
476- * transformed by the optional matrix. It is
480+ * transformed by the optional matrix. The new bitmap may be the
481+ * same object as source, or a copy may have been made. It is
477482 * initialized with the same density as the original bitmap.
483+ *
484+ * If the source bitmap is immutable and the requested subset is the
485+ * same as the source bitmap itself, then the source bitmap is
486+ * returned and no new bitmap is created.
478487 *
479488 * @param source The bitmap we are subsetting
480489 * @param x The x coordinate of the first pixel in source
0 commit comments