Setting the color of individual pixels in a bufferedimage

i am trying to set the color of each pixel in a loop as follows:-
BufferedImage bi=new BufferedImage(w,h,BufferedImage.TYPE-INT_RGB);
for(int j=0;j<h;j++){
for(int i=0;i<w;i++){
pixel=translate(i,j);
clr=findcolor(pixel);
if(clr==-1){
bi.setRGB(i,j,0);
else
bi.setRGB(i,j,clr);
findcolor() function just returns an int, so how do take this integer value and set the appropriate color?
when i execute this code,in the PaintComponent method of a JPanel class, my entire panel becomes black, this is not because of my first "if" condition.i checked the return value of my findcolor function.
However if i multiply the color value by a large number like 10000, then i get a few colors only(black,blue, green)
So please let me know how i can get all colors, without having to multiply the value.

What do the translate and findcolor methods do?

Similar Messages

  • Dynamically setting the color of the title in a Panel

    Hello, I know I can set the color & font of the title in a Panel using the titleStyleName in a stylesheet.  How can I dynamically change the color though?  I have a component:
             <mx:Panel id="myPanel"borderColor="{this.color1}" />
    where this.color1 is a value that changes dynamically, and thus changes the border color.  How do I do this for the color of the text in the title?

    Hi,
    Try this
    var css:CSSStyleDeclaration = StyleManager.getStyleDeclaration(".myPanelTitle");
    css.setStyle("color",0x00FF00);

  • How to set the color to the particular row in a report

    Hi
    I have a report in which I have an edit link(I changed the id as edit link)..When I click that link, all the details(the whole row details) will be appearing on the items nearer to the report to save the changes....
    I want to set the color for the particular row when a link is clicked and the color should not be changed until I save the changes in items...After saving the changes, the report should come in the normal color...this is my requirement..i refered many forums regarding this...But could not find solution....If anyone knows,please help me...
    Fazila

    Here is how I would implement
    Create renderer
    Add SkinnableContainer element and create a skin for this container namely SkinnableContainerSkin
    find the fill section in the skin
    add bitmap fill to the fill section and give the source of the image which you are planning to use(Hopefully this is a direct way of doing, may be you need to hack this a little to get it to work)
    I've never tried this, but should help you give some idea.

  • How to set the color scale so that we can get same color for same intensity of color in various runs

    Hi
    I am trying to get the color pattern of mashed potato trays and diferent trays has different color intensity but if IF i am chsooing rainbow plateu it's giveing red color for dark region of each tray but two tray has different intensity of dark color. Can you suugest me how should I set the color scale so that I can distinguish which tray has higher degree of intensity of darkness.
    I will be obliged to get the suggestions

    Hello,
    Thank you for contacting National Instruments. I just have a few questions for you to help us clarify your application:
    What API, such as LabVIEW or C, are you programming your application in?
    Are you using Vision, and if so what specific functions are you currently using?
    Is the lighting consistent and just the color of the trays changing?
    How are you displaying the image in your program? Are you using an Image Display control?/li>
    Depending on what functions you have available, then we may be able to work on finding a way to distinguish between the different intensities. If you could provide a little information to your application based on these questions then will be able to better understand and help you with your app
    lication.
    Regards,
    Michael
    Applications Engineer
    National Instruments

  • How do you change the colors of individual cells within a 2D array?

    How do you change the colors of individual cells within a 2D array of numeric indicators?
    I want the VI to check a data value and if it is failing, white out a square at a specific index coordinate.  I have it working with color boxes, but I'm not sure how to use the property node function, to change the color of individual cells, by coordinates.
    I have attached the VI using color boxes. If you run the VI, the box corresponding to the Step control should turn white.
    I want to do the same thing, using numeric indicator boxes inside the array.
    Thanks for any suggestions...
    Attachments:
    Fill DME matrix.vi ‏95 KB

    Get rid of all these sequences! That's just bad form.
    Your code has a few logical problems. Why do you create a boolean array if you later only look at the last element (Yes, the FOR loop does nothing useful, except in the last iteration because your outputs are not indexing. All other iterations are useless, you only get the result of the last array element. My guess is that you want to color the index white if at least one of the numbers is out if range. Right?
    It is an absolute nightmare to manage all your numeric labels. Just read them from a 2D array. Now you can simply find the index of the matched elements and don't have to spend hours editing case structure conditions.
    Attached is a simple example how you would do what I meant (LV7.1). Modify as needed.
    Message Edited by altenbach on 04-04-2006 02:04 PM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    Fill_2DME_matrixMOD.vi ‏70 KB

  • Get the color of a pixel in an image

    how can i do to get the color of a pixel in an image ???
    Can anyone help me ?

    Hi,
    first of all you need to get the library to transfer your image to java.awt.image.BufferedImage object.
    I know many such libraries. Its depends of what kind of image you have: jpeg, gif, png or other.
    And when you get the BufferedImage of you picture using library, then you can get the color of any pixel in image using int BufferedImage.getRGB(int x, int y) as integer value.
    Victor Letunovsky

  • Link Color not changing for Visited Pages - How do I set the Color?

    In earlier versions of Safari, the user could select the color used to display links that have already been visited. I can't find that option in Preferences anymore. Some visited links do show a different color, some don't. Is it just random? How do I set the color in Safari 4.0.4 and activate the behavior?

    HI,
    I think you change visited pages link colors using Google preferences.
    http://www.googleguide.com/preferences.html
    Carolyn

  • Setting the color (or background color) of a substring

    Is it possible to set the color of a substring. For example:  If I had the string "Steve is stuck and needs help" and I wanted to change it to become "Steve is stuck and needs help".
    At present I am trying to modify the text inside of a String Indicator, but am open to suggestions.
    I have been reading the LV help and it seems to suggest that you can do this using the Text.SelStart and Text.SelEnd properties, but I can't get over that last hurdle that actually updates the string.
    Regards
    Steve
    https://decibel.ni.com/content/blogs/DailyCLAD
    Solved!
    Go to Solution.

    So close.
    Thanks All
    https://decibel.ni.com/content/blogs/DailyCLAD

  • Get the color of a pixel on the Stage

    Is there a way to retrieve the color of a generic pixel on the screen using the mouse pointer inside the Stage of Flash Player? With the getPixel method of the BitmapData class you can get the color of a pixel only if the mouse is over a bitmap image, but what if I need the color a generic pixel on the screen?

    this takes a snapshot of the pixel below the mouse:
    function eventHandler(event:MouseEvent):void
         var bmd:BitmapData = new BitmapData(1, 1, false, 0x000000);
         var matrix:Matrix = new Matrix();
         matrix.translate(event.stageX, event.stageY);
         //can never remember which way translate works so it could be:
         //matrix.translate(-event.stageX, -event.stageY);
         bmd.draw(stage, matrix);
         var pixelColour:uint = bmd.getPixel(0, 0);
    my blog has more info: http://blog.leeburrows.com/2010/09/bitmapdata-basics-1/

  • Can you set the color of a specific element in a JList?

    Is it possible to set the color of a single element in a JList without writing lines and lines of your own class? I know setForgroundColor exists, it just changes all element in a JList, so is there a simple way to tweak it? i am still a newbie, so re-writing swing, would be a bit of a problem for me. Any Suggestions? thanks.

    you write your own renderer, about 6-8 lines, setting the color determined by an
    if/else statement - note: you must set the color in both if and else
    search the forums for
    "implements ListCellRenderer"
    and you should find plenty of examples
    if you just want the selected element a different color, you can do this with
    UIManager.put("List.selectionBackground", new javax.swing.plaf.ColorUIResource(Color.YELLOW));
    but you must do this before you create the JList, and it will affect all JLists in your program.

  • Can u tell me how to set the color of the button and its border

    hi to all,can u tell me how to set the color of the button and its border

    There are sample code on the java.sun.com
    http://java.sun.com/docs/books/tutorial/uiswing/components/example-swing/index.html
    try this web page ... There are lots of examples... Good luck ... "Gan en "

  • Setting the color of a disabled checkbox...

    Hi,
    how do I set the color of a (disabled) JCheckBox because the following code does not work for me:
    jCheckBox1.setForeground(Color.BLACK);The background is that I don't want to have the checkbox in this grey (disabled) style, instead it should look like a "normal" checkbox (but disabled).
    Any ideas?
    Best regards
    - Stephan

    WindowsLookAndFeel uses native APIs to draw most of the controls. So, a disabled checkbox under Windows LAF will use the same API as the native disabled checkbox. You can install a custom JXLayer on that checkbox to prevent all the events from being passed to it - not the cleanest solution, but it will get you there (and make your users annoyed that they can't click on that checkbox).

  • Setting the color on selected Tab

    Hi,
    I can't seem to figure out how to set the color on the
    selected tab in a JTabbedPane. I've added a
    ChangeListener but when I try to use it, it only
    changes the color after the tab has been selected.
    I want to change it while it is selected.
    How can I do this?

    Maybe this helps:
    http://www2.gol.com/users/tame/swing/examples/SwingExamples.html
    Kurta

  • Setting the color of 3D EM Structures

    i have no issues setting the color i like for the 2D layer drawings. 
    and they are also correct on the 3D of the schematic layout
    however my problem is in setting the color in 3D layer for EM structures. They seem to be different.
    I tried setting the color of my material definitions (topmetal) under the material definitions tab of the STACKUP.
    but the color does not correctly translate in the 3D EM structure.
    please advise.

    i got it correctly setting the color of the 2D and 3D for EM structures by following your suggestion in setting the COLOR KEY. that's new to me. thanks
    but my major problem is still unsolved where the color settings of my 2D/3D schematic layouts is different from 2D/3D EM structure layout. I always set the color in the LPF file. for my case for example, my topmetal is defined in lpf as RED. but then when i draw shapes in 2D EM structure, the color for this topmetal layer becomes BLUE...quite lost on this because there's only 1 way to set the color in LPF under "General, Drawing layer 2d"...

  • Setting the color of the window title in Forms 6i

    How does one control or set the color of the title of the MDI and module windows
    gordon
    [email protected]

    Gordon, I'm pretty sure this is actually outside the realms of Forms since the Window Manager is controlled by the O/S and so the only way you can set this is via the PC desktop (there is nothing exposed in Set_Window_Property that can do this).
    Hope this helps.
    Regards
    Grant Ronald
    Forms Product Management

Maybe you are looking for

  • How to assign chart of account to company code

    hi all,           i am using SAP ECC 6.0            in my hierarchy , i follow following menu path for assigning company code to chart of account but there is no option there my menu path is as follows : Financial Accounting (NEW) -> General Accounti

  • Duplicate Check while creating new BP

    Dears, I am a CRM Consultant and working on a CRM VMS integration scenario, wherein BP(End customer) is created in VMS system and this will be replicated to SAP CRM system which has duplicate check active.  However we would like to perform the duplic

  • Why do I get a message that says something is preventing firefox to update correctly when I have the latest version and it is up to date.

    Every now and then I will come back to my computer and see a message saying that something is preventing Firefox from updating correctly, am I sure that I have got the latest version. Included in the message box is a link to www.firefox.com, when I c

  • M&S iviewer iPlayer TV

    Hi, I can't believe I'm the only one with this issue. I am currenlty being force to use the BT HomeHub2 for my internet router due to an ongoing broadband/phone line issue. Why is this an issue. Well it's not, I don't actually mind the HH router, but

  • Linux ODBC Errors

    I'm trying to port my setup from a Windows machine to a Linux server and haven't been able to thus far. The DB is on one server and the OBIEE instance in on a different server. I have an Oracle Client installed and working on the OBIEE server as I ch