Graphics

Z

zajekurwabiscie

Hi, my name is Janek and I have a small question about
paintComponent(Graphics g) - to draw for example LINE I should use
g.drawLine but what if I have my own Graphics created somewhere else.
More precisely I have:

BufferedImage backimage;
Graphics2D offScreen;
offScreen = backimage.createGraphics();
offScreen.drawLine(0,0,10,10);

and I would like to display it using paintComponent(Graphics g).
How can I do it ?
 
A

Andrew Thompson

On Feb 26, 5:23 am, (e-mail address removed) wrote:
...
BufferedImage backimage; ...
and I would like to display it using paintComponent(Graphics g).

g.drawImage(backimage, 0, 0, null);

Andrew T.
 
Z

zajekurwabiscie

g.drawImage(backimage, 0, 0, null);
Andrew T.

But I want to draw not only the image but also all changes done to
that image :

BufferedImage backimage;
Graphics2D offScreen;
offScreen = backimage.createGraphics();
offScreen.drawLine(0,0,10,10); <-------------- I
need this too !!!!!!!!
 
Z

zajekurwabiscie

I want to draw not only the image but also all applied changes :

BufferedImage backimage;
Graphics2D offScreen;
offScreen = backimage.createGraphics();
offScreen.drawLine(0,0,10,10); <------------- I need to draw
it too !!!!!!!
 
Z

zajekurwabiscie

U were right !!! Sorry for my luck of trust. I had a misteke !
BTW it's not natural - I mean creating a graphics object from image
( offScreen = backimage.createGraphics(); )
then using n changing Graphics object but changes are applied to
image :|

This line suggests that offScreen is created from backimage n this
image is no longer involved
offScreen = backimage.createGraphics();
but than we paint or save backimage :| WHY ?? HOW ??
 
A

Andrew Thompson

U were right !!!

Please note that while some abbreviations
are OK for this group, and others are needed,
abbreviations like 'u', and 'plz' generally
are not liked. Please attempt to spell short
words like 'you' properly. Also, only one '!'
gets the point across!
Sorry for my luck of trust.

Why should we trust each other? Tests
are always better, and note that I would
not expect someone who does not know me,
to take anyhting I say 'on trust'.
..I had a misteke !
BTW it's not natural - I mean creating a graphics object from image
( offScreen = backimage.createGraphics(); )
then using n changing Graphics object but changes are applied to
image :|

This line suggests that offScreen is created from backimage n this
image is no longer involved
offScreen = backimage.createGraphics();

The word 'create' does suggest (to me) that
the Graphic object is 'newly created' and
therefore 'separate' from the BufferedImage,
but it would probably be better called
'getGraphics', ainsce it gets *the* graphics
object of te image, and all changes (lines,
colors, circles) to the graphic, are stored
in the image.
but than we paint or save backimage :| WHY ?? HOW ??

It shows the Image, as it was after the
last changes made to the graphic object.

(And last note, ALL CAPS is equivalent
to SHOUTING. Please don't shout at me,
because I have a hangover..)

Andrew T.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top