C++ rudimentary bitmap image edge detection
I'm just going to rattle off the things I see as I find them.


header.getBytesAhead() should return a void *
pointer_ahead should be a unsigned char const *
small_ahead should be a unsigned char *
Loop x over the pixels (width) not the bytes.
for (unsigned int x = 0; x &lt; width; x += 2)
starting_position = x * 6 + y * ( width * 3 + padding_bytes )
int difference = abs(first_av - second_av)
small_position = x / 8 + y * ( small_width + small_padding_bytes )
small_bit_position = x % 8
small_ahead[ small_position ] |= 3 &lt;&lt; small_bit_position
Use std::vector so header.deleteBytes is unnecessary.


Edit: 


small_position = x / 8 + y * ( ( width + 7 ) / 8 + small_padding_bytes )
To handle an odd width: for (unsigned int x = 0; x + 1 &lt; width; x += 2)