Hello, my many merry Moldering men. I have some psych homework to get to, and I imagine you're all busy too, so I'll try to keep this brief.
My question: If I want to be able to create an image dynamically and efficiently, what language should I use, and what are all of the libraries / extensions / plugins I need to get it done? I've tried in C++ and Java; Java breaks inexplicably, while C++ requires a nested list of libraries, each with their own prerequisites. What did you use for Moldering, and would you recommend it for me? At first, I'd like to be able to render vector fields (faster than my current method, which is Javascript>HTML rendering little tiny colored table cells.)
I don't care if it's free-coordinate based like Flash's graphics or created as a matrix indexed by the pixel position. Ultimately, I'd like the choice between automatically saving/rewriting or rendering to the screen, and I'd like to be able to animate it, and I'd like it to have fast HSL compatibility, but all of the fancy stuff can come later. For now I just want a way of a) making or loading an image, B) editing the contents, and c) saving or rendering the result.
Bonus if the language/compiler/add-ons/etc. is all free.
The incentive: I'm back in the game. I came here to check it out and it sounds like you have a beta floating around... at the very least, I can be a tester. I know I didn't contribute much the first time around, but I can this time. I'm better at making sprites, now, too.
Have a Zufable for your time.
Hahaha, nice image.
Okay, this will be long but will be specific. Just make sure you have enough time to read it slowly, understand it, and take it all in. Then, you should be able to create a simple application that does the majority of what you want. Then, from there we can do the rest.
I know java extensively so I recommend that. Not only because it is familiar but because I've written code to optimize image creation, and also because you can make it an applet and run it within a browser.
Now, there isn't really a simple solution. Any language will require a little bit of setup before you can load in an image and alter it, however if you download the java sdk (software developer kit), it will include all the code necessary to do what you, do it in an applet, and also to let anyone else run it who already has java installed (virtually anyone who connects to the internet) without needing to install or have any additional libraries or patches.
I can point you in the right direction, and I can also give you some code I've written to help optimize image creation.
You'll need the following things to load an image, alter it, and create/save it. We can start there.
Start writing a java program and include the following libraries (this is essential for any java program so you'll need to research this if you want to write this, and any, programs):
| CODE |
java.awt.image.BufferedImage; java.imageio.ImageIO; java.awt.Graphics2D |
With ImageIO you can read an image from a file. You will want to load it as a bufferedImage. When you get this all sorted out I can link you to my imageOptimizer code which will only require you change 2 lines of code or so and that you include the source. You can open an image like this:
| CODE |
| BufferedImage myImage = ImageIO.read("file.png"); |
From there you now have what's called a BufferedImage. They can be altered, displayed, or saved to a file. They're called buffered images because you can alter the buffered data inside the image.
Now, to draw on it you'll need to create a Graphics2D object like so,
| CODE |
| Graphics2D myGraphicsObject; |
Then you will need to make this graphics object associated with the image like so:
| CODE |
| myGraphicsObject = (whatever you called you bufferedimage).getGraphics(); |
Of course you need to replace that comment with your BufferedImage. Then you will be able to call any of the drawing methods on that graphics object and it will draw onto the image. So, for example you could write:
| CODE |
| myGraphicsObject.drawRext(0,0,10,10); |
All of the methods for Graphics2D are here
http://download.oracle.com/javase/1.4.2/do...Graphics2D.htmlYou can also find the API (Application Programmers Interface) pages for the other classes I have been discussing.
Then, next you need to do the final thing for now, which is to draw to the screen, and depending on whether you want this to be an applet or not you will need to create your applet, or what is called a JFrame (a regular program window).
Each of them has a ContentPane within and you can swap out the ContentPane with a Canvas. By setting the contentPane of the applet or JFrame to a canvas you can then call the method of the canvas that allows you to draw to it. A canvas is a drawing surface that can be put into an applet or a JFrame. The code looks like this:
| CODE |
| canvas.paint(myGraphicsObjects); |
I know that seems like a lot to digest but I think it was pretty thorough and if you take it one step at a time you should be able to build a pretty simple application. The first step of course is to create an applet or jframe. The second is to load your file and display it, and your third task should be to alter the buffered Image.
From there you have a simple working application and a basic understanding as to how it works. Take it one step at a time and get each step working before proceeding to the next. It would likely take me an hour or less to write this application but I have considerable programming experience (specifically Java), so I expect it would take you most of a day from what experience I think you have with Java (very little?).
Let me know how that works out. If you have some experience with Java and it seems to be giving you trouble at a specific point then I can explain. or else, if you are having trouble because you don't know where to start but think you'd be able to understand the code if I wrote it (and don't mind learning by seeing and understanding, rather than doing) I can write a small application that loads in an image and draws a rectangle over it and displays it. In that scenario send me a test image and let me know if you wish to write an applet or a stand alone application.
Well, I got swamped with homework in between when I posted that and when I came back. Since then I've mucked around with intro tutorials getting used to Netbeans and some of the basics of the language (while the forum was down...?).
I'll try tomorrow during class. I have math and it's a joke, I should be able to spend the whole time doing this stuff. ;)