Help with a drycrpt program

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Nov 2008
Posts: 1
Reputation: thebiff is an unknown quantity at this point 
Solved Threads: 0
thebiff thebiff is offline Offline
Newbie Poster

Help with a drycrpt program

 
0
  #1
Nov 4th, 2008
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.

  1. /**
  2.  * Decrypt.java
  3.  * Starter file for secret image Comp 110 project
  4.  * Ian Jones
  5.  */
  6.  
  7. import java.awt.Image;
  8. import java.awt.*;
  9. import java.awt.event.*;
  10. import javax.imageio.*;
  11. import java.awt.image.BufferedImage;
  12.  
  13.  
  14. public class Decrypt {
  15. String path, pictureFile;
  16. Picture aPicture;
  17. Pixel aModified;
  18. Pixel aBrightened;
  19.  
  20.  
  21.  
  22. public Decrypt() {
  23.  
  24. path = System.getProperty("user.dir");
  25. FileChooser.setMediaPath("c:/Documents and Settings/Biff/Desktop/");
  26. System.out.println("Get the picture to decrypt");
  27. pictureFile = FileChooser.pickAFile();
  28. aPicture = new Picture(pictureFile);
  29. System.out.println(aPicture);
  30. aPicture.show();
  31.  
  32. }
  33.  
  34. public void decryptPicture() {
  35. Pixel[] pixel;
  36. aPicture.explore();
  37. for(int x=0; x<aPicture.getWidth()-1; x++){
  38. for(int y=0; y<aPicture.getHeight()-1; y++){
  39. if((x+y)%2==0)
  40. pixel.setRed(255);
  41. pixel.setBlue(0);
  42. pixel.setGreen(0);
  43. }
  44. }
  45.  
  46. System.out.println("modified " + aModified + " brightened " + aBrightened
  47. + " pixels");
  48. aPicture.repaint();
  49. aPicture.write("decryptedPicture.png");
  50. System.out.println("wrote decryptedPicture.png");
  51.  
  52. }
  53.  
  54. public static void main(String[] args) {
  55. Decrypt app = new Decrypt();
  56. app.decryptPicture();
  57. System.out.println("Decrypt is done");
  58. }
  59. }
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 19
Reputation: bionicseraph is an unknown quantity at this point 
Solved Threads: 6
bionicseraph bionicseraph is offline Offline
Newbie Poster

Re: Help with a drycrpt program

 
0
  #2
Nov 4th, 2008
What exactly are you stuck on? Make sure to put your code in tags...
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 137
Reputation: PoovenM is on a distinguished road 
Solved Threads: 11
PoovenM PoovenM is offline Offline
Junior Poster

Re: Help with a drycrpt program

 
0
  #3
Nov 5th, 2008
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?
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the Java Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC