Click here to Skip to main content
15,887,585 members
Home / Discussions / Java
   

Java

 
AnswerRe: C to Java translation Pin
thatraja13-Jan-14 6:43
professionalthatraja13-Jan-14 6:43 
AnswerRe: C to Java translation Pin
jschell13-Jan-14 9:25
jschell13-Jan-14 9:25 
QuestionResize objects from an ArrayList Pin
ririsuperstar11-Jan-14 4:44
ririsuperstar11-Jan-14 4:44 
Questionjava technology Pin
Member 1051702110-Jan-14 16:25
Member 1051702110-Jan-14 16:25 
AnswerRe: java technology Pin
Richard Andrew x6410-Jan-14 16:44
professionalRichard Andrew x6410-Jan-14 16:44 
GeneralRe: java technology Pin
Richard MacCutchan10-Jan-14 22:11
mveRichard MacCutchan10-Jan-14 22:11 
AnswerRe: java technology Pin
Richard MacCutchan10-Jan-14 22:11
mveRichard MacCutchan10-Jan-14 22:11 
QuestionWould like to retrieve RGB pixel values from another method but couldn't retrieve it Pin
nurul azila9-Jan-14 5:02
nurul azila9-Jan-14 5:02 
I'm still new to Java. I'm having trouble while retrieving the RGB pixel values from my method, compareHexaRGB which in this method I could get the difference pixel values based on comparison of 2 similar images. I tried the printString2DArray method but it doesn't work. It stated either incompatible types: String[][] cannot be converted to String[] or produce errors such as [[Ljava.lang.String;@6d09a8df

After I get the values, I would like to combine it to one Hex value then convert it to ASCII characters. I couldn't proceed to this process as the retrieve value couldn't work.

Here is the code for compareHexaRGB() method:

public class compareHexaRGB
 {
  private static int w;
  private static int h;
  private static BufferedImage img;
  private static BufferedImage img2;
  private static String[][] check_hex2;
  private static String[][] check_hex4;
  private static String[][] message;

  public static void compareHexaRGB(BufferedImage image, BufferedImage image2, int width, int height) throws IOException
 {
 w = width;
 h = height;
 img = image;
 img2 = image2;

 }

 public void check() throws IOException
 {
     getPixelRGB1 pixel = new getPixelRGB1();
     getPixelData1 newPD = new getPixelData1();

     int[] rgb;
     int count = 0;

     int[][] pixelData = new int[w * h][3];
     check_hex2 = new String[w][h];
     check_hex4 = new String[w][h];

     for(int i = 0; i < w; i++)
     {
         for(int j = 0; j < h; j++)
         {
             rgb = newPD.getPixelData(img, i, j);

             for(int k = 0; k < rgb.length; k++)
             {
                 pixelData[count][k] = rgb[k];
             }

                 if(pixel.display_imgHex2()[i][j].equals(pixel.display_img2Hex2()[i][j]))
                 {
                     System.out.println("\nPixel values at position 2 are the same." + "\n" + pixel.display_imgHex2()[i][j] + "  " + pixel.display_img2Hex2()[i][j]);
                 }
                 if(pixel.display_imgHex4()[i][j].equals(pixel.display_img2Hex4()[i][j]))
                 {
                     System.out.println("\nPixel values at position 4 are the same." + "\n" + pixel.display_imgHex4()[i][j] + "  " + pixel.display_img2Hex4()[i][j]);
                 }
                 if(!pixel.display_imgHex2()[i][j].equals(pixel.display_img2Hex2()[i][j]))
                 {
                     System.out.println("\nPixel values at position 2 are not the same." + "\n" + pixel.display_imgHex2()[i][j] + "  " + pixel.display_img2Hex2()[i][j]);
                     check_hex2[i][j] = pixel.display_img2Hex2()[i][j];
                     System.out.println("\nOutput Hex 2: " + check_hex2[i][j]);
                 }
                 if(!pixel.display_imgHex4()[i][j].equals(pixel.display_img2Hex4()[i][j]))
                 {
                     System.out.println("\nPixel values at position 4 are not the same." + "\n" + pixel.display_imgHex4()[i][j] + "  " + pixel.display_img2Hex4()[i][j]);
                     check_hex4[i][j] = pixel.display_img2Hex4()[i][j];
                     System.out.println("\nOutput Hex 4: " + check_hex4[i][j]);
                 }
                 if(!pixel.display_imgHex2()[i][j].equals(pixel.display_img2Hex2()[i][j]) || (!pixel.display_imgHex4()[i][j].equals(pixel.display_img2Hex4()[i][j])))
                 {
                     System.out.println("\nOne of the pixel values at position 2 and 4 are not the same." + "\n" + pixel.display_imgHex2()[i][j] + "  " + pixel.display_img2Hex2()[i][j] + "\n" + pixel.display_imgHex4()[i][j] + "  " + pixel.display_img2Hex4()[i][j]);

                     if(!pixel.display_imgHex2()[i][j].equals(pixel.display_img2Hex2()[i][j]) || (pixel.display_imgHex2()[i][j].equals(pixel.display_img2Hex2()[i][j])))
                     {
                         check_hex2[i][j] = pixel.display_img2Hex2()[i][j];
                         System.out.println("\nOutput Hex 2: " + check_hex2[i][j]);
                     }

                     if(!pixel.display_imgHex4()[i][j].equals(pixel.display_img2Hex4()[i][j]) || (pixel.display_imgHex4()[i][j].equals(pixel.display_img2Hex4()[i][j])))
                     {
                         check_hex4[i][j] = pixel.display_img2Hex4()[i][j];
                         System.out.println("\nOutput Hex 4: " + check_hex4[i][j]);
                     }

                 }
             count++;
             System.out.println("\nOutput Count: " + count);
         }

     }

 }

 public String[][] getCheck_hex2()
 {
     return check_hex2;
 }

 public String[][] getCheck_hex4()
 {
     return check_hex4;
 }
 }


Code for extractMessage() method:
public class extractMessage
{
private static String character;
private static String[][] char1;
private static String[][] char2;
private static int w;
private static int h;

private static void printString2DArray(String[][] in)
{
    for (int i = 0; i < in.length; i++)
    {
        if (i != 0)
        {
            System.out.print(", ");
        }
        System.out.print(java.util.Arrays.toString(in[i]));
    }
}

public static void charExtract()
{
compareHexaRGB hexRGB = new compareHexaRGB();

char1 = new String[][]
{
new String[] { hexRGB.getCheck_hex2() } //error stated incompatible types
};

System.out.println("Char 1: ");
printString2DArray(hexRGB.getCheck_hex2());

}

public String convertHexToString()
{
StringBuilder sb = new StringBuilder();
StringBuilder temp = new StringBuilder();

extractMessage extract = new extractMessage();
extract.charExtract();

for(int i = 0; i < extract.length(); i+=2) //error stated couldn't find symbol extract
{
String output = extract.substring(i, (i + 2));
int decimal = Integer.parseInt(output, 16);
sb.append((char)decimal);

temp.append(decimal);
}
return sb.toString();
}
}

Any help I would appreciate!

modified 9-Jan-14 11:23am.

QuestionRe: Would like to retrieve RGB pixel values from another method but couldn't retrieve it Pin
Richard MacCutchan9-Jan-14 21:17
mveRichard MacCutchan9-Jan-14 21:17 
QuestionProblem is to classify whether the video on YouTube is harassment type or not... Pin
nishaaggarwal8-Jan-14 22:39
nishaaggarwal8-Jan-14 22:39 
QuestionRe: Problem is to classify whether the video on YouTube is harassment type or not... Pin
Richard MacCutchan8-Jan-14 23:39
mveRichard MacCutchan8-Jan-14 23:39 
QuestionCode to convert from C# to Java (with goto) Pin
Kujtim Hyseni8-Jan-14 9:00
Kujtim Hyseni8-Jan-14 9:00 
AnswerRe: Code to convert from C# to Java (with goto) Pin
gettgotcha8-Jan-14 9:20
gettgotcha8-Jan-14 9:20 
AnswerRe: Code to convert from C# to Java (with goto) Pin
Richard MacCutchan8-Jan-14 22:24
mveRichard MacCutchan8-Jan-14 22:24 
GeneralRe: Code to convert from C# to Java (with goto) Pin
Kujtim Hyseni9-Jan-14 1:45
Kujtim Hyseni9-Jan-14 1:45 
GeneralRe: Code to convert from C# to Java (with goto) Pin
Richard MacCutchan9-Jan-14 1:52
mveRichard MacCutchan9-Jan-14 1:52 
QuestionTool for generating JNI (calling C/C++ code from java) Pin
doofx8-Jan-14 3:19
doofx8-Jan-14 3:19 
AnswerRe: Tool for generating JNI (calling C/C++ code from java) Pin
Richard MacCutchan8-Jan-14 6:09
mveRichard MacCutchan8-Jan-14 6:09 
GeneralRe: Tool for generating JNI (calling C/C++ code from java) Pin
doofx8-Jan-14 6:25
doofx8-Jan-14 6:25 
GeneralRe: Tool for generating JNI (calling C/C++ code from java) Pin
Richard MacCutchan8-Jan-14 6:44
mveRichard MacCutchan8-Jan-14 6:44 
GeneralRe: Tool for generating JNI (calling C/C++ code from java) Pin
doofx8-Jan-14 8:13
doofx8-Jan-14 8:13 
QuestionError in JFrame while Drawing Graphics2D Pin
f2630-Dec-13 19:54
f2630-Dec-13 19:54 
AnswerRe: Error in JFrame while Drawing Graphics2D Pin
Richard MacCutchan30-Dec-13 23:06
mveRichard MacCutchan30-Dec-13 23:06 
GeneralRe: Error in JFrame while Drawing Graphics2D Pin
f2630-Dec-13 23:57
f2630-Dec-13 23:57 
Questionfinger prints (Bio Metrics) Pin
Member 1048716225-Dec-13 6:11
Member 1048716225-Dec-13 6:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.