473,490 Members | 2,635 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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

1 New Member
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.

Expand|Select|Wrap|Line Numbers
  1. private void hide_image()
  2.     {
  3.         string file = openFileDialog1.FileName;
  4.         original = (Bitmap)Bitmap.FromFile(file);
  5.  
  6.         Color color,color1, color2, color3;
  7.         int value;
  8.         int r1, b1, g1, a1;
  9.         int pixelR, pixelG, pixelB, pixelA;
  10.         for (int i = 0; i < original.Width; i++)
  11.         {
  12.             for (int j = 0; j < original.Height; j++)
  13.             {
  14.                 color = bmp.GetPixel(i, j);
  15.                 color2 = original.GetPixel(i, j);
  16.                 r1 = color2.R;
  17.                 b1 = color2.B;
  18.                 g1 = color2.G;
  19.                 a1 = color2.A;
  20.  
  21.                 value = color.R;
  22.  
  23.                 byte[] array = getBytes(value);
  24.                 byte[] arrayR1 = getBytes(r1);
  25.                 byte[] arrayG1 = getBytes(g1);
  26.                 byte[] arrayB1 = getBytes(b1);
  27.                 byte[] arrayA1 = getBytes(a1);
  28.  
  29.                 arrayR1[6] = array[0];
  30.                 arrayR1[7] = array[1];
  31.                 arrayG1[6] = array[2];
  32.                 arrayG1[7] = array[3];
  33.                 arrayB1[6] = array[4];
  34.                 arrayB1[7] = array[5];
  35.                 arrayA1[6] = array[6];
  36.                 arrayA1[7] = array[7];
  37.  
  38.                 pixelR = getInt(arrayR1);
  39.                 pixelG = getInt(arrayG1);
  40.                 pixelB = getInt(arrayB1);
  41.                 pixelA = getInt(arrayA1);
  42.                 color3 = Color.FromArgb(pixelA, pixelR, pixelG, pixelB);
  43.                 original.SetPixel(i, j, color3);
  44.             }
  45.         }
  46.         pictureBox4.Image = original;
  47.  
  48.       }
In C# i am using color object to get the separate the values of RGB.How will i get those in java?
Dec 15 '14 #1
0 1141

Sign in to post your reply or Sign up for a free account.

Similar topics

4
1716
by: John | last post by:
Hi all; I write my first code using vector and list. When I run it, segmentation fault. Try to debug it, but it can not pass linking with -g option. What is the error with it? Thanks a lot....
6
1241
by: yezi | last post by:
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <errno.h> #include <string.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h>...
12
1453
by: Michael Culley | last post by:
I found this code in a project: StringBuilder sb = new StringBuilder(); sb.Append("SELECT * FROM SomeTable") .Append("WHERE SomeField = SomeValue") .Append("ORDER BY etc etc etc") at first I...
6
1484
by: Joshepmichel | last post by:
package librarySystemV5; import java.sql.*; import java.util.*; public class DatabaseTableViewer { private static final String DB = "mytestdb", ...
2
1866
by: samvb | last post by:
Hi, I have this code: CSS: .onlineuserscon {width:98%; float:left; background-color:#fff;} .onlineusersul {list-style:none; margin:0; padding:0;} .onlineuserimg {width:150px; padding:7px;...
2
1361
by: doyan | last post by:
#include<dos.h> void main(void) { while(1) { outportb(0x378, 0xFF); delay(1000); outportb(0x378, 0x00); delay(1000); }
3
1712
by: khatereh | last post by:
what is the meaning of this code volatile BOOL GotSUD; BOOL Rwuen; BOOL Selfpwr;
2
1154
abdoelmasry
by: abdoelmasry | last post by:
What is the wrong with this code ? it always returns zero matches. I think it should return two matches, I need to read how may tags like this pattern <!== any thing ==!>
0
7112
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6974
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
6852
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7356
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5448
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4878
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3084
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
628
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
277
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.