Page 1 of 2 12 LastLast
Results 1 to 20 of 33

Thread: Newbie: Require assistance - modify existing jpeg image ,save and display on LCD

  1. #1
    Join Date
    Feb 2008
    Posts
    19
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Newbie: Require assistance - modify existing jpeg image ,save and display on LCD

    Hi

    I have to develop a feature in my application which enables modifying an jpeg image and saving it.

    This feature is launched from one of the existing screens in my project

    Let me divide this task
    1. Open an existing jpeg image. This should be displayed on LCD (640x480)
    2. Modify the jpeg image using stylus (Touch Screen is integrated)
    3. Save the modified image

    What are the steps involved? How should I proceed?

    -Thanks in advance

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Newbie: Require assistance - modify existing jpeg image ,save and display on LCD

    Take a look at QImage.

  3. #3
    Join Date
    Feb 2008
    Posts
    19
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Newbie: Require assistance - modify existing jpeg image ,save and display on LCD

    Thanks for your response.

    I have tried using the QImage
    I open the jpeg file using Qimage. But the image is not visible on the LCD.
    What else should I do? I tried using QImageIO to display the image on LCD. But, after opening, the old screen itself is displayed on LCD. How do I make this image to display on the LCD?
    This is what I have done:
    QImage image;
    const char *buffer = "/root/ferrari.jpg";
    image.load(buffer);

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Newbie: Require assistance - modify existing jpeg image ,save and display on LCD

    You have to display the image somewhere. QImage only holds the data. You can use QLabel to display a QPixmap that you can obtain from QImage or directly load from file.

  5. #5
    Join Date
    Feb 2008
    Posts
    19
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Newbie: Require assistance - modify existing jpeg image ,save and display on LCD

    Thanks pal!

    This is what I have done. But, I still dont see the image on the LCD. The screen is not refreshing. Have I missed something here?
    This is what I have done-
    Qt Code:
    1. QImage image;
    2. const char *buffer = "/root/ferrai";
    3. image.load(buffer);
    4.  
    5. QPixmap pix;
    6. pix.fromImage(image, 0);
    7.  
    8. QLabel labl;
    9. labl.setPixmap(pix);
    To copy to clipboard, switch view to plain text mode 
    Last edited by jpn; 19th March 2008 at 18:53. Reason: missing [code] tags

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Newbie: Require assistance - modify existing jpeg image ,save and display on LCD

    Quote Originally Posted by dbugger View Post
    QPixmap pix;
    pix.fromImage(image, 0);
    QPixmap::fromImage() is a static method --- it won't change the "pix" variable, but instead it returns a new QPixmap.

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Newbie: Require assistance - modify existing jpeg image ,save and display on LCD

    And the label probably goes out of scope.

  8. #8
    Join Date
    Feb 2008
    Posts
    19
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Newbie: Require assistance - modify existing jpeg image ,save and display on LCD

    Thanks for your response

    What are you hinting at? Do you mean that that the image I want to display is not available in QLabel? If that is the case how can I achieve it?

    I see 2 other classes QImageIO and QIODevice. As, I have to display the image on LCD (touhscreen integrated) which is an IO device, should one of these classses be also used?

  9. #9
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Newbie: Require assistance - modify existing jpeg image ,save and display on LCD

    1) QPixmap::fromImage() is a static method --- it won't change the "pix" variable, but instead it returns a new QPixmap.
    Qt Code:
    1. QPixmap pixmap = QPixmap::fromImage(image);
    To copy to clipboard, switch view to plain text mode 
    2) And the label probably goes out of scope.
    Qt Code:
    1. {
    2. QLabel label;
    3. label.setPixmap(pixmap);
    4. label.show();
    5. } // label is a local variable and goes out of scope, so gets destructed according to normal C++ rules
    To copy to clipboard, switch view to plain text mode 
    VS.
    Qt Code:
    1. {
    2. QLabel* label = new QLabel;
    3. // label->setAttribute(Qt::WA_DeleteOnClose); // hint
    4. label->setPixmap(pixmap);
    5. label->show();
    6. } // the pointer variable goes out of scope but the object itself remains alive
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  10. #10
    Join Date
    Feb 2008
    Posts
    19
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Newbie: Require assistance - modify existing jpeg image ,save and display on LCD

    Thanks.

    I will try and let you know

    Cheers

  11. #11
    Join Date
    Feb 2008
    Posts
    19
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Newbie: Require assistance - modify existing jpeg image ,save and display on LCD

    I tried your suggestion. There is no change in the screen that is displayed on the LCD. But, if I press one of the buttons (which is on the keypad), the current screen vanishes but I still dont see the desired image on LCD. Though on close observation, on the top right corner of the LCD, I see something, but it is not part of the image that I want to display
    Where am I going wrong?

    Thanks for your patience

  12. #12
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Newbie: Require assistance - modify existing jpeg image ,save and display on LCD

    Could we see a larger snippet of code?

  13. #13
    Join Date
    Feb 2008
    Posts
    19
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Newbie: Require assistance - modify existing jpeg image ,save and display on LCD

    This is what I have done:

    Qt Code:
    1. QImage image;
    2. const char *buffer = "/root/whitescreen.jpg";
    3. image.load(buffer);
    4. QPixmap pix;
    5. pix.fromImage(image, 0);
    6. QLabel* label = new QLabel;
    7. label->setPixmap(pix);
    8. label->show();
    To copy to clipboard, switch view to plain text mode 

    Please excuse me for my mistakes if any
    Last edited by jpn; 20th March 2008 at 18:04. Reason: missing [code] tags

  14. #14
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Newbie: Require assistance - modify existing jpeg image ,save and display on LCD

    You are still using QPixmap::fromImage() incorrectly.
    J-P Nurmi

  15. #15
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Newbie: Require assistance - modify existing jpeg image ,save and display on LCD

    And this snippet is not larger than the previous one. Could we see in what exact context is the code situated? Is it in main() or is it a method of some class and where is it called?

  16. #16
    Join Date
    Feb 2008
    Posts
    19
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Newbie: Require assistance - modify existing jpeg image ,save and display on LCD

    This is where the code sits

    Qt Code:
    1. void class_name::function()
    2. {
    3. #if PRINT_DEBUG
    4. qDebug("%s : xxxxxxxxx yyyyyyy Pressed",pname);
    5. #endif
    6.  
    7. #if 1
    8. printf("\nentering open image\n");
    9. openimage();//ING_IND
    10. printf("\nexited open image\n");
    11. #endif
    12. }
    13.  
    14.  
    15. void class_name::openimage()
    16. {
    17. closecurrentscreen();
    18. /*open jpeg image*/
    19. QImage image;
    20. const char *buffer = "/root/whitescreen.jpg";
    21. QPixmap pix;
    22. pix.load(buffer);
    23. QLabel* label = new QLabel;
    24. label->setPixmap(pix);
    25. label->show();
    26. /*modify image*/
    27. /*need to code*/
    28. /*save image*/
    29. /*need to code*/
    30. }
    To copy to clipboard, switch view to plain text mode 

    This is exactly what I intend to do. Before opening the image,
    - close the current screen
    - open the image
    - modify
    - save

    But even the current screen itself is not getting closed.

    Thanks pal for everything!!
    Last edited by wysota; 20th March 2008 at 20:28. Reason: missing [code] tags

  17. #17
    Join Date
    Feb 2008
    Posts
    19
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Newbie: Require assistance - modify existing jpeg image ,save and display on LCD

    I would like to show some more of the code but it is confidential

  18. #18
    Join Date
    Feb 2008
    Posts
    19
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Newbie: Require assistance - modify existing jpeg image ,save and display on LCD

    but I can give you the scenario if you want to know. but that I cannot write in the forum, I can write you a private message, if that is fine with you!!

    Thanks!!

  19. #19
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Newbie: Require assistance - modify existing jpeg image ,save and display on LCD

    You will surely have to redesign your code. Qt is event driven. That means that the code is not structured as a single scenario flow, but instead it's a state machine that reacts on events received. Your method will have to display the image and do nothing more with it. Other methods will perform actions associated with editing the image and finally yet another one will save it back.

    My guess is that your slot is not called at all, so verify that first by inserting some debug statements in it.

  20. #20
    Join Date
    Feb 2008
    Posts
    19
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Newbie: Require assistance - modify existing jpeg image ,save and display on LCD

    Do you mean to say that the control isn't entering the "openimage" function? If that is the case, I can see the debug messages, which means that my SLOT is fine. But I am not sure as to how to make my current application which has many screens to go inactive/ionvisible and display the jpeg image on LCD.
    Should/Can we modify the frame buffer?

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.