Skip to content
Commit beebd3ca authored by Leon Scroggins III's avatar Leon Scroggins III
Browse files

ImageDecoder: Disallow empty/unsorted crop rects

Bug: 135133301
Test: Idf64474f28c0bf3f77616a31d843d84fbfd570ab

If the specified crop Rect is empty or unsorted, throw an
IllegalStateException, like we do if the Rect does not fit in the target
size.

This is a change in behavior to make it more consistent. Here are the
specific behavior changes:
- an empty crop rect was previously supported in all cases, but would
  result in a zero width and/or height Bitmap/Drawable. If one
  dimension is non-zero, it still affects layout, though nothing is
  drawn. This is not useful, so the new Exception is more helpful. (It
  is also more consistent with setTargetSize, which throws an
  IllegalArgumentException for non-positive dimensions.)
- a negative width or height in decodeBitmap, or on a static image in
  decodeDrawable, previously threw an IOException when trying to call
  SkBitmap::setInfo with a negative width or height. Throwing an
  IllegalStateException is more consistent with other invalid crop rects
- a negative width or height in decodeDrawable on an animated image
  previously resulted in an AnimatedImageDrawable with a negative
  intrinsic width and/or height. When passed to an ImageView, this
  dimension ends up being 1. Again, this does not seem useful.

Change-Id: I15d2f77125799413eaf55d417e98ff34599e2eb4
parent a9380ab7
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment