columbo666
asked on
drawing to buffer + flip to window
any sourcecodes for the following problem :
- i want to draw to a 2d array (24bit if possible)
- flip the array to the screen (to a size-fixed window)
- hell-fast (if possible)
do you have any sources for this. inclusive creating the size-fixed window and everything else. i want to calc some graphic effects (plasmas, etc.). if you've got any additional questions, feel free to ask.
thank you very much. i appreciate every comment.
- i want to draw to a 2d array (24bit if possible)
- flip the array to the screen (to a size-fixed window)
- hell-fast (if possible)
do you have any sources for this. inclusive creating the size-fixed window and everything else. i want to calc some graphic effects (plasmas, etc.). if you've got any additional questions, feel free to ask.
thank you very much. i appreciate every comment.
ASKER
very good. any code ? i tried to use these createImage-things (and others), but i couldn't get them working.
For which one of the ways? 1.1 or 1.2 compatible?
Sasha Maryanovsky.
Sasha Maryanovsky.
ASKER
i've got 1.2, but you can do it also for 1.1. your decision
Well, 1.2 it's pretty easy:
int width = 300;
int height = 300;
BufferedImage img = new BufferedImage(width,height ,BufferedI mage.TYPE_ INT_RGB);
Graphics g = img.getGraphics();
// Do various painting on the Graphics here.
int [] pixels = img.getRGB(0,0,width,heigh t,null,0,w idth);
After this, "pixels" contains all the pixel values in aRGB format.
For 1.1, you will have to implement your own drawing routines, which is quite difficult, and I'm not going to explain this here :-)
Sasha Maryanovsky.
int width = 300;
int height = 300;
BufferedImage img = new BufferedImage(width,height
Graphics g = img.getGraphics();
// Do various painting on the Graphics here.
int [] pixels = img.getRGB(0,0,width,heigh
After this, "pixels" contains all the pixel values in aRGB format.
For 1.1, you will have to implement your own drawing routines, which is quite difficult, and I'm not going to explain this here :-)
Sasha Maryanovsky.
Umm, note that I didn't test this code, so it may be wrong :-)
Sasha Maryanovsky.
Sasha Maryanovsky.
hi !
guess this website may help u...
http://java.sun.com/docs/books/tutorial/2d/images/index.html
hope it helps..:)
guess this website may help u...
http://java.sun.com/docs/books/tutorial/2d/images/index.html
hope it helps..:)
ASKER
i can really use that. thanks. a small detail : i want to draw only single pixels (and fill the whole buffer with them). any fast possibilities ?
ASKER
sorry, finally i can't really use that. i just want a complete piece of code, which creates a non-resizable window and draws an (pixel based & flickerless) animation within.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
dunno, the project was done now without this and i can code java a bit now...
You can do that only since JDK1.2 by using BufferedImage.getGraphics(
>flip the array to the screen (to a size-fixed window)
Just draw the BufferedImage on a showing Window.
>hell-fast (if possible)
Well, you don't really control it using the method I described.
Alternatively, since JDK1.0, you can implement your own drawing procedures, which would draw into an int array. You would then convert the array into an Image using Toolkit.createImage(ImageP
To make the drawing as fast as possible, I recomment creating an offscreen Image using Component.createImage(int,
Sasha Maryanovsky.