Share your repls and programming experiences

← Back to all posts
PPM Image Library
AaronSpeedy (0)

For a raycasting project that I'm working on I needed a way to edit images. I could've used an existing library, but I developed this garbage instead. Enjoy!

The basic functions are ~>
~ createData(int X, int Y, std::vector<float> color) - This just creates an image with the specified dimensions and color
~ setPixel(int x, int y) / (std::vector<int>) - Sets the specified pixel to a certain color. Pixel can be a vector or an index.
~ saveData(std::string name) - Used to save and write the data to the ppm file.

There are also a few more to get data from the object like getSize() or getWidth() / getHeight(), but those are fairly self explanatory.
I wouldn't suggest using ppm files as they are uncompressed, meaning that they can get really large really quickly. They also aren't supported by many platforms.

If you have any improvements or suggestions for me please feel free to tell me or add them yourselves. Anyone is free to use this, I do not care. Hope you enjoy!