Page 1 of 2

Loading and Drawing an image

Posted: August 28th, 2016, 2:42 pm
by egizz983
Hello would like to ask how can i load an image(jpg,png,ect) and draw him instead of using that putpixel for 200 times or more to draw something , i mean maybe there is already a tutorial somewhere that i missed , or maybe someone could just tell or made a tutorial on how to do that ?

Re: Loading and Drawing an image

Posted: August 28th, 2016, 4:19 pm
by trybane@gmail.com
Assuming you're using the reboot series, it'll be a little bit before he gets to loading images from jpg, bmp, png and such but if you're in a hurry he goes into it somewhat at the end of the old beginner series. Though in there he helps make a custom bitmap loading class as a good exercise and he shows a real use of class shortly after entering the Intermediate series.

But if you don't want to wade through his older series, you can also take a look at this for some help using gdi+ for images:

https://msdn.microsoft.com/en-us/librar ... s.85).aspx

Try doing some self-research if there's anything you get stuck on. It's good to practice that since Chili won't go over every possible thing you can do with c++. If and when you eventually strike out on your own, you'll need to look up how to do new things that you haven't tried yet. Just my 2 cents.

Re: Loading and Drawing an image

Posted: August 28th, 2016, 4:20 pm
by chili
In the new series, that tutorial is coming (you need to learn about arrays, pointers, strings, and file access before you are able to fully understand loading an image into memory and drawing it). In the old series, those tutorials already exist. You can look at the tutorial index topic on this forum for more details.

Re: Loading and Drawing an image

Posted: August 28th, 2016, 5:41 pm
by egizz983
chili wrote:In the new series, that tutorial is coming (you need to learn about arrays, pointers, strings, and file access before you are able to fully understand loading an image into memory and drawing it). In the old series, those tutorials already exist. You can look at the tutorial index topic on this forum for more details.
i know all basic about c++ i am not a new to programing , arrays,string,pointer,file access ,file reading or writing , class , all loops and so on , i know most of the c++ i just need to learn a methods to do some things , that's why i am still watching your beginners series just to see how you do all stuff , always try to analyze some other scripts just to see how works , i have googled (image loading ) already and i know that its something as a reading a each pixel not sure how to get color code of a pixel and other stuff, so just wait a tutorials of your and will watch old series as well

Re: Loading and Drawing an image

Posted: August 28th, 2016, 6:54 pm
by trybane@gmail.com
Take a look at his Intermediate Lesson 2. He explains bitwise operators and uses them for alpha blending which requires you to retrieve individual color codes of each pixel. Alternatively you could reverse engineer his new framework and see how he gets his color codes that way. That's assuming you understand bitwise operators. Oh and bitshift operators as well.

Re: Loading and Drawing an image

Posted: August 28th, 2016, 10:19 pm
by trybane@gmail.com
After inspecting the new framework for about 10 minutes, I see ways to extract individual colors, and some ways to use the "PutPixel" function without needing to do even that. Try taking a close look at the Graphics class and you'll find what you're looking for.

Re: Loading and Drawing an image

Posted: August 29th, 2016, 5:32 am
by egizz983
okay i will , i haven't analyze his frame work only a part of keyboard and mouse for controls , will check graphics as well

Re: Loading and Drawing an image

Posted: August 29th, 2016, 7:27 am
by chili
Yeah, if you look on the wiki there is some documentation to give you a decent overview of what is in there.

Re: Loading and Drawing an image

Posted: August 29th, 2016, 8:58 am
by albinopapa
If you know all the stuff chili said you need to learn, what part of image loading are you having trouble with?

There are a few different ways to load images, one way requires you know how the image is stored, like a bitmap has a header section that describes the image and then the pixels are stored from the bottom to the top, or more precisely in reverse order.

Another way is to use an API such as GDI+ or the Windows Imaging Component. This allows you to load images without needing to know how the images are stored, because Microsoft has done all that work for you, you just have to learn how to use the APIs.

You can look on msdn.microsoft.com for either gdi+ or windows imaging component and there should be some tutorials on how to use the APIs to load images. That's how I learned how to use the Windows Imaging Component (WIC).

Re: Loading and Drawing an image

Posted: August 29th, 2016, 11:45 am
by egizz983
albinopapa wrote:If you know all the stuff chili said you need to learn, what part of image loading are you having trouble with?

There are a few different ways to load images, one way requires you know how the image is stored, like a bitmap has a header section that describes the image and then the pixels are stored from the bottom to the top, or more precisely in reverse order.

Another way is to use an API such as GDI+ or the Windows Imaging Component. This allows you to load images without needing to know how the images are stored, because Microsoft has done all that work for you, you just have to learn how to use the APIs.

You can look on msdn.microsoft.com for either gdi+ or windows imaging component and there should be some tutorials on how to use the APIs to load images. That's how I learned how to use the Windows Imaging Component (WIC).
i haven't even tried to load yet cuz i dont even have a clue where and how to start so i do not know in what part i will have a problem , till now i was only working with a text files on c++ , but will check that GDI+ stuff and will see how it goes