 Hello, everybody, and welcome back to some more C++ SDL programming. I'm going to go ahead and save this script, not the script, but this source code, this program as a new file. I'm going to call mine 09a underscore more images with underscores. OK. And let's actually get to the point of this tutorial. In the last tutorial, we were learning how we can actually go ahead and use images in our code and in our SDL program. Now, we have a few classes. And this is how we've been able to manipulate images and actually see them on the screen and that sort of thing, using SDL Surface and SDL Rect with our Sprite class. We have Sprite Gloops to manage multiple of them, Sprite Groups, sorry. And the block, which is actually the object or the class that actually is going to display a Sprite, which is really the base class. So we have the set image function. And you may have remembered, or you may remember anyway, when I said that SDL supports images, I said that SDL only supports bitmaps. And you can see this line right here, loaded image equals SDL underscore load BMP or load bitmap. The only thing that it can really load is a bitmap file. And that's kind of a shame. Let's check it out in the documentation. I've got this up in my internet browser over here. Now, this is online at wiki.libsdl.org. You can, of course, find that online at just libsdl.org. And the function we were using was SDL load bitmap. And OK, looks like we've got a few over here. Use this function to load a surface from a bitmap file. It doesn't explain anything more about loading images. I wonder if it shows that by API by category. I was hoping it would show us some images. Simple drawing, load bitmap. Now, notice it doesn't have any other functions to load any other kinds of images. So we've got to know a little bit more with this, because bitmaps are really not the most common kind of image file that we see. Now, I want to tell you about a special library or a special module that will allow you to use other images and other file types other than just plain old bitmap in SDL. And this is called sdl underscore image. I'm going to Google that. I'll show you all just heading over to Google. And it's sdl underscore image. And sdl image, this right here, it'll link you to other projects for sdl image. And you'll see, OK, sdl image 2.0 has been released, because we have sdl 2.0. There is the older version, sdl image 1.2. And we can use that just as well as if we would like. But this is available online. And you can download the Windows binaries if you need to, if you're running on Windows. If you're on Linux, obviously, contact your distribution maintainer for updates. I'm on Linux. And that's what I'm going to do. I'm going to go ahead and just install this by my package manager in Ubuntu. Now, I'm going to get my terminal open. And I'm in my cwork sdl folder that I've been in. And the command for this is just sudo. Obviously, to run this command as the super user, super user do, apt-get install. apt-get is the package manager for Ubuntu. And other, I think, Debian-based systems install. And the package name is lib sdl, just like we've seen before. 2, of course, because we're using the version number. And hyphen image, because we know that's the module in the library we want. And, of course, dash dev, because we want the development libraries. Go ahead and hit Enter. It'll ask you to put in your password. And I've already installed this, but if it does ask you, please enter the yes key or the y key to confirm. You can go ahead and install, and that will work just fine for you. Cool. So now that it's installed, we can go back into our source code. And the only thing that we really have to do, thankfully, this sdl image doesn't really have to be imported. I'm sorry. No, it doesn't have to be initialized. It does, however, obviously have to be imported and included. So over here in our preprocessor definitions to include some header files, we want to include sdl and then a new line underscore image. We can save that. And now that we can go back into our code, we notice that in the block class, that's where we're actually loading this image. And the function we used was before sdl load bitmap, or load BMP. Now we're going to use a different function here. This one is called img underscore. Now you notice it has a pretty similar kind of syntax other than the sdl proceeding underscore. This is just going to be img to note that we're using the image library and the image module. Img underscore load with capital L. And that's how we can load that file name. I believe this should still work with the bitmap file. We'll go ahead and keep that. And let's see what happens when we try to run this code. I'll clear the screen here. And my program is called g++. That's what we're going to use to compile. 09a, more images. And we do need to use package config with our back ticks. C flags and libs to get all the information for sdl2. And outside of the back ticks, what we can do as to link the new sdl2 image library, we have to use a hyphen and then the letter L and then without any spaces, we're just going to link with the g++ command that this is an argument for g++, the program itself. We want to use sdl, capital letters, to, because that's the version number, underscore image. And that's all lowercase. Now when we run this, no errors. Awesome, that works well for us. If I run the code, sweet. Our bitmap image loads perfectly fine. But like I've told you, we can use PNG files and other things with that. I want to say, sorry. The description here says sdl image is an image file loading library. It loads images, sdl services, and textures and supports the following formats, bitmap, GIF, however you want to say, JPEG, PNG, and other very common ones. OK, so let's actually go find a PNG file we can just use. PNG, Sprite, I just googled images. Holy crap, that's a lot of stuff. I want something small. Sprite. I'm going to get a Sprite can. That's small enough. And OK, that's a PNG file. Awesome. Hope I don't have any copyright issues with this. All right, and this was in my CWORK sdl nutrition bottle.png. Good. NutritionBottles.png is the file name. And if we go back in our code, we can run our setImage function on our block object. And we can use nutritionBottles.png. Now when we run this code, we'll go ahead and compile it. No errors. We can run this. And there's our Sprite bottles with our Sprites that are properly using a PNG image. Awesome. We could do this with other things like JPEGs and that sort of thing. I'm not going to demonstrate that for you. Hopefully you can take my word for it. If not, you can try it out for yourself and see what works for you. But all it is in this case with the sdlImage library, we don't have to initialize the library or do anything with it. We're just essentially using more services that sdl typically works with, but we're loading them in a different way with the IMG load function. Now you can check out more or see what else this library can do by checking it out online at that sdlImage 2.0 kind of web page that we Googled. And the documentation is available. They give you a nice link to it here. And it shows what more it can do, that sort of thing. I would recommend you check this out, but it's entirely up to you. Okay, thanks for watching the video guys. Thanks for, I hope you enjoyed this tutorial. And well, thanks for keeping with me. Hopefully I'll see you in the next tutorial.