painkiller102's Profile User Rating: -----

Reputation: 14 Tradesman
Group:
Contributors
Active Posts:
281 (0.15 per day)
Joined:
27-February 08
Profile Views:
4,351
Last Active:
User is offline Feb 22 2013 11:29 PM
Currently:
Offline

Previous Fields

Country:
US
OS Preference:
Windows
Favorite Browser:
FireFox
Favorite Processor:
Intel
Favorite Gaming Platform:
PC
Your Car:
Who Cares
Dream Kudos:
50

Latest Visitors

Icon   painkiller102 has not set their status

Posts I've Made

  1. In Topic: problem reading colors from a bufferedimage

    Posted 11 Feb 2013

    View Postpbl, on 11 February 2013 - 11:51 AM, said:

    View Postpainkiller102, on 11 February 2013 - 12:52 AM, said:

    I wish there was a way to be able to pull out exactly what was drawn to the image to begin with.

    If you knew the original Image background may be a brute force algorithm may achieve that but the problem is false, in the sense that I can't figure out an application that would require such and editing, to start with.


    Well it was going to be used as part of an eye dropper tool. So the user can select the pixel and then re-draw it with the same color and alpha value. I can always change it to take a sub-image and then re-draw that image where the user selects, but that is more of a workaround to what i was wanting, but still it will work.
  2. In Topic: problem reading colors from a bufferedimage

    Posted 10 Feb 2013

    View Postpbl, on 10 February 2013 - 02:40 AM, said:

    What let you think so ?
    The BufferedImage method getRGB(int x, int y) is probably one of the Image easiest method to use.
    So what is the actual outputed values and the expected one ?

    The use of Alpha will screw up your read back as it will be mixed with the default background color

    An Alpha of 100 will bring more accurate results


    yea that was what i was afraid of. I wanted to pull out accurate information for each pixel, but sense the user can change the pixels alpha value, this creates the accuracy problem. The values are commonly only 1-5 off of the original color. I wish there was a way to be able to pull out exactly what was drawn to the image to begin with. The only way i can think of doing it is to log the colors themselves in an array but that's obviously going to lead to a bigger file size when i saved a serialized class with them all.

    Just as an edit, i have played around with transparency a bit more in a professional image editing program. It would seem if i can get rid of the alpha value somehow the original RGB values would be restored. In an image editing program, i would just continue to draw the transparent pixel over and over again until it was solid. In my case however, i cannot just do:

    BufferedImage drawOver = new BufferedImage(50,50,BufferedImage.TYPE_INT_ARGB);
            g = drawOver.getGraphics();
            color1 = new Color(img.getRGB(0, 0),true);
            g.setColor(color1);
            g.fillRect(0, 0, 50, 50);
            g.fillRect(0, 0, 50, 50);
            g.fillRect(0, 0, 50, 50);
            g.fillRect(0, 0, 50, 50);
            g.fillRect(0, 0, 50, 50);
            g.fillRect(0, 0, 50, 50);
    
    


    to fix the issue. All this does is replace the old pixel with the new one, and doesn't actually re-draw the pixel over the first one. Is there a way for me to re-draw pixels instead of just replacing them?
  3. In Topic: Get Files From Portable Device

    Posted 1 Sep 2011

    View Postfarrell2k, on 01 September 2011 - 10:04 AM, said:

    It's definitely not a java issue. Try doing control panel -> computer management -> disk storage to see if you can find a drive letter there.


    I honestly don't think there is a drive letter at all. If there was it would show up on the file chooser. I don't think the devices work as such by using a drive letter (which blows my mind because i was under the impression that all devices were assigned a drive-letter).
  4. In Topic: Using an applet to search an array assignment 3

    Posted 31 Aug 2011

    It would be best to set the 'clearFields' as a public method. like:

       public void actionPerformed(ActionEvent e)
       {
          //Assigning data
          id = idField.getText();
          password = passwordField.getText();
          success = false;
    
          //Sequential search
          for(int i=0; i<6; i++)
          {
    		  if((idArray[i].compareTo(id)==0) && (passwordArray[i].compareTo(password)==0))
    		  success = true;
    	  }
    
    	  if(success)
    	  {
    		  headerLabel.setText("Login Successful");
    		  clearField();
    	  }//close if
    	  else
    	  {
    		  repaint();
    	  }//close action performed
           }
    
           public void clearFields()
           {
               idField.setText("")
               passwordField.setText("");
               idField.requestFocus();
           }
    
    


    Edit: sorry it's a bit messy, but you should still get the idea from it :blink:
  5. In Topic: Counting vowels from an existing file

    Posted 29 Aug 2011

    Well the first thing you might want to do is make the entire thing one string.

    so adjust your code to:

    ]import java.util.Scanner;
    
    public class ReadData {
    
        public static void main(String[] args) throws Exception {
            // Create a File instance
            java.io.File file = new java.io.File("scores.txt");
    
            // Create a Scanner for the file
            Scanner input = new Scanner(file);
            
            // Create the Content String        
            String fileContent = "";
    
            // Read data from a file
            while (input.hasNext()) {
                fileContent += input.next() + " ";
            }
            // Close the file
            input.close();
    
    


    That should get all of the files data into one solid string. The next thing we need to do is split the string into a character array:

    char[] charArr = fileContent.toCharArray();
    
    


    Now we need to loop through every character and look for 'a' 'e' 'i' 'o' 'u' and 'y' <- If you wish to use Y as a vowel.

    int counter = 0;
    for(char c : charArr)
    {
         if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y')
              counter++;
    }
    System.out.println("Number of Vowels: " + counter);
    
    


    And that should be all there is to it! the final code should look like:
    import java.util.Scanner;
    
    public class ReadData {
    
        public static void main(String[] args) throws Exception {
            // Create a File instance
            java.io.File file = new java.io.File("scores.txt");
    
            // Create a Scanner for the file
            Scanner input = new Scanner(file);
            
            // Create the Content String        
            String fileContent = "";
    
            // Read data from a file
            while (input.hasNext()) {
                fileContent += input.next() + " ";
            }
            // Close the file
            input.close();
    
            //Split the string into a character array
            char[] charArr = fileContent.toCharArray();
    
            //loop through every character to find the vowels
            int counter = 0;
            for(char c : charArr)
            {
                  if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y')
                       counter++;
            }
           
            //Tell the user the number of vowels
            System.out.println("Number of Vowels: " + counter);
    
    

My Information

Member Title:
D.I.C Regular
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:
Interests:
Programming random (most of the time useless) apps. And watching TV and the usual what nots
Years Programming:
3
Programming Languages:
C#,C++(very little),Java,Visual Basic,Action Script(a bit), and lots and lots of Autoit

Contact Information

E-mail:
Private
Website URL:
Website URL  http://

Friends

painkiller102 hasn't added any friends yet.

Comments

painkiller102 has no profile comments yet. Why not say hello?