| | |
Help with a drycrpt program
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Nov 2008
Posts: 1
Reputation:
Solved Threads: 0
Hi i have been trying to write a code that takes a picture and gets the odd valued pixels and turns them red, and also get the even values pixels and make them brighter. I am stuck and any help would be appriciated.
Java Syntax (Toggle Plain Text)
/** * Decrypt.java * Starter file for secret image Comp 110 project * Ian Jones */ import java.awt.Image; import java.awt.*; import java.awt.event.*; import javax.imageio.*; import java.awt.image.BufferedImage; public class Decrypt { String path, pictureFile; Picture aPicture; Pixel aModified; Pixel aBrightened; public Decrypt() { path = System.getProperty("user.dir"); FileChooser.setMediaPath("c:/Documents and Settings/Biff/Desktop/"); System.out.println("Get the picture to decrypt"); pictureFile = FileChooser.pickAFile(); aPicture = new Picture(pictureFile); System.out.println(aPicture); aPicture.show(); } public void decryptPicture() { Pixel[] pixel; aPicture.explore(); for(int x=0; x<aPicture.getWidth()-1; x++){ for(int y=0; y<aPicture.getHeight()-1; y++){ if((x+y)%2==0) pixel.setRed(255); pixel.setBlue(0); pixel.setGreen(0); } } System.out.println("modified " + aModified + " brightened " + aBrightened + " pixels"); aPicture.repaint(); aPicture.write("decryptedPicture.png"); System.out.println("wrote decryptedPicture.png"); } public static void main(String[] args) { Decrypt app = new Decrypt(); app.decryptPicture(); System.out.println("Decrypt is done"); } }
•
•
Join Date: Aug 2006
Posts: 137
Reputation:
Solved Threads: 11
You make use of certain classes that aren't part of the standard Java API so I'm unable to really follow the code you've given. I did notice that you create a Pixel array in method decryptPicture() and then you begin to populate the array depending on a Boolean evaluation. Since Pixel is a class you will definitely get a null exception when you attempt to populate the array.
When creating an array of objects you must instantiate each element of that array before using it. If you don't understand this concept please feel free to ask for a better explanation.
For us to better help you I need to know if you've found a way to access each pixel from the image? I notice you have classes created that seem to do this but it's safer to ask then to assume you do.
If you've successfully managed to get access to each pixel then it seems the code you're missing would be to increase the brightness of the even valued pixels; am I correct? The general way this would be done is with a filter (I think that a Gaussian filter would increase the brightness) but perhaps you could simply increase the RGB values of the pixel by some constant?
When creating an array of objects you must instantiate each element of that array before using it. If you don't understand this concept please feel free to ask for a better explanation.
For us to better help you I need to know if you've found a way to access each pixel from the image? I notice you have classes created that seem to do this but it's safer to ask then to assume you do.
If you've successfully managed to get access to each pixel then it seems the code you're missing would be to increase the brightness of the even valued pixels; am I correct? The general way this would be done is with a filter (I think that a Gaussian filter would increase the brightness) but perhaps you could simply increase the RGB values of the pixel by some constant?
![]() |
Other Threads in the Java Forum
- Previous Thread: hi! can anyone please help me complete this code
- Next Thread: create database at run time
| Thread Tools | Search this Thread |
911 actionlistener addressbook android api append applet application array arrays automation binary block bluetooth character chat class client code component consumer csv database desktop eclipse error fractal ftp game givemetehcodez graphics gui html ide image input integer j2me japplet java javaarraylist javac javaee javaprojects jmf jni jpanel julia linked linux list loop mac map method methods mobile netbeans newbie number objects online oriented panel print printf problem program programming project projects properties recursion replaydirector reporting researchinmotion rotatetext rsa scanner screen se server set size sms sort sql string swing template test threads time title tree tutorial-sample ubuntu update windows working





