将图形绘图从android移植到标准Java [英] Porting graphics drawing from android to standard java
问题描述
我有一个android应用程序,可将图像直接绘制到画布上. 它特别使用路径和贝塞尔曲线.
I have an android application which draws images directly onto the canvas. It uses notably paths and beziers.
我现在需要将此端口移植到用标准Java编写的Windows应用程序中,并且很难找到要使用的正确图形库.
I now need to port this to a windows app written in standard java and am having difficulty in finding the correct graphics library to use.
我需要在内存中创建带路径的位图. 该路径必须能够容纳线条,贝塞尔曲线,椭圆形和空心矩形. 然后,将生成的图像多次渗入输出图形中.
I need to create bitmaps in memory, drawn with a path. The path needs to be able to hold lines, beziers, ovals and hollow rectangles. The resulting image is then blitted into the output graphic a number of times.
我看过Graphics2D,但是路径绘制不允许创建椭圆作为其一部分.
I have looked at Graphics2D, but the path drawing does not permit creating ovals as a part of it.
是否有解决方法或其他标准库? java中是否有与Android画布相当的东西?
Is there a workaround or another standard library available ? Is there an android canvas equivalent within java ?
推荐答案
Java2D中的路径(以java.awt.geom.Path2D
或java.awt.geom.GeneralPath
的形式)可以附加任何java.awt.Shape
. java.awt.geom.Ellipse2D
表示圆形或椭圆形,并且实现了java.awt.Shape
,因此可以将其添加到Path2D中.
Paths in Java2D (in the form of java.awt.geom.Path2D
or java.awt.geom.GeneralPath
) can have any java.awt.Shape
appended to them. java.awt.geom.Ellipse2D
represents a circle or oval, and it implements java.awt.Shape
so you can add one to a Path2D.
您可以在java.awt.image.BufferedImage
上绘制路径,并将缓冲的图像绘制到屏幕上.
You can draw paths onto a java.awt.image.BufferedImage
and draw the buffered image onto the screen.
您真正需要的是Java2D API.
The Java2D API really is what you need.
这篇关于将图形绘图从android移植到标准Java的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!