Direct drawing on UI
-
hi
why cant RGBData just live in VideoFrameWidget ?
so you dont need to give it from main. ?but else u just use functions to give it to the widget.
-
hi
why cant RGBData just live in VideoFrameWidget ?
so you dont need to give it from main. ?but else u just use functions to give it to the widget.
It can, but i found it not logic. it is coming from the camera.
It was simplification of main. In a reality it will be a loop.If i understood you correctly, you propose to do it like this:
main() { char* RGBData;//data from camera VideoFrameWidget videoFrame = new VideoFrameWidget(); CameraDevice videoSource = new CameraDevice (); for(;;) { RGBData = videoSource->getFrame(); videoFrame->setFrame(RGBData); videoFrame->update(); } } class VideoFrameWidget : public QWidget { Q_OBJECT public: VideoFrameWidget(QWidget *parent); virtual void paintEvent(QPaintEvent *); void setFrame(char* newFrameData); private: char* frameData; }; void VideoFrameWidget::paintEvent(QPaintEvent*) { //use opengl to draw image from frameData } void VideoFrameWidget::setFrame(char* newFrameData) { frameData = newFrameData; }
-
yes exactly and then u can use
char* frameData;
in paintEvent -
-
@mrjj
Thank you for helping@Wieland
Can i ask for help with my problem please?
I need to display raw RGB on a screen in a fastest way. -
@mrjj
Ok. Thanks.For me it is looks strange, but reading this example
http://doc.qt.io/qt-5/qtopengl-2dpainting-example.html
i found, what the only different is using GLWidget as base class.
All painting is done by the same QPainter.Am i right?
If it is so, task can be really simple.
Maybe you know the fastest way to paint from RGB raw data on widget: draw line by line, pixel by pixel, memcopy,.... -
@mrjj
Ok. Thanks.For me it is looks strange, but reading this example
http://doc.qt.io/qt-5/qtopengl-2dpainting-example.html
i found, what the only different is using GLWidget as base class.
All painting is done by the same QPainter.Am i right?
If it is so, task can be really simple.
Maybe you know the fastest way to paint from RGB raw data on widget: draw line by line, pixel by pixel, memcopy,....@Mikl
Yes as far as i know its VERY similar to
normal widget drawing even when opengl.
(when 2d)well, the sample i have seen , used something like
uchar* data = getDataFromSomewhere();
QImage img(data, width, height, QImage::Format_ARGB32);
and then convert ot pixmap and draw.
or directly into pixmap with
http://doc.qt.io/qt-4.8/qpixmap.html#loadFromData -
@mrjj
Ok. Thanks.For me it is looks strange, but reading this example
http://doc.qt.io/qt-5/qtopengl-2dpainting-example.html
i found, what the only different is using GLWidget as base class.
All painting is done by the same QPainter.Am i right?
If it is so, task can be really simple.
Maybe you know the fastest way to paint from RGB raw data on widget: draw line by line, pixel by pixel, memcopy,....@Mikl said:
For me it is looks strange, but reading this example
http://doc.qt.io/qt-5/qtopengl-2dpainting-example.html
i found, what the only different is using GLWidget as base class.
All painting is done by the same QPainter.Am i right?
Hi! Yes, getting 2D hardware acceleration for QPainter is really easy :)