直接从字节数组作物图像 [英] crop image directly from byte array

查看:179
本文介绍了直接从字节数组作物图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个字节数组,其中包含一个图像...我想保存裁剪。

I have a byte array, which contains an image... i'd like to save it cropped.

我的工作方法是:
得到的byte []
将其转换成位图与BitmapFactory.de codeByteArray的
使另一个位图从它与createbitmap(sourceBitmap中,X1,Y1,whileX,whileY)
回收第一个(未裁剪的一个)
节省出来的第二个,然后回收太

My working method was: get the byte[] convert it into a bitmap with BitmapFactory.decodebytearray make another bitmap from it with createbitmap(sourceBitmap, x1, y1, whileX, whileY) recycle the first (uncropped one) save out the second, then recycle that too

问题是,一段时间存在2位图,原始和裁剪之一,这就是为什么我不能用这种方法具有更大的图像(3MP以上)

the problem is that for a while it exists 2 bitmap, the original and the cropped one, and thats why i cant use this method with larger images (over 3MP)

有没有办法直接从字节数组裁剪图像?我看到有一个去codeByteArray的(dataArray中,偏移,长度,选项),但我不能从它使图像(其余的数据是不是图像)......可能有人也许帮助?

is there a way to crop image directly from the byte array? I saw that there is a decodeByteArray(dataArray, offset, length, options), but i couldn't make an image from it (the remaining data was not an image)... could someone help maybe?

推荐答案

该方法德codeByteArray的(dataArray中,偏移,长度,选项)不打算裁剪图像,但可以从包含比图像本身更多的数据字节缓冲器解析的图像。典型的用途是提取,包括除其他事项外图像复杂的二进制数据结构的图像。

The method decodeByteArray(dataArray, offset, length, options) is not intended to crop an image but to parse an image from a byte buffer that contains more data than the image itself. The typical use of this is to extract images from complex binary data structures that include images among other things.

据我所知是没有办法来裁剪图像而无需创建一个新的。对我来说,你能做的最好是目前你在做什么。

To my knowledge there is no way to crop an image without creating a new one. To me the best you can do is what you are currently doing.

这篇关于直接从字节数组作物图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆