What will be the equivalent java code for this C# code?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Noob1234
    New Member
    • Dec 2014
    • 1

    #1

    What will be the equivalent java code for this C# code?

    I am making a web based stagenography appplication in java but i am stuck at how to get the individual values of Red Green and Blue in an image pixel.I have an equivalent code in C# but i am not able to split a pixel value into Red,Green and blue.

    The following code includes the function that hides the picture in another image.

    Code:
    private void hide_image()
        {
            string file = openFileDialog1.FileName;
            original = (Bitmap)Bitmap.FromFile(file);
    
            Color color,color1, color2, color3;
            int value;
            int r1, b1, g1, a1;
            int pixelR, pixelG, pixelB, pixelA;
            for (int i = 0; i < original.Width; i++)
            {
                for (int j = 0; j < original.Height; j++)
                {
                    color = bmp.GetPixel(i, j);
                    color2 = original.GetPixel(i, j);
                    r1 = color2.R;
                    b1 = color2.B;
                    g1 = color2.G;
                    a1 = color2.A;
    
                    value = color.R;
    
                    byte[] array = getBytes(value);
                    byte[] arrayR1 = getBytes(r1);
                    byte[] arrayG1 = getBytes(g1);
                    byte[] arrayB1 = getBytes(b1);
                    byte[] arrayA1 = getBytes(a1);
    
                    arrayR1[6] = array[0];
                    arrayR1[7] = array[1];
                    arrayG1[6] = array[2];
                    arrayG1[7] = array[3];
                    arrayB1[6] = array[4];
                    arrayB1[7] = array[5];
                    arrayA1[6] = array[6];
                    arrayA1[7] = array[7];
    
                    pixelR = getInt(arrayR1);
                    pixelG = getInt(arrayG1);
                    pixelB = getInt(arrayB1);
                    pixelA = getInt(arrayA1);
                    color3 = Color.FromArgb(pixelA, pixelR, pixelG, pixelB);
                    original.SetPixel(i, j, color3);
                }
            }
            pictureBox4.Image = original;
    
          }
    In C# i am using color object to get the separate the values of RGB.How will i get those in java?
Working...