Could someone provide an example of how to dynamically create an image in Java, draw lines et cetera on it, and then draw the image so that areas not painted will remain transparent in the drawing process?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
One could use a
BufferedImagewith an image type that supports transparency such asBufferedImage.TYPE_INT_ARGB:One can draw on the
BufferedImageby callingBufferedImage.createGraphicsto obtain aGraphics2Dobject, then perform some drawing:Then, since
BufferedImageis a subclass ofImagethat can be used to draw onto anotherImageusing one of theGraphics.drawImagethat accepts anImage.