从图像创建位图
我有一个 Image 对象,它是相机拍摄的 jpg 图片,我需要从中创建一个 Bitmap。
除了使用 BMPGenerator 类?我正在开发一个商业项目,但由于 GPLv3 许可证,我认为我无法使用它。
到目前为止,这是我的代码。我可以用它做点什么吗?
FileConnection file = (FileConnection) Connector.open("file://" + imagePath, Connector.READ_WRITE);
InputStream is = file.openInputStream();
Image capturedImage = Image.createImage(is);
我尝试了这个,但无法获得正确的文件路径并且图像卡在空值中
EncodedImage image = EncodedImage.getEncodedImageResource(filePath);
byte[] array = image.getData();
capturedBitmap = image.getBitmap();
I have an Image object which is a jpg picture taken by the camera and I need to create a Bitmap from it.
Is there any way to do it besides using BMPGenerator class? I'm working on a commercial project and I don't think I can use it due to the GPLv3 license.
So far this is the code I have. Can I do something with it?
FileConnection file = (FileConnection) Connector.open("file://" + imagePath, Connector.READ_WRITE);
InputStream is = file.openInputStream();
Image capturedImage = Image.createImage(is);
I tried this but I wasn't able to get the correct filepaht and the image is stuck in null
EncodedImage image = EncodedImage.getEncodedImageResource(filePath);
byte[] array = image.getData();
capturedBitmap = image.getBitmap();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用
videoControl.getSnapshot(null)
,然后使用Bitmap myBitmap = Bitmap.createBitmapFromBytes(raw, 0, raw.length, 1)
从相机获取位图。videoControl是从
player.getControl("VideoControl")
获取的,player
是从Manager.createPlayer()
获取的图片你有吗?如果我们谈论 EncodedImage,您只需使用其中的
getBitmap()
即可。You can use
videoControl.getSnapshot(null)
and thenBitmap myBitmap = Bitmap.createBitmapFromBytes(raw, 0, raw.length, 1)
to get a bitmap from camera.videoControl is got from
player.getControl("VideoControl")
andplayer
is got fromManager.createPlayer()
By the way, what kind of Image do you have? If we are talking of EncodedImage, you can just use
getBitmap()
from it.固定的!
嗯,差不多了。
使用以下方法,但图像旋转了 90 度。
将使用这个
Fixed!
Well, almost.
Used the following method but the image is rotated 90 degrees.
Going to fix that with this