Porting graphics drawing from android to standard java

假装没事ソ 提交于 2019-12-25 02:38:14

问题


I have an android application which draws images directly onto the canvas. It uses notably paths and beziers.

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.

I have looked at Graphics2D, but the path drawing does not permit creating ovals as a part of it.

Is there a workaround or another standard library available ? Is there an android canvas equivalent within java ?


回答1:


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.

You can draw paths onto a java.awt.image.BufferedImage and draw the buffered image onto the screen.

The Java2D API really is what you need.



来源:https://stackoverflow.com/questions/21203392/porting-graphics-drawing-from-android-to-standard-java

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!