| | |
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 |
-xlint add android api applet application array arrays automation bi binary blackberry bluetooth chat class classes client code compile compiler component converter database digit eclipse equation error event exception fractal freeze functiontesting game gameprogramming givemetehcodez graphics gui health html hyper ide idea image input int integer j2me java javame javaprojects jetbrains jni jpanel jtable julia learningresources linux list login loop main map method methods mobile myregfun netbeans newbie nonstatic notdisplaying page pearl print problem program programming project qt recursion scanner screen scrollbar server set size sms sort spamblocker sql string superclass swing system thread threads time tree variablebinding windows xor





