First 32 bytes of the TGA
Code:
000000 00 00 02 00 00 00 00 00 00 00 00 00 56 05 00 03
000010 20 08 11 0f 15 ff 13 12 18 ff 13 13 19 ff 14 15
0 image ID len
0 color map type (none)
2 image type (uncompressed RGB)
no color map
0 x origin
0 y origin
0x556 width
0x300 height
0x20 bpp (32 bit)
0x08 descriptor (8 bit attribute, origin in lower left, non-interleaved)
pixel data for the lower left is (11 0F 15 FF), in BGRA order
Somehow your parse is stuffing the alpha value into your green channel.
You really should look into using structs, rather than that sea of magic numbers. I think your bug is the + 18 in line 35 of tga.c, which seems to be trying to skip past the header, but m already includes that. Thus your parse code is starting 4.5 pixels into the array, which being BGRA, means your packing code is seeing RABG, albeit from two different pixels each time.