• Post Reply Bookmark Topic Watch Topic
  • New Topic

Retrieving Picture Drawn  RSS feed

 
MJ Seah
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I have a question to check with all of you... currently i am using swing to do my project that is why i am placing this question here.

Below is some of the coordinates which i have save in a DAT file:

X Value= 151 Y Value= 154
X Value= 155 Y Value= 151
X Value= 164 Y Value= 147
X Value= 178 Y Value= 141
X Value= 197 Y Value= 135
X Value= 217 Y Value= 128
X Value= 241 Y Value= 124
X Value= 262 Y Value= 120
X Value= 281 Y Value= 118

The question is how can i convert all this coordinates that i have save previously from a drawing, and load it back to screen that returns a picture of what i have drawn?

Is there a way to do it? Please do help me by providing the codings! Thank you very much!!!
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Obviously you need to read in the file to produce an array of X, Y values, and then draw them. You could use the String.split() method to write a simple parser, and Integer.parseInt() to turn Strings into int values.

Once you have the array, then your normal "paintComponent()" method can use it to draw the picture. I don't know if the X,Y values represent the vertices of a polygon, or "on" pixels vs. "off" pixels; what they are will obviously influence how you use them.
 
MJ Seah
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any Sample Codings on how to use them in either ways?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!