I want to get a screen shot of the widget application and then set its raw data buffer to QMeidaPlayer with setMedia(). If anyone tried this before, I would thank if you tell me how to do that:
buffer.setBuffer(&ba);
image->save(&buffer); // writes image into ba in PNG format
image->save("/home/saman/Desktop/myImage", "PNG");
mediaPlayer.
setMedia(QUrl::fromLocalFile("/home/saman/Desktop/png/images08.jpeg"));
//I want this to read from raw data
mediaPlayer.play();
QPixmap originalPixmap = QPixmap::grabWidget(this);
QImage *image = new QImage(originalPixmap.toImage());
QByteArray ba;
QBuffer buffer(&ba);
buffer.setBuffer(&ba);
buffer.open(QIODevice::WriteOnly);
image->save(&buffer); // writes image into ba in PNG format
image->save("/home/saman/Desktop/myImage", "PNG");
mediaPlayer.setMedia(QUrl::fromLocalFile("/home/saman/Desktop/png/images08.jpeg")); //I want this to read from raw data
mediaPlayer.play();
To copy to clipboard, switch view to plain text mode
I note again, what i have done is to receive the image, SAVE it, and then read from it. However, I would like to ask you how to read raw data directly without saving it into media player.
// saving
counter = 1;
image.save("/home/saman/image", "JPG");
counter = 0;
// saving
counter = 1;
image.save("/home/saman/image", "JPG");
counter = 0;
To copy to clipboard, switch view to plain text mode
somewhere else, reading
if(counter == 0)
{
mediaPlayer.
setMedia(QUrl::fromLocalFile("/home/saman/image"));
mediaPlayer.play();
}
if(counter == 0)
{
mediaPlayer.setMedia(QUrl::fromLocalFile("/home/saman/image"));
mediaPlayer.play();
}
To copy to clipboard, switch view to plain text mode
Bookmarks