Back to programming!
|
So I’ve not been programming much the past few months, and this Monday we got a wake-up call with a sudden contest; we were to make a program that compress an image and then decompress it to it’s original state. I came to the same conclusion as the others within a few minutes after looking at the image, break it down into blocks of identical pixels, check the next pixel with the previous to see if they match. Then count it up until they do not match, and create a block of ”color” and ”amount”. My group struggled to make the program work and compress it (I assisted them and tried to organise the work between them). When it was about 1 hour left, I started doing my own version so that we would have something to show, as it had derailed completely. However, I started too late, and I could only manage to do the compression (and start of the decompression) into a binary file. We managed to compress it to around 6kb. The purpose of the contest was to give us a ”oh, shit” moment of realisation that this is going to get hectic. A point well conveyed as no one managed to do the decompression correctly during the contest. The following day I finished the decompression, by reading the file stream of the compressed file and from that data reorganise the pixels in the same order they came in (first in, first out). The result was the original image decompressed. We also learned about templates, we learned about it’s pros and cons, the pros being that you don’t have to make a struct and or function for each data type (float, int, char, short, long, string etc.), it also won’t make a struct for int if there is no call for it in the program, this happening at compile-time. The cons were the drawback to the previous statement, it happens in compile-time, which means that it has to check all the code for calls to that template, each time you compile. This can greatly increase the time it takes for the program to compile. We were taught about dynamic lists, binary search tree and linked lists this Thursday. However, I was home with an upset stomach and missed the lecture. I feel like I’ve heard it before, but I have to read up on it during the week, I believe one of them is the last in first out principle, but I’m not sure. |