fread( data, 1, width * height * 3, file ); fclose( file );
Here's your problem, you can't read directly from a png file, it's compressed. You need to decompress it first in order to get any useful data. I would recommend using an image loading library like FreeImage or SOIL.
thanks icOde.
i wonder whether it is compatible with msvc 2010 c++? i tried to load the sln file into vc 2010, but it failed.