问题描述
我一直在试图让一个机器人相当于code以下: -
I have been trying to get an android equivalent code for the following :-
private BufferedImage user_space(BufferedImage image)
{
BufferedImage new_img = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_3BYTE_BGR);
Graphics2D graphics = new_img.createGraphics();
graphics.drawRenderedImage(image, null);
graphics.dispose();
return new_img;
}
我要的Graphics2D的机器人相同。我一直在寻找了一会儿,发现了画布机器人可以做一些类似的任务,这里的Graphics2D类进行,但主要的问题是,我没有得到这在正在执行的整个过程相当于机器人code。
请任何人能帮助尽快...
I want an android equivalent of Graphics2D. I have been searching for a while and found out that Canvas in android can do some similar tasks as performed by the Graphics2D class here but the main problem is that I'm not getting the android equivalent of the whole process that is being performed in the code.Please anyone help ASAP...
推荐答案
Android不具备的BufferedImage
或的Graphics2D
正如你可能已经发现了。
android does not have BufferedImage
or Graphics2D
as you probably already found out.
我不是一个Java开发人员(只是Android的),所以我不是你想达到什么样的100%肯定,但在我看来,你只是创建图像的副本。
I'm not a java developer (just android) so I'm not 100% sure on what you're trying to achieve, but it seems to me that you're simply creating a copy of the image.
在这里,你将使用这些类型的操纵少数几类:
here a few classes that you'll be using for those type of manipulation:
-
:这就像BufferedImage的,它的对象实际存储所有从图像(可能大对象与内存崩溃电位)字节。还有在这里一些静态方法副本位图,创建新的可变或不可变的位图,缩放或COM preSS为PNG或JPG到流。
Bitmap: that's like the BufferedImage, it's the object that actually stores all the bytes from the image (possibly large object with potential for memory crash). There're some static methods here for copy bitmaps, create new mutable or immutable bitmaps, scale, or compress as PNG or JPG to a stream.
:在大量的静态方法来创建新从资源,文件,流等。
BitmapFactory: lots of static methods to create new bitmaps from resources, files, streams, etc.
:你实际上只使用一个,如果你想在图像上绘制(叠加图像,把一些文字或线条,类似的东西)
Canvas: You'll actually only use this one if you want to draw on the image (overlay image, put some text, or a line, stuff like that)
这篇关于安卓相当于code代表的Graphics2D的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!