I don't see you defining all of the bi2 fields. For example: bf.bfType, bf.bfOffBits, bi.biSize, bi.biBitCount, bi.biCompression. There may be more.
Why don't you try to generate an output images...