This is present in all GUI_BMPFiles. It causes a segfault. You don't need to multiply the index by 4, C takes care of this for you already. The previous code will write beyond the bounds of the array.