This pretends that you have a FILE* open to some image already, and that the image is tiny (less than 4k bytes).
char buffer[4096]; int length; length = fread( buffer, 1, 4096, some_file ); Image image = DecodeMemoryToImage( buffer, length ); if( image ) { // buffer decoded okay. }