I'm trying to write a program for my Lego Mindstorm NXT, the program is simple, drawing some lines and saving the image in a .png file. So, I thought I'd use BufferedImage and use getGraphics to draw on it, the thing is; if I write the code:
import java.awt.image.BufferedImage;
import lejos.nxt.Button;
public class Main {
public static void main(String[] args) {
System.out.println("Test\n");
BufferedImage bimg = new BufferedImage(300,300, BufferedImage.TYPE_3BYTE_BGR);
Button.waitForAnyPress();
}
}
When I run the program, it freezes for a while in "Linking..." and gives me the following:
Java Heap Space
Java.Lang.OutOfMemory
So the question is this: How can I use BufferedImage with Lejos without having this problem? And if there's another method of drawing lines and saving the image on a file, it would be very helpful.
EDIT: The Java Heap Space is caused by the line
BufferedImage bimg = new BufferedImage(300,300, BufferedImage.TYPE_3BYTE_BGR);
I've also tried using ImageIO:
import javax.microedition.lcdui.Image;
*
*
Image img = Image.createImage(300, 300);
ImageIO.write((RenderedImage) img, "png", monFichier);
It gives me the same thing. I don't know but maybe this isn't the right way to create an image with Lejos. What do you think?