Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Picture programming
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh pageAdd this topic to your bookmarks (CTRL-D) View next topic
Author Message
r.m_spy




PostPosted: Thu Jul 15, 2010 9:39 am   Post subject: Picture programming

I want to make a few programs for programming pictures. I would like to do it in java, but I really don't know how to do much, exept writing text to a file.

program 1 should do the following

load an image of the users choice
using something like turings "Whatdotcolor", it should assign a variable the color of a pixel(length,hieght)
write to a file "PIXEL (length,height) = color"

program 2 should

read a line from a file
if the command is pixel, it should put the color of the pixel in the pixel (therefor reconstructing the image)

then I could use it to program all sorts of commands like...

delay(time)

change the picture pixel by pixel

...

here is what I can do

FileWriter fw = new FileWriter"c:\\sample\\greet\\picture.txt");
PrintWriter pw = new printwriter(fw);
pw.println("Hello");
pw.println("world");
pw.close();
 
Sponsor
Sponsor
Sponsor
sponsor
Kharybdis




PostPosted: Thu Jul 15, 2010 9:49 am   Post subject: RE:Picture programming

It'd be a slow program... or relatively slow -_-
 
Euphoracle




PostPosted: Thu Jul 15, 2010 5:24 pm   Post subject: RE:Picture programming

It won't be slow. You can easily edit pixels in a BufferedImage object, but if all you know how to do is Hello World, you need to start by learning the language before dicking around with images.
 
TheGuardian001




PostPosted: Thu Jul 15, 2010 5:28 pm   Post subject: Re: Picture programming

I'd advise against doing this. It's really inefficient (PIXEL(XX,YY)= is 13 characters, plus however many bytes used to store a colour, all to store 1 pixels worth of information) and would probably not work anywhere near as well as you want it to.

However if you really want to try:
-the java.awt.Robot class has a getPixelColor(x,y) which returns a java.awt.Color object.
-writing to the file should be easy to do. You already know file output, just change the words you output.

Have you ever worked with Graphics at all? Do you know how to create windows and draw to them?
 
andrew.




PostPosted: Thu Jul 15, 2010 5:51 pm   Post subject: RE:Picture programming

The getPixelColor method in the Robot class will not only get colours for your program though. It will get whatever colour is at that pixel whether it's your program or not. So you have to know the boundaries of your window in relation to the screen coordinates.
 
Euphoracle




PostPosted: Thu Jul 15, 2010 5:55 pm   Post subject: RE:Picture programming

...Or you can use BufferedImage and the pixel accessors from there.... why are you complicating things....
 
andrew.




PostPosted: Thu Jul 15, 2010 7:00 pm   Post subject: RE:Picture programming

I never knew that...
 
TheGuardian001




PostPosted: Thu Jul 15, 2010 8:07 pm   Post subject: Re: Picture programming

Can you create a BufferedImage from an Applet/Frame's default graphics context?
 
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh pageAdd this topic to your bookmarks (CTRL-D) View next topic

Page 1 of 1  [ 8 Posts ]
Jump to:   


Style:  
Search: