473,418 Members | 1,933 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,418 software developers and data experts.

get pixel value of image which is already displayed

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 3285
jkmyoung
2,057 Expert 2GB
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
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...
1
by: Raju | last post by:
Is there any way to get and set the pixel value in a container control(form, picturebox...)?
2
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
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...
0
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"...
10
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
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
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
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
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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
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,...
0
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
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
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,...
0
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...

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.