I'm learning opengl and I'm the kinda guy who likes to write things from scratch and I was searching for how I can read image files data to create my own image importing library to use for textures but I couldn't find anything useful except reading a bmp file. Can you recommend any resources that might help me?

Thanks in advance


What you are looking for is the 'file format'. This is the fancy name you will have to search for when looking up the byte protocols for a file.

For BMP, you can find the info you want here. This is probably denser than you might be used to, so if you want something that you can directly read from then this stack overflow post might be nicer for you.

If you want to get good practice without using any of the above, this might be a great site to practice from since it gives you the higher level stuff for bitmap files succinctly and describes it effectively.

  • \$\begingroup\$ Thank you so much I appreciate all these informations. For the bmp files I have managed to import them, I was talking about other types than bmp like png or jpeg and thank you again I would upvote but I have to have 15 reputation points sorry. \$\endgroup\$ – Tomahawk Apr 21 '17 at 16:17
  • \$\begingroup\$ @Tomahawk png would probably require a library since I recall there being zlib compression. It probably is a much larger challenge than bmp files, and you're best of using a library (but read the file format anyways!) since my guess is that it'd take you a non-trivial amount of time to handle png files. \$\endgroup\$ – Water Apr 21 '17 at 16:21

Not the answer you're looking for? Browse other questions tagged or ask your own question.