Fields | |||||||||||
public Bitmap | inBitmap | If set, decode methods that take the Options object will attempt to reuse this bitmap when loading content. | |||||||||
public int | inDensity | The pixel density to use for the bitmap. | |||||||||
public boolean | inDither | If dither is true, the decoder will attempt to dither the decoded image. | |||||||||
public boolean | inInputShareable | This field works in conjuction with inPurgeable. | |||||||||
public boolean | inJustDecodeBounds | If set to true, the decoder will return null (no bitmap), but the out... | |||||||||
public boolean | inMutable | If set, decode methods will always return a mutable Bitmap instead of an immutable one. | |||||||||
public boolean | inPreferQualityOverSpeed | If inPreferQualityOverSpeed is set to true, the decoder will try to decode the reconstructed image to a higher quality even at the expense of the decoding speed. | |||||||||
public Bitmap.Config | inPreferredConfig | If this is non-null, the decoder will try to decode into this internal configuration. | |||||||||
public boolean | inPurgeable | If this is set to true, then the resulting bitmap will allocate its pixels such that they can be purged if the system needs to reclaim memory. | |||||||||
public int | inSampleSize | If set to a value > 1, requests the decoder to subsample the original image, returning a smaller image to save memory. | |||||||||
public boolean | inScaled | When this flag is set, if inDensity and inTargetDensity are not 0, the bitmap will be scaled to match inTargetDensity when loaded, rather than relying on the graphics system scaling it each time it is drawn to a Canvas. | |||||||||
public int | inScreenDensity | The pixel density of the actual screen that is being used. | |||||||||
public int | inTargetDensity | The pixel density of the destination this bitmap will be drawn to. | |||||||||
public byte[] | inTempStorage | Temp storage to use for decoding. | |||||||||
public boolean | mCancel | Flag to indicate that cancel has been called on this object. | |||||||||
public int | outHeight | The resulting height of the bitmap, set independent of the state of inJustDecodeBounds. | |||||||||
public String | outMimeType | If known, this string is set to the mimetype of the decoded image. | |||||||||
public int | outWidth | The resulting width of the bitmap, set independent of the state of inJustDecodeBounds. |
/* 这里返回的bmp是null */
/* 计算得到图片的高度 */
/* 这里需要主意,如果你需要更高的精度来保证图片不变形的话,需要自己进行一下数学运算 */' w# ?4 z3 K# {! n
int height = options.outHeight * 200 / options.outWidth;
options.outWidth = 200;
options.outHeight = height;
/* 这样才能真正的返回一个Bitmap给你 */
options.inJustDecodeBounds = false;
Bitmap bmp = BitmapFactory.decodeFile(path, options);
image.setImageBitmap(bmp);
inSampleSize = options.outWidth / 200;
复制代码options.inPreferredConfig = Bitmap.Config.ARGB_4444; // 默认是Bitmap.Config.ARGB_88880 `' `- L) C+ `
联系客服