video as texture in Qt3D 2.0 - qt

I am using Qt 5.5.0 and Qt3D 2.0.
I want to display video as texture.
I can display and rotate only one image.
How can I add a video instead of an image?

Related

Pixelated gif in QT

I'm trying to show a gif file in QT app, using the approach provided in the link: https://code.qt.io/cgit/qt/qtbase.git/tree/examples/widgets/widgets/movie?h=5.15
Approach makes use of QMovie object set in a QLabel.
The example works well and fine.
But if I enable High DPI scaling for the app, the gif becomes all pixelated. Please see the screenshots below.
This is the line that I add to enable High DPI scaling.
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
Any ideas to get this fixed ?
I have tried the following fixes already:
setScaledSize for the QMovie object
setScaledContents(true) for the QLabel
QT version I'm using is 5.15.2 and platform is Windows.
A GIF picture cannot have more than 256 unique colours. When you load such an image into Qt, it is internally represented in that exact format with the palette (of 256 colours) from the GIF representation, even if your hardware might be able to display many more colours.
This also means that when you scale such an image, Qt is not allowed to extend the colour space to render in-between colours - This means that scaled GIF pictures generally have to look much worse than scaled high-colour images.
The solution to this is either to transform the QImage you created from a GIF picture into a format with a larger colour space before scaling it (with QImage::convertToFormat) or, better still, don't use GIF images at all. After all, GIF is a format developed 30 years ago and has never really been updated to adapt to modern hardware, and using it, you artificially limit your programs to the capabilities of that format.
It seems at this moment there is no way to render sharp gifs when scaled using QMovie and QLabel. I have filed a bug for the same in QT bug tracker.
Meanwhile I have found a workaround that works fine. It is done making use of QML in the QWidget system, using QQuickWidget.
Let me add the full steps here, so that it is helpful to anyone else who run into this problem:
First we need to add support for Qml and QuickWidgets. I use CMake and Visual Studio. Hence I add the below lines in the CMakeLists.txt file. Equivalent changes needs to be made in the .pro file, if QT Creator is used instead.
# I'm only adding the relevant lines for brevity
find_package(Qt5 COMPONENTS Qml QuickWidgets)
target_link_libraries(${APP_TARGET_NAME}
Qt5::Qml
Qt5::QuickWidgets)
# Note the --qmldir switch
add_custom_command (TARGET ${APP_TARGET_NAME} POST_BUILD
COMMAND ${QTDIR}/bin/windeployqt
--qmldir ${CMAKE_CURRENT_SOURCE_DIR}/qml
${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/${APP_TARGET_NAME}.exe)
Then create a spinner.qml file inside a folder named qml:
import QtQuick 2.15
Rectangle {
width: 12
height: 12
AnimatedImage {
y: 5
width: 12
height: 12
id: spinner
source: "img/spinner.gif"
speed: 1.0
}
}
And then load the qml file using QQuickWidget and add the QQuickWidget instance to the QWidget layout.
QHBoxLayout *main_layout = new QHBoxLayout();
auto *spinner_gif = new QQuickWidget(QUrl::fromLocalFile(":/spinner.qml"));
main_layout->addWidget(spinner_gif);
this->setLayout(main_layout);
The gif that shows up won't be pixelated even when scaled and we can see the GPU in use, in the Task Manager, as expected for a QQuickWidget.

Coordinates of the displayed part of an image in Qt

How can I know the coordinates of the displayed part of an image in the Qgraphicsview in QT ?

How to implement a Adobe Photoshop Elements like toolbox in QT

Adobe Photoshop Elements is developed in QT. How to implement the dockable and stretchable toolbox at the left of Adobe Photoshop Elements. THX.

Is it possible to have a transparent video playing in QT application

Some codecs alow alpha transparency, like flv, Mov and Webm. I am about to build a QT app and i want to know if it will be possible to make a video player using QML which will support transparency and i will be able to see the background of my app even when the video is playing.
You can set a widget to have a level of transparency, so if the video stream is also transparent it should show transparent to the widget and then if the widget is also transparent then through that.
Have you already looked at the QML Video example which ships with the current QTCreator / QT 5.1.1 SDK package?. If you wish to draw a transparent/translucent video window, you can modify the 'opacity' property of a QML VideoOutput element to have translucent Video overlay.
You can build the example if you download and install the SDK.
Here's is the online link to the example:
QML Video Example
Take a close look at this file:
VideoItem.qml
You can modify the opacity as shown below:
import QtQuick 2.0
import QtMultimedia 5.0
VideoOutput {
id: root
height: width
source: mediaPlayer
opacity: 0.7 // Set the opacity as you wish
...
You can play around with the example by importing any type of video files you wish.

cocos3d line glow effect

I'm using cocos3d 7.0 (that is, a 3d extension for cocos2d) on iOS 3.1 which has only GLES 1.1.
I want to draw a line in space with a glowing effect. Ideally, it has to look like a line on the second image in Opengl ES 1.x glowing effect in iOS. But the above example uses plain gl calls, and no cocos3d/2d framework calls.
Is there any good example or tutorial of creating such an effect in terms of cocos3d api?

Resources