Programatically get color from CSS

How do I get a given color used in css (preferably in hex),
for example, the color of the text in textinputs, from CSS?

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"
layout="absolute" creationComplete="onComplete()">
<mx:Style>
TextInput{
color: #FF0031;
</mx:Style>
<mx:Script>
<![CDATA[
import mx.controls.Alert;
private function onComplete():void{
var styleForTextInput:CSSStyleDeclaration =
StyleManager.getStyleDeclaration("TextInput");
var nn:Number = styleForTextInput.getStyle("color");
var inHex:String = "#" + nn.toString(16);
Alert.show("inHex:" + inHex);
]]>
</mx:Script>
</mx:Application>

Similar Messages

  • Get color from image

    Hey people, I'm new to Illustrator and have a question. I want to use a color from an image that I put into Illustrator.
    The exact things I did with the image are the following: copied it from Windows Photo Viewer into Illustrator, then put the 'cut out' effect on it, then copied it into a new Illustrator document that has a businesscard template and resized it fit the template's margins. Now I want to kind of 'enlengthen' the image by putting a square next to it. To make it look smooth, it has to have the same color as that side of the image of course. But that's my problem, I'm not able to select the color from the image and make a new color group with that specific color. The 'get color from selected artwork' button doensn't help much since I can't click it, for some reason the mouse turns into this 'can't click here' icon every time I move it on this button.
    Any help would be greatly appreciated!
    PS apologies for any unavoidable noobness

    To sample a color from a raster image, ShiftClick with the Eyedropper tool. (CS3)
    Always state what software version you are using.
    JET

  • Get colors from image

    Is there any way to get the colors from an image in photoshop? Ideally, I would like a simple process to get a swatch collection from an existing image.
    Thanks,
    CFH

    I don't know if this is the easiest way, but, change Mode to Indexed. Go to Mode>Color Table and Save the table with a new name. Then you should be able to load it in the Swatches palette from the flyout. Choose .act in the dropdown.

  • Get color from paintPanel()

    I need a way to get the Color from a paint panel when the user clicks the mouse. I already have the mouse listener set up to return the co-ordinates within the paint panel.
    Could you suggest a class and method I could use, to get the color value from the paint panel.
    here's some of the code, so you know what i'm taking about
         public void mouseClicked (MouseEvent e)
                   System.out.println("the co-ordinates are "+ e.getX()+" "+e.getY());
              }

    There is no Image object there is only a paintPanel object.
    Doesn't seem to be a constructor for an image object in the Image Class.
    There must be an easier way of getting the pixel color for any given co-ordinates within the paintPanel object.

  • How do I transfer a color from one object to another without losing the gradient?

    COLORING AN OBJECT AND SAVING THE GRADIENT
    These are my notes.
    x
    Choose the EYEDROPPER tool.
    x
    Sample the color you want from an object in your image.
    x
    Double-click on the fill icon at the bottom of the tool panel.
    This brings up the COLOR PICKER panel.
    In that panel, you'll find the numeric value of the color you sampled.
    I followed these instructions but when the COLOR PICKER panel came up, it didn't show the color it was suppose to show.  The color I sampled with the eyedropper was a light blue with a gradient.  I had a few different files up with the same image.  One file brought up the color orange in the Color Picker panel.  And another file brought up a total BLACK, with a numeric value of 0000!  Can anyone tell me what's happening? 

    My guess is the eyedropper tool is struggling.  The best way and the one I use is to get color readings in Photoshop using its eyedropper tool.  Write down the color percentages for each color you want from the image.  Then, in Illustrator, I use the color palette to create new swatches using the percentage I wrote down from the actual image file.  Those new swatches can be used ( or transferred to ) in the gradient palette.  I have never used the eyedropper tool for getting color from anywhere in Illustrator.  But, that's just me.

  • [CS2/CS3] - Getting color of stroke

    I'm parsing graphical objects (rectangles, ...) and I want to be able to get color of stroke(fill color),
    I use this code:  
    Utils()->GetFillRenderingUID(sourceFillRenderingUID, sourceGraphicStyleDescriptor);  
    to get sourceFillRenderingUID and now I use:  
    PMString sourceStrokeColor = Utils()->GetSwatchName(sourceSplineRef.GetDataBase(), sourceStrokeRenderingUID); 
    but this method returns me name of color only in case of base color (Black,...),
    please how to get color CMYK or something similar to be able to compare 2 colors ?  Thx, marxin

    I found out, that if I create a graphic object with defined swatc (f.e. C=100, M=0, Y=0, K=50), my code:<br/>
    Utils<IGraphicAttributeUtils>()->GetStrokeRenderingUID(sourceStrokeRenderingUID, sourceGraphicStyleDescriptor);
    PMString sourceStrokeColor = Utils<ISwatchUtils>()->GetSwatchName(sourceSplineRef.GetDataBase(), sourceStrokeRenderingUID);
    my code correctlly gets "C=100, M=0, Y=0, K=50" as a name of strokeColor. But If I create user defined solid color (which is not a swatch profile), my code gets "" as a Name. I read in guide that solid color f.e. will create a local swatch profile, but I am not able to get the color from UID.
    Please could anyone help me how to get color from stroke and local swatch ?
    Thx, marxin

  • I cannot get my HP 6600 to print in color from my new macbook pro.

    Does anyone know how to help me get my Macbook Pro to print to my HP Officejet 6600 in color?  I am new to MAC computers and am sure it's just a setting I need to change.  I know it is not a printer problem as it prints color from the same webpage from my PC desktop.  Thanks.

    bamajim,
    Here is a link to a page for your printer that may help with your issue.
    The document provides steps to troubleshoot printouts that do not match the screen while printing from the web.
    Does this also happen when printing graphics from somewhere other than the web ?
    Once you give these steps a try let us know what happens.
    If I helped you at all it would be great if you clicked the blue kudos star!
    If I solved your post please mark it as solved to help others.
    I'm a printer tech with HP.

  • Trouble with slow Macbook Air. I have first generation MacBook Air and have a hard time keeping hard drive from being full. Right now, I have almost 5 gigs available, but mac is slow and I keep getting color wheel when I use Mail. Any suggestions?

    Trouble with slow Macbook Air. I have first generation MacBook Air and have a hard time keeping hard drive from being full. After trashing many docs, I have almost 5 gigs available, but mac is slow and I keep getting color wheel when I use Mail. I'd like to install Lion, but now I'm afraid it will slow down my machine even further. Do I have enough free hard disc space? Is Mail problem related to free hard disc space? Thanks for your help!

    7gb of free disc space is required to install Lion.  Read this about how to free up disc space: http://pondini.org/OSX/DiskSpace.html.  Also, advice on how to speed up your mac: http://www.maclife.com/article/feature/25_ways_speed_your_mac

  • How to get the default selection color from JTable

    Hi, there,
    I have a question for how to get the default selection color from JTable. I am currently implementing the customized table cell renderer, but I do want to set the selection color in the table exactly the same of default table cell renderer. The JTable.getSelectionBackgroup() did not works for me, it returned dark blue which made the text in the table unreadable. Anyone know how to get the window's default selection color?
    Thanks,
    -Jenny

    The windows default selection color is dark blue. Try selecting any text on this page. The difference is that the text gets changed to a white font so you can actually see the text.
    If you don't like the default colors that Java uses then use the UIManager to change the defaults. The following program shows all the properties controlled by the UIManager:
    http://www.discoverteenergy.com/files/ShowUIDefaults.java
    Any of the properties can be changed for the entire application by using:
    UIManager.put( "propertyName", value );

  • Set textRollover color for Text control from css (very urgent)

    Hi,
           I have text control . I need to set textRollovercolor for the text control from css. Is it possible.
    regards,
    Jayagopal.

    Jayagopal
    We can set the text roll over color using css like shown below.
    .txtColor{
        text-selected-color:         #000000;
        text-roll-over-color:         #FF0000;
    Thanks
    Raghu

  • Please Help Get a Color from Pixel !!!!

    Is anybody know how to get a Color from pixel.
    My program is not Full Screen .
    So i think Robot.getPixelColor() don't suitable.
    Please Help me!

    Robot.getPixelColor() will work fine, but the problem you will have is getting the mouse set to the correct location and getting your application to know where it is: you can do it with win32 calls and JNI. Here are a few that I have found helpful--they are in a VB format:
    Public Const CLR_INVALID = &HFFFF 'not a valid pixel
    Public Const MOUSE_MOVED = &H1
    Public Const MOUSEEVENTF_ABSOLUTE = &H8000 ' absolute move
    Public Const MOUSEEVENTF_LEFTDOWN = &H2 ' left button down
    Public Const MOUSEEVENTF_LEFTUP = &H4 ' left button up
    Public Const MOUSEEVENTF_RIGHTDOWN = &H8 ' right button down
    Public Const MOUSEEVENTF_RIGHTUP = &H10 ' right button up
    Public Const REQUEST_LEFT_CLICK = &H2D 'request left click "-"
    Public Const REQUEST_RIGHT_CLICK = &H2B 'request right click "+"
    Type POINTAPI
    x As Long
    y As Long
    End Type
    Type POINTSTRUCT
    hwnd As Long
    hdc As Long
    ptAbsolute As POINTAPI
    ptOrigin As POINTAPI
    ptLocal As POINTAPI
    ptColor As Long
    sType As String
    retMessage As Boolean
    End Type
    Declare Function GetCursorPos _
    Lib "user32" (ByRef lpPoint As POINTAPI) _
    As Long
    Declare Function SetCursorPos _
    Lib "user32" (ByVal x As Long, ByVal y As Long) _
    As Long
    Declare Sub mouse_event _
    Lib "user32" (ByVal dwFlags As Long, _
    ByVal dx As Long, _
    ByVal dy As Long, _
    ByVal cButtons As Long, _
    ByVal dwExtraInfo As Long)
    Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
    Declare Function GetMessageExtraInfo Lib "user32" () As Long
    Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, _
    ByVal x As Long, _
    ByVal y As Long) As Long
    Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, _
    ByVal yPoint As Long) As Long
    Declare Function GetWindowDC Lib "user32" (ByVal hwnd As Long) As Long
    Declare Function GetWindowOrgEx Lib "gdi32" (ByVal hdc As Long, _
    ByRef lpPoint As POINTAPI) As Long

  • TS5185 Hi After I have report a junk message I coudl not get Imessge from other iphone. and could not send any message in blue color but green which need to pay for.

    Hi After I have report a junk message to 7726, I coudl not get Imessge from other iphones. and could not send any message in blue color but green which need to pay for. Does Apple blocked my imessage ? I have checked the setting. imessage is on.
    Thanks,
    J

    Make sure that your date and time settings and time zone are accurate (Settings - General - Date and Time). Reset your phone to 'Set Automatically' and then try signing in again - this worked for me.  My date/time settings were not automatic (candy crush cheats!!).

  • How to get color group from illustrator into flash

    Hi,
    I have difficulties with the color management between Illustrator and Flash.
    I have the original vector files in Illustrator and would like to use the color groups, I have in Illustrator, also in Flash.
    One way doing it is using the Kuler.
    But I can not get the colors from Illustrator into Kuler.
    Can someone advice how to manage that process?
    Many thanks in advance!

    I'm fairly new to this having only recently started using these tools again after six years, but will try to help! Go to "Explore", find a theme you like and click the "Edit" selection when you mouse over it. From there you can edit it or save a copy of it as is as whatever name you wish. In Photoshop or Illustrator, they will now show up in Adobe Color Themes (Window > Extensions > Adobe Color Themes) under "All Themes" in the drop menu. In these apps (and others that are Adobe Color Theme aware), any themes that you favorite on the site will show up under "My Favorites".
    If you're using Fireworks, it's different as it still uses Kuler (Window > Extensions > Kuler).  Themes you save or favorite on the site don't automatically show up there, however you can search for themes by name, and if you select "Custom" from the theme group dropdown, you can enter up to four names that will show up in that dropdown menu and produce as many results as the window can hold for an individual term. For instance, I saved a theme as "Copy of Industrial Calm" which if I enter in the search box, the "group" is a group of one. However, if I just type "Industrial", the window fills with options, yet there are MANY more results on the Adobe Color site and you would have to be specific to get the right one in that window.
    Hope that helps.

  • Getting the background color from a row

    I'm displaying a table that has alternating row colors for odd and even... when I click on a row I am changing the color to blue. When I click on a different row I want to set the background color back to what it was for the originally selected row and change the currently selected row to blue. This worked just fine when I had the colors hard coded into the code... but as soon as I started using style sheets it stoped working,
    My questions is how do I get the background color from a row... for instance, the following alert dislays nothing. How can I get the actual color out for the row?
    var tableElem = document.getElementById('table');
    var rowElem;
    rowElem = tableElem.rows[0];
    alert(rowElem.bgColor);
              

    If you're working with style sheets, then ignore the background color. You don't want to care what color is actully being used, only that the correct style is in place.
    Worry instead about the className property for your row:<style>
    .highlightRow {
       color: white;
       background-color: gray;
    .normalRow {
       color: black;
       background-color: white;
    </style>
    var tableElem = document.getElementById("table");
    var rowElem = tableElem.rows[0];
    alert(rowElem.className);
    <table id="table">
    <tr class="normalRow"><td>...</td></tr>
    <tr class="highlightRow"><td>...</td></tr>
    </table>

  • How to get max 5 color from image??

    I try to get max 5 color from image (ex. jpeg,gif) ,I use PixelGrabber
    it too slowly when i use large image,Please help me, to run more fast
    (other way PixelGrabber)
    best regard
    [email protected],[email protected]
    source below:
    public String generateColor(InputStream source,String filePath){
    BufferedImage image = null;
    String RGB = "";
    System.out.println("==generateColor==");
    try {
    image = ImageIO.read(source);
    catch (IOException ex1) {
    ex1.printStackTrace();
    //image.getGraphics().getColor().get
    // BufferedImage image2 = ImageIO.read(source);
    // image.getColorModel().getNumColorComponents()
    if(image.getColorModel() instanceof IndexColorModel) {
    IndexColorModel icm = (IndexColorModel)image.getColorModel();
    byte[][] data = new byte[3][icm.getMapSize()];
    int[] rgbB = new int[icm.getMapSize()];
    icm.getRGBs(rgbB);
    String dataHtm = "<HTML><table width=\"100\" border=\"0\"><tr>";
    for(int i = 0 ;i< rgbB.length;i++){
    int r = (rgbB[i] >> 16) & 0xff;
    int g = (rgbB[i] >> 8) & 0xff;
    int k = (rgbB) & 0xff;
    System.out.println("red:" + Integer.toHexString(r));
    System.out.println("green:" + Integer.toHexString(g));
    System.out.println("blue:" + Integer.toHexString(k));
    dataHtm = dataHtm + "<td width=\"10\" bgcolor=\"#" + Integer.toHexString(r)+Integer.toHexString(g)+Integer.toHexString(k);
    dataHtm = dataHtm + "\"> </td>";
    dataHtm = dataHtm + "</tr></table></HTML>";
    try {
    BufferedWriter out = new BufferedWriter(new FileWriter("c:\\23289207.html"));
    out.write(dataHtm);
    out.close();
    catch (IOException e) {
    e.printStackTrace();
    int w = image.getWidth();
    int h = image.getHeight();
    int[] pixels = new int[w*h];
    int[] pixs = new int[w*h];
    System.out.println("image width:"+w+"image hight:"+h+"image w*h:"+(w*h));
    Image img = Toolkit.getDefaultToolkit().getImage(filePath);
    PixelGrabber pg = new PixelGrabber(img, 0,0, w, h, pixels, 0, w);
    try {
    pg.grabPixels();
    catch (Exception x) {
    x.printStackTrace();
    String picColor = "";
    Stack stackColor = new Stack();
    Hashtable hashColor = new Hashtable();
    for (int i = 0; i < w * h; i++) {
    int rgb = pixels[i];
    int a = (rgb >> 24) & 0xff;
    int r = (rgb >> 16) & 0xff;
    int g = (rgb >> 8) & 0xff;
    int k = (rgb) & 0xff;
    i = i+1000;
    //System.out.println("i:" + i);
    picColor = convertToSring(r)+convertToSring(g)+convertToSring(k);
    stackColor.add(picColor);
    //System.out.println("picColor:"+picColor);
    // System.out.println("\n\n a:" + a);
    // System.out.println("red:" + r);
    // System.out.println("green:" + g);
    // System.out.println("blue:" + k);
    }//end for
    getMaxColor(stackColor);
    System.out.println("==generateColor==end\n\n");
    return null;

    import java.awt.Color;
    import java.awt.image.BufferedImage;
    import java.io.IOException;
    import java.net.URL;
    import javax.imageio.ImageIO;
    public class HighFive
        private void examineColors(BufferedImage image)
            long start = System.currentTimeMillis();
            int w = image.getWidth(), h = image.getHeight();
            int[] rgbs = image.getRGB(0,0,w,h,null,0,w);
            findHighFive(rgbs);
            long end = System.currentTimeMillis();
            System.out.println("total time = " + (end - start)/1000.0 + " seconds");
        private void findHighFive(int[] colors)
            int[] uniqueColors = getUniqueColors(colors);
            int[] colorCounts  = getColorCounts(uniqueColors, colors);
            int[] highFive     = getHighFive(colorCounts);
            // for each value of highFive find index in colorCounts
            // and use this index to find color code in uniqueColors
            for(int j = 0; j < highFive.length; j++)
                int index = findIndexInArray(colorCounts, highFive[j]);
                Color color = new Color(uniqueColors[index]);
                String s = color.toString();
                s = s.substring(s.indexOf("["));
                System.out.println("color " + s + "  occurs " +
                                    highFive[j] + " times");
        private int[] getUniqueColors(int[] colors)
            // collect unique colors
            int[] uniqueColors = new int[colors.length];
            int count = 0;
            for(int j = 0; j < colors.length; j++)
                if(isUnique(uniqueColors, colors[j]))
                    uniqueColors[count++] = colors[j];
            // trim uniqueColors
            int[] temp = new int[count];
            System.arraycopy(uniqueColors, 0, temp, 0, count);
            uniqueColors = temp;
            return uniqueColors;
        private int[] getColorCounts(int[] uniqueColors, int[] colors)
            // count the occurance of each unique color in colors
            int[] colorCounts = new int[uniqueColors.length];
            for(int j = 0; j < colors.length; j++)
                int index = findIndexInArray(uniqueColors, colors[j]);
                colorCounts[index]++;
            return colorCounts;
        private int[] getHighFive(int[] colorCounts)
            // find five highest values in colorCounts
            int[] highFive = new int[5];
            int count = 0;
            for(int j = 0; j < highFive.length; j++)
                int max = Integer.MIN_VALUE;
                for(int k = 0; k < colorCounts.length; k++)
                    if(colorCounts[k] > max)
                        if(isUnique(highFive, colorCounts[k]))
                            max = colorCounts[k];
                            highFive[count] = colorCounts[k];
                count++;
            return highFive;
        private boolean isUnique(int[] n, int target)
            for(int j = 0; j < n.length; j++)
                if(n[j] == target)
                    return false;
            return true;
        private int findIndexInArray(int[] n, int target)
            for(int j = 0; j < n.length; j++)
                if(n[j] == target)
                    return j;
            return -1;
        public static void main(String[] args) throws IOException
            String path = "images/cougar.jpg";
            Object o = HighFive.class.getResource(path);
            BufferedImage image = ImageIO.read(((URL)o).openStream());
            new HighFive().examineColors(image);
    }

Maybe you are looking for