问题
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