One of my favorites was probably when I created a function that would save a 256 color image to disk in PCX format, with compressing... Using PowerBasic for DOS, which doesn't natively support a 256 color mode in the first place.
...Especially when being able to succesfully open the resulting image in a 3rd party paint program without errors.
...Especially when being able to succesfully open the resulting image in a 3rd party paint program without errors.