473,625 Members | 2,770 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

get pixel value of image which is already displayed

12 New Member
How can I get pixel value of image? I have displayed the image using buffer now I wanted to know how i can get the pixel of the image.

Here is my code to display the image

Expand|Select|Wrap|Line Numbers
  1. import java.awt.*;
  2. import java.awt.image.BufferedImage;
  3. import java.io.*;
  4. import javax.imageio.ImageIO;
  5. import javax.swing.JFrame;
  6. public class ShowImage extends Panel {
  7.     BufferedImage  image;
  8.   public ShowImage() {
  9.     try {
  10.     System.out.println("Enter image name\n");
  11.     BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
  12.      String imageName=bf.readLine();
  13.     File input = new File(imageName);
  14.         image = ImageIO.read(input);
  15.     } catch (IOException ie) {
  16.       System.out.println("Error:"+ie.getMessage());
  17.     }
  18.   }
  19.  
  20.   public void paint(Graphics g) {
  21.     g.drawImage( image, 100,100, null);
  22.   }
  23.  
  24.   static public void main(String args[]) throws Exception {
  25.     JFrame frame = new JFrame("zinab");
  26.     Panel panel = new ShowImage();
  27.     frame.getContentPane().add(panel);
  28.     frame.setSize(500, 500);
  29.     frame.setVisible(true);
  30.   }
  31. }
May 21 '10 #1
1 3291
jkmyoung
2,057 Recognized Expert Top Contributor
Generally an image has multiple pixels. Do you mean a pixel array? What format of image is it and what class are you using to display it?
May 21 '10 #2

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

Similar topics

1
5054
by: Sinora | last post by:
I am trying to cahnge pixel value of a grayscale image using Bitmap object . Each pixel is consists of 8 bits. Bitmap bigim(720,480,PixelFormat8bppIndexed) ( I tried 8 instead PixelFormat8bppIndexed) I wanted to assign the values of each pixel using bigim.SetPixel(x,y,integer value between 0 to 255)
1
3697
by: Raju | last post by:
Is there any way to get and set the pixel value in a container control(form, picturebox...)?
2
15053
by: Aravind | last post by:
Hi guys, I want to read the pixel value from an image and to store them in an array.any help regarding this is appriciatable. Thanks in Advance, Aravind
7
3592
by: TomHL | last post by:
hello, - I have a Bitmap Object named: bmp1 - I already have the numerical values of:red,blue and green colors + I have the X and Y cordinates. How do I set the pixel value via safe code on the bmp1 object? (the pixel location based on the X & Y values and it's color based on the red,blue and green values the I already have)
0
1385
by: Daniel Sibarani | last post by:
I'm using Win.2003 Server to store aspnet application that uses Crystal Report as its reporting. Since the website is using Impersonation; <identity impersonate="true" userName="domain\username" password="password"/in web.config, the report image not displayed. I have tried so many ways etc: 1. Configuring IIS's Application Settings turned on. 2. Edit the Machine.config file, changing the "Username" attribute from "machine" to "system"....
10
12083
by: Lucas | last post by:
I want to change some pixel value in the picture file. how to do it? If I read the file in binary mode, a bit == a pixel ? Thanks
1
1733
by: baburk | last post by:
Hi all, I want to set the pixel value 10px from javascript. This style in a file stylesheet.css. Javascript in a file script.js p,h2,h3
3
8789
by: Bernard123456 | last post by:
Hi all, I am new to CImg. I would like to know how to obtain a pixel value on a specific coordinate. Thank in advance to all
8
6089
by: lucindaa | last post by:
For Example I have Table name called "tbl_certificate" Fields as follows id Certificate name 1 Secondary 2 Highersecondary 3 Undergraduate
5
8949
by: jakebruce86 | last post by:
In the CImg library and documentation there are many functions that return "pixel values". I have noticed through experimentation that some pixel values are negative. If I set a pixel to a specific color, is there any way that i can return the exact RGB value of that color? What is a "pixel value" and how is it related to the pixel's actual color?
0
8253
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8692
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8354
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8497
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6116
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5570
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4089
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4192
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2621
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.