Convert int to Color

hi...does anyone know how to convert int value (grabbed from getRGB()) into the actual color format?

hi
use this
Color(int rgb)
Creates an opaque sRGB color with the specified combined RGB value consisting of the red component in bits 16-23, the green component in bits 8-15, and the blue component in bits 0-7.
just for
int      getRGB()
Returns the RGB value representing the color in the default sRGB
regards
Aniruddha

Similar Messages

  • Question on converting #FFFFFF to Color

    Yea, I'm new at this but am having fun!. I have written an applet to replace and applet that I downloaded a few months ago. I need to set the colors of the foreground and background from <PARAM> tags in html. My question is how can I convert #FFFFFF that will be in the param tag to a Color object for setForeground() and setBackgroud()? I'm using a swing Applet.

    Test this little program that convert any hexadecimal color to an RGB color :
    import java.awt.*;
    public class ColorConverter {
         public static void main(String[] args) {
              getColorFromHtml(0xffffff);
              getColorFromHtml(0xff0000);
              getColorFromHtml(0x00ff00);
              getColorFromHtml(0x0000ff);
         public static Color getColorFromHtml(int htmlColor) {
              int red = htmlColor>>16;
              int green = (htmlColor>>8)&0x00ff;
              int blue = htmlColor&0x0000ff;
              System.out.println("red :" +red+" green : "+green+" blue : "+blue);
              return(new Color(red, green, blue));
    }------ unformatted version -----
    import java.awt.*;
    public class ColorConverter {
         public static void main(String[] args) {
              getColorFromHtml(0xffffff);
              getColorFromHtml(0xff0000);
              getColorFromHtml(0x00ff00);
              getColorFromHtml(0x0000ff);
         public static Color getColorFromHtml(int htmlColor) {
              int red = htmlColor>>16;
              int green = (htmlColor>>8)&0x00ff;
              int blue = htmlColor&0x0000ff;
              System.out.println("red :" red" green : "+green+" blue : "+blue);
              return(new Color(red, green, blue));
    Before that you have to convert the string #FFFFFF to an int :
    String s = "#FFFFFF";
    s = s.substring(1);
    int hexColor = Integer.parseInt(s, 16);
    Color rgb = getColorFromHtml(hexColor);
    Denis

  • How can I convert a pages color document to a PDF Black and White doc.

    How can I convert a pages color document to a PDF Black and White doc.  Or, covert the color to B&W in a new doc?

    > How can I convert a pages color document to a PDF Black and White doc.  Or, covert the color to B&W in a new doc?
    The general idea is that you colour correct photographs once, archive, and convert with or without colour changes. The archived photograph is unchanged - or we would be colour correcting the same photographs again and again and again.
    If you have a photograph with a corrected exposure, you can open the photograph in the Apple ColorSync Utility, apply a colour space conversion to a grayscale appearance using the preinstalled ICC profile, save the photograph under another name, and place that in your pagination.
    If you have a paginated document with corrected exposures, and any such non-scalable bitmap or scalable spline graphics as you have chosen to add, you can render the pagination as a whole to PDF through the same ICC profile, carrying out the same colour space conversion on any and all objects.
    Caveat: If you intend the pagination for certain processes, in particular offset lithography, then you are probably  expected not to render the type to grayscale, but rather to render it to single ink solid black. No software can determine what printing process you intend, you have to understand a bit about printing, and how to set up general colour space conversions in software. Ask your prepress provider, and if the answer is not prompt and proficient, pick another provider.
    /hh

  • Converting from indexed color to grayscale no longer works in CS4

    I have a number of files to convert from indexed colors to grayscale. Did some but clicked "don't show me again" box on the Discard Colors warning. Now I can't make the conversion. Everything looks fine, but when I close file, then reopen, it's reverted to indexed colors - restarting Photoshop or the computer doesn't help.
    I'd appreciate any help....Thanks, Grant

    Grant,
    All your contact information is posted to the web. These forums are crawled by bots harvesting info.
    I don't think you want additional junk mail, unsolicited phone call scams, and possible attempts to crack your website, do you?
    People here recommend not to post contact info. Perhaps a forum moderator can remove your personal info, but you might be able to edit your post yourself.
    GIF only uses indexed color mode, So if you want your files to NOT be in the Indexed Color mode you need to save them as another file format like .png or .jpg

  • Convert from spot color to custom CMYK value in Applescript

    I thought this would be very simple and it's not apparently. I am trying to convert a spot color into a custom CMYK value. Basically:
    tell application "Adobe Illustrator"
              set theList to every path item of current document
              repeat with k from 1 to count of theList
                        if fill color of item k of theList = {name:"Dark Green"} then
                                  set fill color of item k of theList to {cyan:0.0, magenta:100.0, yellow:0.0, black:0.0}
                        end if
              end repeat
    end tell
    But this script obviously doesn't work. From what I can tell, the fill color simply returns the tint of the item, not the name of it. I can't find anything that returns the name of a spot color so I can set the correct corresponding color. In the above example, I made the color obviously changed so I could visually see the result.
    Any advice would be greatly appreciated! I'm a first time poster here.
    Thanks!

    tell application "Adobe Illustrator"
              tell current document
                        set theList to every path item
                        set sw to every swatch
                        repeat with i from 1 to count of sw
                                  set swname to name of item i of sw
                                  if swname = "Dark Green" then
                                            set swco to color of item i of sw
                                            repeat with k from (count of theList) to 1 by -1
                                                      set co to fill color of item k of theList
                                                      if swco = co then
                                                                set fill color of item k of theList to {cyan:0.0, magenta:100.0, yellow:0.0, black:0.0}
                                                      end if
                                            end repeat
                                  end if
                        end repeat
              end tell
    end tell

  • CAST Not working for me - Arithmetic overflow error converting int to data type numeric - error

    GPM is DECIMAL(5,2)
    PRICE is DECIMAL(11,4)
    COST is DECIMAL(7,2)
    Trying to update the Gross Profit Margin % field and I keep getting the "Arithmetic overflow error converting int to data type numeric" error.
    UPDATE SMEMODETAIL SET SMD_GPM = (SMD_PRICE-SMD_COST) / SMD_PRICE * 100
    FROM SMEMODETAIL WHERE SMD_PRICE<>0 AND SMD_QUANTITY<>0
    Example record:
    SMD_PRICE    SMD_COST    GPM%
    1.8500            1.62                12.4324324324324300
    I added cast and I still get the error.
    How do I format to get this to work?
    Thanks!

    Hi GBerthume,
    The error is caused by some value such as 1000.01 of the expression (SMD_PRICE-SMD_COST) / SMD_PRICE * 100 exceeds the
    precision of the column(DECIMAL(5,2)). The example data doesn't cause the overflow error for the value of the expression is 12.43 which is in the scope of DECIMAL(5,2).
    USE TestDB
    CREATE TABLE SMEMODETAIL
    SMD_PRICE DECIMAL(11,4),
    SMD_COST DECIMAL(7,2),
    SMD_GPM DECIMAL(5,2)
    INSERT INTO SMEMODETAIL(SMD_PRICE,SMD_COST) SELECT 1.8500,1.62
    UPDATE SMEMODETAIL SET SMD_GPM = (SMD_PRICE-SMD_COST) / SMD_PRICE * 100
    FROM SMEMODETAIL WHERE SMD_PRICE<>0-- AND SMD_QUANTITY<>0
    SELECT * FROM SMEMODETAIL
    DROP TABLE SMEMODETAIL
    The solution of your case can be either scale the DECIMAL(5,2) or follow the suggestion in Scott_morris-ga's to check and fix your data.
    If you have any question, feel free to let me know.
    Eric Zhang
    TechNet Community Support

  • How can i open the "Convert to Indexed Color" dialog with custom presets?

    Hi,
    I need to automatically open the "Convert to Indexed Colors" dialog in Photoshop. Before and after that i have some scripts running so its not possible to open the dialog manually. Also i want to set some custom presets (like number of colors etc.).
    Found something similar to what i want for the Color Range selection (opens the dialog with the presets you put in):
    function colorrange(enabled, withDialog, fuzziness) {
        if (enabled != undefined && !enabled)
          return;
        var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
        var desc1 = new ActionDescriptor();
        desc1.putInteger(app.charIDToTypeID('Fzns'),fuzziness);
        var desc2 = new ActionDescriptor();
        desc2.putDouble(app.charIDToTypeID('Lmnc'), 31.22);
        desc2.putDouble(app.stringIDToTypeID("a"), 0.86);
        desc2.putDouble(app.stringIDToTypeID("b"), 0.31);
        desc1.putObject(app.charIDToTypeID('Mnm '), app.charIDToTypeID('LbCl'), desc2);
        var desc3 = new ActionDescriptor();
        desc3.putDouble(app.charIDToTypeID('Lmnc'), 95.34);
        desc3.putDouble(app.stringIDToTypeID("a"), 54.59);
        desc3.putDouble(app.stringIDToTypeID("b"), 49.85);
        desc1.putObject(app.charIDToTypeID('Mxm '), app.charIDToTypeID('LbCl'), desc3);
        desc1.putInteger(app.stringIDToTypeID("colorModel"), 0);
        var desc4 = new ActionDescriptor();
        var desc4 = executeAction(app.stringIDToTypeID('colorRange'), desc1, dialogMode);
    How can i achieve the same for the indexed color conversion dialog? Apart from doing a lot of guessing regarding the stringIDs.
    Is there some kind of "lookup table" for char and string IDs?
    Thank you guys in advance! This forum has been a great help many times.

    Ok never mind i got it, stupid me.
    Recorded it with Script Listener and changed the "DialogMode" parameter of the executeAction function from "DialogModes.No" to "DialogModes.All".
    var idCnvM = charIDToTypeID( "CnvM" );
                var desc249 = new ActionDescriptor();
                var idT = charIDToTypeID( "T  " );
                    var desc250 = new ActionDescriptor();
                    var idPlt = charIDToTypeID( "Plt " );
                    var idClrP = charIDToTypeID( "ClrP" );
                    var idSele = charIDToTypeID( "Sele" );
                    desc250.putEnumerated( idPlt, idClrP, idSele );
                    var idClrs = charIDToTypeID( "Clrs" );
                    desc250.putInteger( idClrs, 4 );
                    var idFrcC = charIDToTypeID( "FrcC" );
                    var idFrcC = charIDToTypeID( "FrcC" );
                    var idNone = charIDToTypeID( "None" );
                    desc250.putEnumerated( idFrcC, idFrcC, idNone );
                    var idTrns = charIDToTypeID( "Trns" );
                    desc250.putBoolean( idTrns, false );
                    var idDthr = charIDToTypeID( "Dthr" );
                    var idDthr = charIDToTypeID( "Dthr" );
                    var idDfsn = charIDToTypeID( "Dfsn" );
                    desc250.putEnumerated( idDthr, idDthr, idDfsn );
                    var idDthA = charIDToTypeID( "DthA" );
                    desc250.putInteger( idDthA, 75 );
                var idIndC = charIDToTypeID( "IndC" );
                desc249.putObject( idT, idIndC, desc250 );
            executeAction( idCnvM, desc249, DialogModes.ALL ); //Change from NO to ALL

  • Converting to CMYK color profile (for print) in raw format

    I am looking to self publish a cookbook in lightningsource. They need the photos in cmyk format. When is it best to convert to this color profile from rgb?
    I have bridge CS5
    What I'm doing currently:
    I click on my .arw image file and select "open in camera raw" which brings me to an editing screen. At the very bottom is says rgb, and 240 ppi
    I need 300 ppi at least and cmyk color.
    Now I know how to change these things in Photoshop, but I was taught that editing it in camera raw in bridge is better to preserve quality for print.
    Should I just edit it in raw and then convert to 300 dpi and cmyk color in photoshop? Or is there a way to do this in bridge? Whats the difference? Any advice will help, trying to make my pictures look amazing in print

    Correct me if I misunderstood anything!
    You are on the right track except for the ppi story. The ppi settings just are a figure expressing the amount of pixels stored in 1 inch, without the width and height figures of the image itself you can't do much with it and just changing this figure is not changing the total amount of available pixels.
    For instance create a new document at 300 ppi and use the international paper size A4 (21 x 29,7 cm). The amount of pixels is 2480 x 3508 (roughly the result of an 8 MP dSLR.
    Use the image size option in PS and be sure to not resample (meaning creating new pixels or deleting pixels to alter the original file size that is 24,9 MB). Now change the amount of pixels to whatever you like. If you increase the number the width and height decrease, and vice versa. Yet the amount of pixels and file size stay at 2480 x 3508 and 24,9 MB.
    But with the specs of wanted width and height for the end result of 300 ppi starts making sense.
    For instance you have a image at the size of a post stamp and an image at international paper size (A4) and both are 300 ppi. The small post stamp size would be in cm about 2 x 3,5 while the A4 size has about 21 x 30 cm width and height.
    So you can imagine having both needed to be printed at the A4 size in 300 dpi (printers work with dots, hence they use dpi - dots per inch- and while not the same they both often use the 300 figure and stand for pretty high quality result) the A4 sized original will meet the wanted standards without problems   while the post stamp would have to be resampled to the new A4 size and when having still 300 ppi needed there would be a lot of interpolation (creating new pixels to match the new size) and this would often result in pixelated or worse quality print result, because PS has to use guess (albeit quit educated guessing) work to add more pixels that are needed to reach the new dimensions.
    ACR has the advantage to set the ppi by default at 300 but as said, as long as you don't alter width and height of the original it is just a figure without any significant importance until you know the complete specs for the output source.

  • Converting string to color

    I have a String str = "red" . how do i convert this to Color.red .

    Hmm... I see two possibilities..
    1. You make a Hashtable with entries like this:
          hash.put ("red", Color.red);
          hash.put ("blue", Color.blue);
          //etc. etc.2. You take a look what reflect can do.. ;-)
    (java.lang.reflect)
    I'd suggest the thing with the hashtable; it's easier and faster. :)
    CUL8er,
    Nick.

  • Can't convert int to int[]    URGENT!

    HI list!
    Here is the code part I have:
    /** Holds the permutated groups which are arrays of integers. */
    Vector v;
    if(arg.length<3) System.exit (0); //Need at least 3 arguments
    elements=new int[arg.length-1]; //Create array to hold elements
    /* Copy the arguments into the element array. */
    for(i=0;i<arg.length-1;i++) elements=Integer.parseInt(arg[i+1]);
    groupsize=Integer.parseInt(arg[0]); //Get the number in each group.
    calc(groupsize,elements.length); //Find out how many permutations there are.
    v=permutate(groupsize,elements); //Do the permutation
    for(i=0;i<v.size();i++) { //Print out the result
    elements=(int[]) v.get(i);
    System.out.println("");
    for(j=0;j<elements.length;j++) System.out.print(elements
    [j]+" ");
    System.out.println("\nTotal permutations = "+v.size());
    and the error I get is:
    Permutate.java:26: Incompatible type for =. Can't convert int to int[]. for(i=0;i<arg.length-1;i++) elements=Integer.parseInt(arg[i+1]);

    elements=(int[]) v.get(i);
    The above statement is illegal. Its not possible to
    use an array type in casting at all.
    Basically you are trying to do a kind of multiple
    casting, which is not possible.
    You might want to store vectors in vector v instead of
    arrays in vector v. Its better to do this.There's nothing wrong with the line
    elements = (int[]) v.get(i);
    assuming the returned object from the vector is in fact an array of int. Even then, it is a runtime exception condition not a compile-time error.
    Using arrays is perfectly valid where you know the size of the array at creation and do not need to resize it during use... The arrays are fast and compact. This is however not a comment on the approach taken in this case but merely an observation that arrays are not always an inferior choice to one of the collection classes.
    Now put up your dukes... ;)

  • Can't convert int to java.lang.Integer.

    Hi everyone.
    I'm working on an auction site at the moment and have problems gaining a bidID number. This is part of my code and my error.
    AuctionFacade aHse = (AuctionFacade) application.getAttribute("AuctionFacade");
    String strTraderName = (String)session.getAttribute("traderName");
    String strPassword = (String)session.getAttribute("password");
    String strIDNum = request.getParameter("auctionID");
    Integer intID = Integer.valueOf(strIDNum);
    Integer [] bids = aHse.getAllBids(intID);
    float fltYourBid = aHse.getBidPrice(bids.length);
    ^
    Can't convert int to java.lang.Integer.
    can anyone help please?

    So, does "aHse.getBidPrice" expect an int or an Integer as its parameter? And does it return an int, or an Integer, or what? The answer to those questions may lead to your solution -- look at what you are actually using as the parameter, for example.

  • Can't convert int to java.lang.Object

    When I deploy my customer Bean, the following error occures, I think the main problem is Can't convert int to java.lang.Object, does anyone facing the same problem with me?
    <pre>C:\j2sdkee1.3\repository\home\gnrtrTMP\CustomerApp\CustomerBean_RemoteHomeImpl.j
    ava:27: Incompatible type for declaration. Can't convert int to java.lang.Object
    java.lang.Object primaryKey = ejb.ejbCreate(param0, param1, para
    m2);
    ^
    C:\j2sdkee1.3\repository\home\gnrtrTMP\CustomerApp\CustomerBean_RemoteHomeImpl.j
    ava:57: Incompatible type for =. Can't convert int to java.lang.Object.
    primaryKeys = ejb.ejbFindByPrimaryKey( param0);
    ^</pre>
    I really need your help!!!

    you can only convert one object type to another. Integer is an object int isnt. You might want to convert int to Integer and then go ahead.
    see if it works.

  • Can u tell me how to convert int value in to string

    hi to all, can u tell me how to convert int value in to string.

    hi to all, can u tell me how to convert int value in
    to string.Even this way:
    int number = 155;
    String mystring = ""+155;
    [\code]                                                                                                                                                                                                                                                                                               

  • Error message:can't convert int to int[]

    Hi,
    I am trying to build a java code which convert decimal to binary
    but ,I found error message "can not convert int to int[]"
    some line of code:
    int i=12,n=0;
    int arr[n]=i%2;
    n++;
    here I am trying to store remainder in an integer arrary.
    how can i do this???????
    guide me please
    -shobhit singh

    shobhit_onprob wrote:
    i want to store some integer values in to an integer arraryDid you follow the address that was given to you? I doubt it, and even if you did, 2 minutes is not enough time to read, let alone understand, the tutorial.
    Go back there, it describes all the basics you need.

  • Converting a true color bufferedImage to a 256color?

    Hi,
    Does anyone know how to convert a true color bufferedImage to a 256 color?
    Any help would be appreciated. Thank you

    The simplest way is to choose an arbitrary lookup table then map each rgb pixel to its nearst value in the table. If the table is good for your type of image then the results can be reasonable.
    A differnt way is just to drop the insignificant bits from each of r, g and b then
    combine the reduced r,g and b into a single byte.
    A better way is to compute a lookup table that is optimal for you image (for various definitions of "optimal"). Below are references for three different approachs to do this (taken from the JAI documentation of ColorQuantizeDescriptor). Once you have the optimised lookup table you
    can find the nearest colour in it for each pixel (as in the first approach).
    Median-Cut      Color Image Quantization for Frame Buffer Display, Paul Heckbert, SIGGRAPH proceedings, 1982, pp. 297-307
    NeuQuant      Kohonen Neural Networks for Optimal Colour Quantization, Anthony Dekker, In Network: Computation in Neural Systems, Volume 5, Institute of Physics Publishing, 1994, pp 351-367.
    Oct-Tree      Interactive Computer Graphics: Functional, Procedural, and Device-Level Methods by Peter Burger and Duncan Gillis, Addison-Wesley, 1989, pp 345.
    Cheers
    matfud

Maybe you are looking for

  • How do i get the itunes 11.1.4 onto a windows 7 machine

    I've hit a dead end with the 193 error.  I've done multiple disc scans. downloaded microsoft patches but the new itunes will not load.  I got an error about mobile device so i removed all apple mobile device files and still can't load itunes.  Ive re

  • Calling FI validation at the time of PR PO creation

    Hi, In the Standard SAP system, FI validation is not called at the time of creation Purchase Requisition or Purchase Order since no FI document is created. We had a requirement to call a FI valdation e.g GL account can only be posted to a certain cos

  • Reg:IDOC Sender side settings

    Dear All, My scenario is IDOCPIMDM I have created all the basic ALE settings and they are, SAP R/3: 1)RFC Destination (SM59) 2)Logical system 2)Port (We21) 3)Partner Profile (WE20) name same as logical system SAP XI: 1) RFC Destination (SM59) 2) Crea

  • How to Print the Account Balance in Outgoing Payment PLD

    Hello Experts How to Print the Account Balance in Outgoing Payment PLD Dixit Patel

  • Log specific http header

    Hi, We have a "RedLine Networks T | X 2600 Real Time Accelerator", between the Clients and our frontends. As expected the IP that gets logged in the frontends is the "T|X 2600" IP, and not the client ip. In the request from the "T|X 2600" we have an