473,756 Members | 5,156 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Got stuck using the BufferedImage getRGB(x,y) method

10 New Member
I want to get the R, G and B components as integers (0-255). I use this:
Expand|Select|Wrap|Line Numbers
  1. Rectangle area = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
  2. BufferedImage bufferedImage = r.createScreenCapture(area);
  3. int pixel = bufferedImage.getRGB(x,y);
  4.  
But it returns some crazy 1 value of -65536 or something like that. How do I convert it to three individual integers R,G and B?
Apr 2 '07 #1
1 7081
JosAH
11,448 Recognized Expert MVP
I want to get the R, G and B components as integers (0-255). I use this:
Expand|Select|Wrap|Line Numbers
  1. Rectangle area = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
  2. BufferedImage bufferedImage = r.createScreenCapture(area);
  3. int pixel = bufferedImage.getRGB(x,y);
  4.  
But it returns some crazy 1 value of -65536 or something like that. How do I convert it to three individual integers R,G and B?
That 'crazy' value represents the colour of the pixel as four bytes: alpha, red,
green and blue; the alpha factor is the transparency of the colour. You can
fiddle with the bytes in the int yourself to get the individual colour components
but you can also let the Color class do the work. You can instantiate a new
Color object given that int value. The Color object has applicable methods you
can use: getAlpha(), getRed(), getGreen() and getBlue().

kind regards,

Jos
Apr 3 '07 #2

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

Similar topics

31
2936
by: Chris S. | last post by:
Is there a purpose for using trailing and leading double underscores for built-in method names? My impression was that underscores are supposed to imply some sort of pseudo-privatization, but would using myclass.len() instead of myclass.__len__() really cause Python considerable harm? As much as I adore Python, I have to admit, I find this to be one of the language's most "unPythonic" features and a key arguing point against Python. I've...
7
20929
by: Rui Pestana | last post by:
Hello all, I want to use the POST method to submit the form and then grab the parameters in the asp file with request.form("parm"). The problem is that I am using the _search target to open the asp page. When I use _blank target there is no problem, either I use GET or POST method. But when I use _search target, only GET method works.
15
3130
by: Thomas Scheiderich | last post by:
I am trying to understand Session variables and ran into a question on how they work with data that is passed. I have an HTM file that calls an ASP file and sends the name either by GET or POST. When I find is that if I send the value by the GET method, response.write("From QueryString: " & Request.QueryString("usernamefromform") & "<br><br>")
7
23656
by: Matt | last post by:
In ASP, when we pass data between pages, we usually pass by query string. If we pass data by query string, that means we need to use submit button, not by regular button, and the form will pass to the server since it's GET or POST request. But if just form-to-form communication, why we need to send the form to the server? Please help clarify. Thanks!! <form action="process.asp" method="get"> //form controls <input type="submit">
6
538
by: harrylmh | last post by:
Hi, I'm learning C# and I just don't quite understand the need for polymorphism. why do we need to use it? how does a base class variable holding a derived class instance do any good? Also, what's the difference between method hiding and overriding when they're both still overriding the base method. Thanks
3
2534
by: Paul Aspinall | last post by:
Hi I want to package my C# winforms app, to be deployed with MSDE, as easily as possible for the end user. I want to create an MSI or Installshield (prefer MSI), to setup my C# app, together with MSDE (if not already installed), and the MSDE application DB. How can I detect if MSDE is already installed?? Has anyone does this?? How??
1
2881
by: Pankaj | last post by:
Hello friends, I am implementing something like PM |------------------------------------------------------ | | | | | ------- -| send_if( data) | | | M | | | | | |
1
1568
by: gspk | last post by:
Hi, I have a input file in the following format , 1-4 5-8 9-10 11 12-14 ------------------------------------ 1000 +500 25 1 250 2000 -520 55 1 25 2500 *525 55 1 125
4
2631
by: Andrew Poulos | last post by:
I'm trying to use the String method parseJSON (that is created in the javascript of a frameset) in one of the frames but I don't know how to correctly reference it. This: notes = str.parseJSON(); doesn't seem to work - I get the error "str.parseJSON is not a function". And this: notes = str.parent.parseJSON();
3
1406
by: Navdip | last post by:
i want to create a DHTML page in which i want to create a Table using method in JSCRIPT in which i'll pass the number of rows and coloumns as arguments of method. and table should get created when i call the method please give me code if u can.....
0
9462
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
9722
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...
0
8723
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7259
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
6542
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
5155
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
5318
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3817
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
3
2677
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.