ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hello guys. I've been coding in java for a bit, did pretty well, and moved back to C. I have a good knowledge of stdio (Contents of the stdio header), and basic text I/O, but what's next? I'm so used to java, and the jdk, coming with graphics, sound, etc etc, for me to hone my skills in, but what about C? And which is the best way to develop one's skills via programming? Which are the best kind of examples? And on a side note, where's a good source for binary file reading? Particularly image files.
The next step depends on what you want to do exactly. If you you want to do some GUI stuff then you probably want to work with a GUI toolkit such as GTK+. As for dealing with binary files, there is a good chance that there is already a library out there for working with them (i.e. libpng for working with png files). Or if you wanted to work at a lower level, you could read the binary files, a byte at a time, and look up the format of the binary file, and interpret it yourself, it's a lot more work, but you would learn a lot more from it as well. I could be wrong, but I think that GTK+ probably has API for interacting with images as well.
The next step depends on what you want to do exactly. If you you want to do some GUI stuff then you probably want to work with a GUI toolkit such as GTK+. As for dealing with binary files, there is a good chance that there is already a library out there for working with them (i.e. libpng for working with png files). Or if you wanted to work at a lower level, you could read the binary files, a byte at a time, and look up the format of the binary file, and interpret it yourself, it's a lot more work, but you would learn a lot more from it as well. I could be wrong, but I think that GTK+ probably has API for interacting with images as well.
Yeah I actually was thinking about that, but I wanted to get into game development. But as for GUI dev, GTK+ was at the top of my list And I seen a bit of libpng, it's nice, but I want to get as low-level as I could possibly with C. Reading each file, byte at a time. Know any good tutorials for that? Like I want to be able to read a .png from the file with just C code.
Quote:
Originally Posted by graemef
For image files you could take a peek at ImageMagik
I actually was trying to avoid that as much as possible, but I will most definitely will be giving it a look-see. As I am trying to dev on consoles (game consoles) down the line. So I don't want to get in the habit of getting used to these convenient libraries. But as I said, I'll give it a look.
If you want to work with binary files you will probably be working with fread and fwrite (see the man pages). The difficult part is knowing how to handle the particular binary format that you are working with. So, for example if you are working with a png file you have could use the information in http://en.wikipedia.org/wiki/Portabl...hnical_details to break apart the different parts of the file. And then of course, for media files like graphics and audio, you often have to worry about uncompressing/compressing the data as well. And you could look at the source code for existing libraries to see how they do it.
And even if you are developping on game consoles, I would still recommend that you use some kind of library to work with graphics and media files if you can, (although you might statically compile the libraries, I don't know that much about game consoles, and I maybe there are libraries specifically for whatever console you are working with).
I say I want to stay away from those libraries, such as ImageMagick, as it is not available on any console I know of (Homebrew or official), and I will, I just want to start off reading binary with C alone, firstly with images. And I am aware that wikipedia will be of great help. But does anyone know a good tutorial that show's the loading of a .bmp file?
BMPs are nice and simple. The last time I did something with them was a long time ago and my startign point was some code from a book which I no longer have and can't recall the title however here is a link that might help.
If you want to be a game programmer, I want to take this opportunity to wish you the best
Google "demoscene" sometime, and check out the Wikipedia page, it's something you should be interested in, and once you have, check out www.pouet.net .
And which is the best way to develop one's skills via programming?
You just answered it. Via programming. The best way to get better at any language is to spend time reading and writing that language.
To be a little more helpful, here's something I like doing.
Find a small project (or large, depending on how much time you have) on SourceForge in C, read through and understand the source code. Then find what the author did wrong, correct his|her mistakes, and maybe add some features recommended in the TODO file. Be sure to send your results to them if you're pleased with it.
Good luck and happy hacking.
Some time ago I wrote a program to load and save BMP images, which you can find here. It supports only basic BMP files, like 8 bits per pixel and no compression, but it is something you can play with. AFAIK using structures is an ubiquitous way to read/write structured binary data, and it is the only trick you should learn to do it yourself easily.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.