Took me a while to come up with this (even though it looks simple) it
will convert a BGR color int (or long) like used in VB to a java Color
(java.awt.Color )
examples of this are:
colornum = 16777215; //pure white
colornum = 255; //pure red
colornum = 65280; //pure green
colornum = 16711680; //pure blue
public Color BGRColorToJavaC olor(int BGRColorNumber) {
//color codes as a ing in form "BGR"
return new Color((float)(B GRColorNumber & 0xFF),
(float)((BGRCol orNumber >> 8) & 0xFF),
(float)((BGRCol orNumber >> 16) & 0xFF));
}
Just putting this here to help people. my google groups search didn't
come up with anything like it, so i'm just trying to change that.
comments to my email please ;)
-Drew 5 14538
I don't understand the reason you convert to float.
You are doing bit operations that assume you have integers,
so why not use the "Color(int r, int g, int b)" constructor?
"Andrew Arace" <an**********@h otmail.com> wrote in message
news:11******** *************** ***@posting.goo gle.com... Took me a while to come up with this (even though it looks simple) it will convert a BGR color int (or long) like used in VB to a java Color (java.awt.Color )
examples of this are: colornum = 16777215; //pure white colornum = 255; //pure red colornum = 65280; //pure green colornum = 16711680; //pure blue
public Color BGRColorToJavaC olor(int BGRColorNumber) { //color codes as a ing in form "BGR" return new Color((float)(B GRColorNumber & 0xFF), (float)((BGRCol orNumber >> 8) & 0xFF), (float)((BGRCol orNumber >> 16) & 0xFF)); }
Just putting this here to help people. my google groups search didn't come up with anything like it, so i'm just trying to change that.
comments to my email please ;)
-Drew an**********@ho tmail.com (Andrew Arace) wrote in message news:<11******* *************** ****@posting.go ogle.com>... Took me a while to come up with this (even though it looks simple) it will convert a BGR color int (or long) like used in VB to a java Color (java.awt.Color )
examples of this are: colornum = 16777215; //pure white colornum = 255; //pure red colornum = 65280; //pure green colornum = 16711680; //pure blue
public Color BGRColorToJavaC olor(int BGRColorNumber) { //color codes as a ing in form "BGR" return new Color((float)(B GRColorNumber & 0xFF), (float)((BGRCol orNumber >> 8) & 0xFF), (float)((BGRCol orNumber >> 16) & 0xFF)); }
Just putting this here to help people. my google groups search didn't come up with anything like it, so i'm just trying to change that.
comments to my email please ;)
-Drew
SORRY SORRY, messed that post up: turns out my 'tests' i did were on
black, and it worked fine...need to get rid of that (float) casting
public Color BGRColorToJavaC olor(int BGRColorNumber) {
//color codes as a int in form "BGR"
return new Color((BGRColor Number & 0xFF),
((BGRColorNumbe r >> 8) & 0xFF),
((BGRColorNumbe r >> 16) & 0xFF));
}
That's right now. Really sorry about that, I felt like an idiot after
i posted it, and 5 seconds later realized I had posted the wrong code.
-Andrew an**********@ho tmail.com (Andrew Arace) wrote in message news:<11******* *************** ****@posting.go ogle.com>... an**********@ho tmail.com (Andrew Arace) wrote in message news:<11******* *************** ****@posting.go ogle.com>... Took me a while to come up with this (even though it looks simple) it will convert a BGR color int (or long) like used in VB to a java Color (java.awt.Color )
examples of this are: colornum = 16777215; //pure white colornum = 255; //pure red colornum = 65280; //pure green colornum = 16711680; //pure blue
Isn't there already a Color constructor that does this?
Color red = new Color(255); // looks red to me
Color blue = new Color(16711680) ; // looks blue too sg******@occ.cc cd.edu (Stephen Gilbert) wrote in message news:<56******* *************** ***@posting.goo gle.com>... an**********@ho tmail.com (Andrew Arace) wrote in message news:<11******* *************** ****@posting.go ogle.com>... an**********@ho tmail.com (Andrew Arace) wrote in message news:<11******* *************** ****@posting.go ogle.com>... Took me a while to come up with this (even though it looks simple) it will convert a BGR color int (or long) like used in VB to a java Color (java.awt.Color )
examples of this are: colornum = 16777215; //pure white colornum = 255; //pure red colornum = 65280; //pure green colornum = 16711680; //pure blue
Isn't there already a Color constructor that does this? Color red = new Color(255); // looks red to me Color blue = new Color(16711680) ; // looks blue too
hmm...i don't think so. i'll check out your examples there, but the
Color(int) constructor says "int rgb" where the color i am passing in,
the way VB represents it, its BGR (reversed endian)
....i hope i didn't spend that time for nothing. an**********@ho tmail.com (Andrew Arace) wrote in message news:<11******* *************** ****@posting.go ogle.com>... hmm...i don't think so. i'll check out your examples there, but the Color(int) constructor says "int rgb" where the color i am passing in, the way VB represents it, its BGR (reversed endian) ...i hope i didn't spend that time for nothing.
You're right. I wrote a test program and looked at it, but
forgot which part I'd made red and blue. The good news is
that your time wasn't wasted. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Michael |
last post by:
Hello
I am trying to write a Java-Program which converts a XML-file in a HTML.
It should take the Transformation-file from the XML-file itself.
Below find a possible XML-file:
<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XMLSPY v5 rel. 3 U (http://www.xmlspy.com) by Michael
Herren (private) -->
|
by: Ravi Tallury |
last post by:
Hi
We are having issues with our application, certain portions of it stop
responding while the rest of the application is fine. I am attaching
the Java Core dump. If someone can let me know what the issue is.
Thanks
Ravi
|
by: ptaz |
last post by:
Hi I'm trying to run a web page but I get the following error. Ca
anyone please tell me a solution to this.
Thanks
Ptaz
HTTP Status 500 -
type Exception report
|
by: Markus Wollny |
last post by:
Hello!
When I try to run ./configure --with-java, it complains that ant doesn't
work. However ant is installed, as is the latest Java SDK 1.4.2 from
sun, PATH and JAVA_HOME are set correctly;
helles:/ # /usr/java/apache-ant-1.5.4/bin/ant -version
Apache Ant version 1.5.4 compiled on August 12 2003
It complains about some unsupported class-version; does it require an
|
by: mailkhurana |
last post by:
Hii ,
I am trying to use a type 2 driver to connect to DB2 0n AIX 5
I have a small java test to class to establish a conneciton with the db
.. I am NOT using WAS or any appserver
When I try to connect to the DB I get the following exception
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:2120)
| |
by: TZESENG |
last post by:
DECEMBER 13, 2005 . Editions: N. America | Europe | Asia | Edition
Preference
News Analysis
By Steve Hamm
Source:
http://www.businessweek.com/technology/content/dec2005/tc20051213_042973.htm
Peter Yared, CEO of software maker ActiveGrid, spent a critical chapter of
his career steeped in Java, the programming language developed by Sun
Microsystems (SUNW). In the late 1990s, Yared was chief technology officer
|
by: Mark Fink |
last post by:
I wrote a Jython class that inherits from a Java class and (thats the
plan) overrides one method. Everything should stay the same.
If I run this nothing happens whereas if I run the Java class it says:
usage: java fit.FitServer host port socketTicket
-v verbose
I think this is because I do not understand the jython mechanism for
inheritance (yet).
|
by: jaywak |
last post by:
Just tried running some code on Linux (2.4.21-32.0.1.EL and Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_04-b05)) and Windows XPSP2 (with Java HotSpot(TM) Client VM (build 1.5.0_11-b03, mixed mode, sharing)) and in both cases, get the following list returned from calling getDeclaredFields() on java.lang.ClassLoader via this code snippet:
Field fields = loaderClass.getDeclaredFields();
for (int i = 0; i <...
|
by: r035198x |
last post by:
Setting up.
Getting started
To get started with java, one must download and install a version of Sun's JDK (Java Development Kit).
The newest release at the time of writting this article is JDK 6 downloadable from
http://java.sun.com/javase/downloads/index.jsp.
I will be using JDK 5(update 8)
|
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...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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,...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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
| |