自定义方法,参数取值超范围抛异常
2017-06-01 13:47
603 查看
/** * Compress a rectangle region in the YuvImage to a jpeg. * Only ImageFormat.NV21 and ImageFormat.YUY2 * are supported for now. * * @param rectangle The rectangle region to be compressed. The medthod checks if rectangle is * inside the image. Also, the method modifies rectangle if the chroma pixels * in it are not matched with the luma pixels in it. * @param quality Hint to the compressor, 0-100. 0 meaning compress for * small size, 100 meaning compress for max quality. * @param stream OutputStream to write the compressed data. * @return True if the compression is successful. * @throws IllegalArgumentException if rectangle is invalid; quality is not within [0, * 100]; or stream is null. */ public boolean compressToJpeg(Rect rectangle, int quality, OutputStream stream) { Rect wholeImage = new Rect(0, 0, mWidth, mHeight); if (!wholeImage.contains(rectangle)) { throw new IllegalArgumentException( "rectangle is not inside the image"); } if (quality < 0 || quality > 100) { throw new IllegalArgumentException("quality must be 0..100"); } if (stream == null) { throw new IllegalArgumentException("stream cannot be null"); } adjustRectangle(rectangle); int[] offsets = calculateOffsets(rectangle.left, rectangle.top); return nativeCompressToJpeg(mData, mFormat, rectangle.width(), rectangle.height(), offsets, mStrides, quality, stream, new byte[WORKING_COMPRESS_STORAGE]); }
相关文章推荐
- VS2005中单元测试自定义异常的方法
- Struts validator 自定义验证方法 6个参数说明
- t-sql中使用参数设置取值范围
- DataGrid的ScrollIntoView方法导致 an argument out of range exception(指定的参数已超出有效值的范围)错误的解决
- C# 自定义事件并使用自定义事件参数方法
- 四、自定义方法及其使用范围
- Android中MediaPlayer类的setVolume方法参数的范围
- 在使用OracleDataAdapterFill(Dataset)方法时报错:指定的参数已超出有效值的范围
- struts2中处理自定义异常的方法小结
- 查询自定义方法或着存储过程的详细参数
- asp.net使用ajax后判断出现异常原因的自定义方法
- Java访问DotNet平台WCF服务,使用自定义对象如IDictionary做参数时,抛出"Did not understand MustUnderstand"异常
- 索引超出范围。必须为非负值并小于集合大小。参数名: index 解决方法
- Oracle数据库自定义异常的使用方法
- Ant+checkstyle:找不到某些自定义异常类的解决方法
- 如何在MapX下读取属性值、自定义范围专题图、在mapx中查找对象的方法
- com中传递自定义类参数的解决方法
- Drupal中关于表单form的drupal_get_form方法如何传递自定义参数
- php中参数带默认值的自定义方法
- 自定义泛型方法及其应用和类型参数的类型推断