-
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:)
-
Re: Newbie: Require assistance - modify existing jpeg image ,save and display on LCD
-
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);
-
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.
-
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-
Code:
const char *buffer = "/root/ferrai";
image.load(buffer);
pix.fromImage(image, 0);
labl.setPixmap(pix);
-
Re: Newbie: Require assistance - modify existing jpeg image ,save and display on LCD
Quote:
Originally Posted by
dbugger
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.
-
Re: Newbie: Require assistance - modify existing jpeg image ,save and display on LCD
And the label probably goes out of scope.
-
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?
-
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.
2) And the label probably goes out of scope.
Code:
{
label.setPixmap(pixmap);
label.show();
} // label is a local variable and goes out of scope, so gets destructed according to normal C++ rules
VS.
Code:
{
// label->setAttribute(Qt::WA_DeleteOnClose); // hint
label->setPixmap(pixmap);
label->show();
} // the pointer variable goes out of scope but the object itself remains alive
-
Re: Newbie: Require assistance - modify existing jpeg image ,save and display on LCD
Thanks.
I will try and let you know
Cheers :)
-
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 :)
-
Re: Newbie: Require assistance - modify existing jpeg image ,save and display on LCD
Could we see a larger snippet of code?
-
Re: Newbie: Require assistance - modify existing jpeg image ,save and display on LCD
This is what I have done:
Code:
const char *buffer = "/root/whitescreen.jpg";
image.load(buffer);
pix.fromImage(image, 0);
label->setPixmap(pix);
label->show();
Please excuse me for my mistakes if any
-
Re: Newbie: Require assistance - modify existing jpeg image ,save and display on LCD
You are still using QPixmap::fromImage() incorrectly.
-
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?
-
Re: Newbie: Require assistance - modify existing jpeg image ,save and display on LCD
This is where the code sits
Code:
void class_name::function()
{
#if PRINT_DEBUG
qDebug("%s : xxxxxxxxx yyyyyyy Pressed",pname);
#endif
#if 1
printf("\nentering open image\n");
openimage();//ING_IND
printf("\nexited open image\n");
#endif
}
void class_name::openimage()
{
closecurrentscreen();
/*open jpeg image*/
const char *buffer = "/root/whitescreen.jpg";
pix.load(buffer);
label->setPixmap(pix);
label->show();
/*modify image*/
/*need to code*/
/*save image*/
/*need to code*/
}
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!!
-
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 :(
-
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!!
-
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.
-
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?