Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Remember reading this article in 2015 and then trying to do some simple glitching using C.

Simply inserting an additional NULL for a specific RGB range will cause all channels written after it to become misaligned and will create quite an interesting output image (similar to figure B.14 in the article). I.e. an R component will be written into G's place, G will be written into B's place etc..

It goes along these lines:

    for (int i = 0; i < imgHeight; i++) {
        for (int j = 0; j < imgWidth; j++) {
            RGBTRIPLE triple;
            fread(&triple, sizeof(RGBTRIPLE), 1, inptr);
            if (triple.rgbtRed == 0xa4 && triple.rgbtGreen == 0x90 && triple.rgbtBlue < 0x77) {
                fwrite(&triple, 4, 1, outptr); // an additional NULL is written to ouput
            } else {
                fwrite(&triple, 3, 1, outptr);
            }
        }
    }


> Remember reading this article in 2015 and then trying to do some simple glitching using C.

And I just realized I meant to play with it "when I got some free time"... three years ago :/


I also have the link buried under an equivalent named 'h4x0r later' folder in my bookmarks since 2015. There are so many interesting things I'll never manage to play with in my lifetime, that I apparently have "postponed".

It's great others document and share their entertaining results to lazy lads like me :)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: