OBS source code use learning (3) screenshots (Screenshot)

This is currently the easiest article in learning and using obs source code. If you have read the first two articles, I believe you will be able to realize this function soon in this article.

Attachment: Obs source code learning and using the first two articles:

Camera acquisition related to OBS source code

OBS source code learning preview box display

1. Copy the code according to the tiger and draw the cat

We directly looked at the code directory of obs and found that the file window-basic-main-screenshot.cpp is very similar to the file where the function we want to achieve is located. We opened it directly without stopping.

As soon as we open it, we can see that in addition to the interface ui with obs, screenshot-obj.hpp is also included in the include.

Let's do the same thing, directly add screenshot-obj.hpp to our project and include it.

After include, we can directly use the ScreenshotObj class, and then we copy all the method functions involved in window-basic-main-screenshot.cpp to it.

So far, most of this function has been completed, and the next step is to slightly modify the code according to its own situation.

2. Use codes to draw cats and tigers

1. Use ScreenshotObj related code

We first define a QPointer monitoring pointer, let it refer to NULL after being destroyed.

QPointer<QObject> screenshotData;

Next, you only need to instantiate to complete the screenshot function

screenshotData = new ScreenshotObj(source);

It is still the same as the core concept of OBS images, whatever source is given to him, he will capture the image of the source.

At this point, all screenshot functions are completed, which can be said to be very simple.

Guess you like

Origin blog.csdn.net/weixin_44838243/article/details/127750754