Android如何最优化的读取一张Bitmap
3个回答
展开全部
全白Java code int[] pix = new int[picw * pich];
for (int y = 0; y < pich; y++)
for (int x = 0; x < picw; x++)
{
int index = y * picw + x;
int r = ((pix[index] >> 16) & 0xff)|0xff;
int g = ((pix[index] >> 8) & 0xff)|0xff;
int b =( pix[index] & 0xff)|0xff;
pix[index] = 0xff000000 | (r << 16) | (g << 8) | b;
}
bm1.setPixels(pix, 0, picw, 0, 0, picw, pich);
BitmapDrawable bmp11=new BitmapDrawable(bm1);
for (int y = 0; y < pich; y++)
for (int x = 0; x < picw; x++)
{
int index = y * picw + x;
int r = ((pix[index] >> 16) & 0xff)|0xff;
int g = ((pix[index] >> 8) & 0xff)|0xff;
int b =( pix[index] & 0xff)|0xff;
pix[index] = 0xff000000 | (r << 16) | (g << 8) | b;
}
bm1.setPixels(pix, 0, picw, 0, 0, picw, pich);
BitmapDrawable bmp11=new BitmapDrawable(bm1);
展开全部
public static byte[] bitmapToByte(Bitmap bitmap) {
ByteArrayOutputStream os = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, os);
return os.toByteArray();
}
ByteArrayOutputStream os = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, os);
return os.toByteArray();
}
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询