在Android中,BitmapFactory.decodeByteArray返回null,inJustDecoteBounds = true

时间:2016-02-10 09:23:44

标签: java android

我想调整.click()的大小,将其存储在$('#clickme').magnificPopup({ delegate: 'a', removalDelay: 500, callbacks: { beforeOpen: function() { this.st.mainClass = this.st.el.attr('data-effect'); } }, midClick: true }); // this is what you need $(".main").mouseleave(function(){ // your window or parent element you can use document if you want $('.popup').click(); // trigger click for popup }); 中供以后使用。

所以我在Bitmap中调整大小。

HashMap

我的问题是AsyncTask为空。 final BitmapFactory.Options options = new BitmapFactory.Options(); @Override protected Void doInBackground(byte[]... params) { byte[] bytes = params[0]; options.inJustDecodeBounds = true; Bitmap test = BitmapFactory.decodeByteArray(bytes,0,bytes.length,options); int imgHeight = test.getHeight(); int imgWidth = test.getWidth(); int counter = 0; while (imgHeight > 2000) { imgHeight = imgHeight / 2; counter++; } return null; } 不为空,长度为273440。

哪里可能是问题?

谢谢你的帮助!

亲切的问候!

2 个答案:

答案 0 :(得分:2)

  

我的问题是测试为空。

预期的行为。从文档

  

如果设置为true,解码器将返回null(无位图),但是   out ...字段仍将设置,允许调用者查询   位图,而不必为其像素分配内存。

您必须使用options来检索您想要的位图元信息。 E.g。

BitmapFactory.decodeByteArray(bytes,0,bytes.length,options);
int imgWidth =  options.outWidth

答案 1 :(得分:0)

如果你设置为true,那么它将返回null,如文档

中所述
public boolean inJustDecodeBounds

Since: API Level 1 If set to true, the decoder will return null (no bitmap), but the out... fields will still be set, allowing the caller to query the bitmap without having to allocate the memory for its pixels.
相关问题