Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Image Editor which renders output as source code?

Alex explained what I'm looking for much better than I have:

You want an existing program that allows you to draw a picture, captures what you do as you draw, and writes each action as a Java command. When you click the "Drawl Oval" tool and click at 0,0 and then at 50,50, it would generate the line g.drawOval(0,0,50,50).

If anybody knows of a program such as this, let me know. Thanks.


Original question:

I've been working with Java and custom drawing using the java.awt.Graphics library lately, but find it is taking too much time to write manually. Is there any simple graphics editor (like mspaint) which generates source code?

Example:

Drawing this: alt text

Would generate:

public void update(Graphics g) {
    g.translate(0, 0);
    g.drawOval(0, 0, 50, 50);
}

Thanks.

like image 835
Kevin Avatar asked Jul 13 '09 16:07

Kevin


People also ask

Which data type is used for image in Java?

By default, Java supports only these five formats for images: JPEG, PNG, BMP, WEBMP, GIF. If we attempt to work with an image file in a different format, our application will not be able to read it and will throw a NullPointerException when accessing the BufferedImage variable.

What is image processing in Java?

Let's move to this interesting topic that is, Java Image Processing. In General, Image processing is a critical component of computer graphic systems. It is a method of performing some operations on an image and getting an enhanced image from a given image.


2 Answers

If they are vectors, you could use an SVG Editor (eg, Inkscape) along with Kirill's SVG to Java2D Transcoder to simplify this. It isn't perfect, but Kirill is very responsive in responding to requests for enhancement.

like image 141
jsight Avatar answered Nov 15 '22 09:11

jsight


It's unclear what you are asking. Two guesses:

  1. You want an existing program that allows you to draw a picture, captures what you do as you draw, and writes each action as a Java command. When you click the "Drawl Oval" tool and click at 0,0 and then at 50,50, it would generate the line g.drawOval(0,0,50,50).

    I do not know of any such tool. But the above might help you reword your question so that others can share their knowledge.

  2. You want a program that takes an existing bitmap and converts it into a series of commands that will replicate the bitmap. Other than simply outputting pixels, such a tool is nearly impossible to write; attempting to decompose an arbitrary picture into simple drawing commands is very hard.

    In this case, I would recommend simply importing the bitmap as a JPG, PNG, whatever, and using drawImage() instead of using Graphics calls.

like image 24
Alex Feinman Avatar answered Nov 15 '22 07:11

Alex Feinman