Loading and Drawing an image

The Partridge Family were neither partridges nor a family. Discuss.
egizz983
Posts: 311
Joined: August 27th, 2016, 12:30 pm

Loading and Drawing an image

Post by egizz983 » August 28th, 2016, 2:42 pm

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 ?

trybane@gmail.com
Posts: 109
Joined: August 11th, 2016, 11:17 am

Re: Loading and Drawing an image

Post by trybane@gmail.com » August 28th, 2016, 4:19 pm

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.

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: Loading and Drawing an image

Post by chili » August 28th, 2016, 4:20 pm

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.
Chili

egizz983
Posts: 311
Joined: August 27th, 2016, 12:30 pm

Re: Loading and Drawing an image

Post by egizz983 » August 28th, 2016, 5:41 pm

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

trybane@gmail.com
Posts: 109
Joined: August 11th, 2016, 11:17 am

Re: Loading and Drawing an image

Post by trybane@gmail.com » August 28th, 2016, 6:54 pm

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.

trybane@gmail.com
Posts: 109
Joined: August 11th, 2016, 11:17 am

Re: Loading and Drawing an image

Post by trybane@gmail.com » August 28th, 2016, 10:19 pm

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.

egizz983
Posts: 311
Joined: August 27th, 2016, 12:30 pm

Re: Loading and Drawing an image

Post by egizz983 » August 29th, 2016, 5:32 am

okay i will , i haven't analyze his frame work only a part of keyboard and mouse for controls , will check graphics as well

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: Loading and Drawing an image

Post by chili » August 29th, 2016, 7:27 am

Yeah, if you look on the wiki there is some documentation to give you a decent overview of what is in there.
Chili

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Loading and Drawing an image

Post by albinopapa » August 29th, 2016, 8:58 am

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).
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

egizz983
Posts: 311
Joined: August 27th, 2016, 12:30 pm

Re: Loading and Drawing an image

Post by egizz983 » August 29th, 2016, 11:45 am

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

Post Reply