Results 1 to 6 of 6
  1. #1
    ferite is offline Member
    Join Date
    Sep 2014
    Posts
    4
    Rep Power
    0

    Default Altered colors in Swing application.

    Hi.

    I am developing a kiosk application, using Java Swing as GUI API. I am testing the application with the display to be used, a framebuffer USB display, tied to a x86 board running TinyCore Linux (Kernel 3.8.10). Now, when the OS desktop is shown, all the picture is "normal":

    Altered colors in Swing application.-2014-09-02-19.11.42.jpg

    But when the Java application is running, the color is altered, as if one of the RGB components was missing (The image is showing a JForm with a JLabel whose Icon image is the girl that you can see in the picture):

    Altered colors in Swing application.-2014-09-02-17.37.51.jpg

    This is how the original background image should look like:

    Altered colors in Swing application.-ndice.jpg

    I have to say that when a "conventional" (HDMI) display is used, the image is shown well. The same as if I execute the app with X forwarding.

    I am wondering if somebody has a possible explanation or a tip to fix this.

    Thanks.

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    13

    Default Re: Altered colors in Swing application.

    You should provide a small program which demonstrates the problem. Make certain you include the image.
    And please surround the code with [code][/code] tags.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  3. #3
    ferite is offline Member
    Join Date
    Sep 2014
    Posts
    4
    Rep Power
    0

    Default Re: Altered colors in Swing application.

    Quote Originally Posted by jim829 View Post
    You should provide a small program which demonstrates the problem. Make certain you include the image.
    And please surround the code with [code][/code] tags.

    Regards,
    Jim
    Hi. With this simple code I could reproduce the case:

    Java Code:
    public class LabelDemo extends JPanel {
        public LabelDemo() {
            super(new GridLayout(1,1)); 
            JLabel label3;
            ImageIcon icon = new ImageIcon("girl.jpg");
            label3 = new JLabel(icon);
            add(label3);
        }
        
        private static void createAndShowGUI() {
            JFrame frame = new JFrame("LabelDemo");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.add(new LabelDemo());
            frame.pack();
            frame.setVisible(true);
        }
     
        public static void main(String[] args) {
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                createAndShowGUI();
                }
            });
        }
    }
    The result is this (Note at the side, the original picture, opened with Firefox):
    Altered colors in Swing application.-2014-09-04-13.35.28.jpg

    Thanks.

  4. #4
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    13

    Default Re: Altered colors in Swing application.

    Well the code you provided worked (in Windows 7) running Java 8. You didn't mention if you had tried it in that environment.
    You said included test program produced the "bad" results when you ran it. I suspect it must be related to the TinyCore
    OS. Others on this site may be able to assist. All I can recommend is to see if there is a mailing list and if
    others have had this problem. Sorry I couldn't be more help.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  5. #5
    ferite is offline Member
    Join Date
    Sep 2014
    Posts
    4
    Rep Power
    0

    Default Re: Altered colors in Swing application.

    After some inquiry with the display manufacturer, it seems that traditionally, framebuffer stores the data in {R, G, B} sequence. But this driver in particular uses {B, G, R}. Apparently most X11 application can "query" for the correct color order. But Java VM don't. So they suggested me as walk around to find out if there is a way to "force" JVM to assume the opposite color order.

    I was wondering if it is possible.

  6. #6
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    13

    Default Re: Altered colors in Swing application.

    I have not worked with ColorModels any but I did read about this:

    DirectColorModel (Java Platform SE 8 )

    Perhaps if you could find a way to create your own color model (but change the masks as needed). The API documentation also refers
    to X11 so it may be of use.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

Similar Threads

  1. altered snake game
    By dmp in forum Android
    Replies: 1
    Last Post: 04-17-2012, 05:49 AM
  2. Design of Application (Swing/SWT)
    By tripley_1 in forum AWT / Swing
    Replies: 2
    Last Post: 12-01-2009, 05:55 PM
  3. Existing swing application
    By macason in forum AWT / Swing
    Replies: 3
    Last Post: 11-30-2009, 10:51 PM
  4. Better Swing Application Framework
    By etf in forum Java Software
    Replies: 1
    Last Post: 09-07-2009, 02:25 PM
  5. designing application in swing
    By programmer_007 in forum AWT / Swing
    Replies: 12
    Last Post: 09-03-2009, 07:50 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •