Hey, guys, what's up?
I welcome you to another drill on the screen, your application and in this story, we are going to
see how we are going to save our screenshot on the part which we have specified.
So the first thing you have to do for that is that you have to just write in the function named as SCAP.
Screenshot and that is going to basically receive trousering now what is browser or whatever browser
over here is basically the object, or you can say that it is basically the object that is going to
provide you with certain methods.
Now, what are going to be those methods?
The first one is going to be to get user data and the second one is going to be the set user data function.
So for this section and for this screenshot application, we are going to use the get the user data.
And what is going to be the data we are going to obtain is basically going to be the buffer in which
our screenshot is basically painted in the on page function.
So using that buffer, what we are going to do is that we are going to get a data from there and we
are going to store it in a buffer string right in this function.
So right here, we are going to first have a global variable that is going to be.
The part for the screenshots that is going to be named as screenshot part and the next thing we are
going to do is that we are going to have to get used at a function that is basically being provided
by the browser object.
So right here, you are going to simply create a variable over here that is going to be named as Bopara
String and that is going to equal to browser DOT.
Get user data and what data is going to gain is basically going to be unbent, not like that, it is
going to be on and it is going to be faint and it is going to be the buffer from the onset.
Now, what is going to be stored in the unfeigned buffer in the unpaired?
We are going to have a buffer that is basically going to have the painting of our screenshot in very
simple words.
So don't get confused for now.
Just remember that it is basically going to be the buffer that is going to have our screen shot.
So that's why we are going to just get the user data from there.
We are going to store it in a variable, but our stranglehold.
And finally, we are going to have a condition that is going to check if this buffer string is empty
now, when is this the first string going to be empty?
This string is going to be empty if the get user data basically does not retrieve anything from there.
And why it is not going to retrieve anything from this on or buffer will be because that this buffer
is empty.
And now why this buffer will be empty is because that this function on bed has never been called.
So if we just write in, if not Bofur string, which means that if it is empty, then what we are going
to do is that we are going to raise an exception.
So just write an exception.
And what is going to be that exception is basically going to be a very simple exception.
That is simply going to say that the first string is empty.
The reason behind that, as I told you, is that on paint was never called, which means that this get
used at a function, was able to retrieve nothing from on or buffer.
So just right in that the buffer.
String.
Was empty.
Because.
Unbent was.
Never quite simple as that is moving to a new line.
All right, that seems cool.
So let's just move out of this if condition and outside this if condition.
What we are going to write is that if this condition after this condition has been checked, we are
going to write in the image equal to image dot from.
And we are going to now set the image of Wahib that is going to be the R.G. Baphomet image, then we
are going to specify the.
Viewport sized, that is basically going to have the length and breadth and height of the screenshot.
Then we are going to have the buffer, a string that is basically going to have on a string that is
going to be the painting of the screenshot.
We are going to have then it is going to be the draw.
Finally, we are going to write an RGV and we are going to write in the X and Y, so that is going to
be zero and one.
Finally, we are going to just save our image.
So we are going to use image and we are going to read Image Dot Save an image basically now contains
the image because we have created it using this thing over here.
So we are going to just save the image now.
And where we are going to save is going to be the first argument that is going to be the screenshot
part.
And the second argument is basically going to be the format in which the image is going to get stored
and that is going to be at the end format.
Finally, when everything is done successfully, what your system is going to simply print for you is
that it is going to write and saved.
Screenshot two, and it is going to then finally have interpellation in which it is going to specify
the part.
So outside this just right, the format in which this interpellation is going to get completed, that
is going to be part equal to the screenshot, but simple as that.
So in this tutorial, what we have discovered is that we have actually saved our screenshot.
We have actually obtained the data from the buffer, stored it in a variable buffer string check it
is empty or if it is not, finally, we have created our image using the Yardbird viewport sized up
of our string.
And what we have done is that we have also saved this to the screenshot board.
The format for the image is going to be the PMG.
Finally, we have just printed a simple message that the screenshot has been saved in the past and what
is going to be the part that is going to be the screenshot part.
So I guess that's it for this story.
In the next tutorial, we are going to have the function that is going to actually open our default
application in which our screenshot is going to get viewed.
So stay tuned for that.
Tutorials for this tutorial.
That's it.
Thank you so much for watching.
And I'll see you guys in the next tutorial.