Breaking a picture into pixels

Hi i'm pretty new to C++, I've read tutorials and books which all only taught me the usual Hello World to Object Oriented programming, now with the knowledge i got from them i can't come up with anything useful to program.

I thought of making some kind of picture editing program that takes a picture (JPEG/GIF/whatever) and breaks it into pixels so that you could for example make it darker or whatever, the question i have is:

Where do i start if i want to make a useful program? what do i use to get useful jobs done?

Are there libraries or something that does this stuff?


Irrelevant question: are there any tutorial on how to use data files? files that are not .txt to store data. all i've learned this far is to store data in a .txt file but its neither secure nor practical or flexible.
Last edited on
Essentially, image formats come in two flavors : compressed and uncompressed (raw). The same can be said about audio formats.

As you might suspect, image formats which 'compress' have a smaller file size footprint at the cost of image quality. You'll end up with a more or less decent approximation of the original image. An example of this would be the .jpg format.
It's important to note that the .png (Portable Network Graphics) format supports lossless compression. It reduces the file size without a loss of quality.

It follows that uncompressed image formats represent the original image in full detail without any loss in quality. One example would be .bmp (bitmap), which also happens to be the format I recommend you start exploring to get familiar with the world of image processing.

Before I go into bitmaps, let's briefly address what all image formats have in common.
Their common attribute is that they are files. What I mean is, that each different format has different and unique headers and structures contained within. This means that when we plan to write a program that modifies image data, we need to know which formats we're dealing with and how their headers and structures are presented in order to parse them correctly. This, again, is also true for audio formats.

Here's an example to think about: Say you open wordpad and write "Hello World!". You decide that you want to save your magnum opus in .txt format , as well as in .rtf (rich text format). Two different files with different extensions, with the same content (apparently). However, the files are of different sizes! How can that be? .txt has no headers or structures, which means the file size is purely affected by how many characters were in the string and whether they're in UNICODE or ANSI.
The .rtf file will be larger than the .txt, because it has been saved with rtf headers. When you open an .rtf file in wordpad, the application has been programmed with an .rtf support case to correctly read the headers (which might be responsible for formatting or other eye candy).

Any such file which is partially un-readable to human eyes is considered to be a 'binary file'. These files are typically created by other applications to be opened later on by another application (or the same one) which can interpret the headers correctly.

So, my challenge to you is this:
http://easybmp.sourceforge.net/
download and link the easybmp library.

Download the ColorToGrey(grayscale) example
http://easybmp.sourceforge.net/samples.html

Finally, write an "ASCII art generator", an application which takes a .bmp as a command line argument, and writes a .txt file filled with characters to represent the image. The example above shows how to load a bitmap, how to check if it is a proper/expected bitmap format, how to iterate through the pixels of the image and to effectively apply a grayscale filter. Based on the grayscale value of each pixel, write one hardcoded character representing that particular shade of gray to your .txt file.

EDIT* I'll be checking frequently, so if something is troubling or if I was vague, just say so.
Last edited on
Topic archived. No new replies allowed.