Creating a .png file
by piobair from LinuxQuestions.org on (#56ZDK)
I have a machine generated bitmapped image. Writing that image to an X-Windows screen is a lot more complicated than writing it to a *.png file. Or so I thought.
The attached program (teapots.c) generates an OpenGL image of teapots. Then, if the 'p' key is pressed, it calls subroutine "png.c" which writes that image to a file teapots.png . The <exc> key exits the program normally. (rename teapots.c.txt to teapots.c; rename png.c.txt to png.c)
The resulting file can be read by a common image reader; the reader does not hiccup over the CRC computation. However, that image is blank.
??
The program can be compiled by
gcc -o teapots teapots.c -lglut -lGL
Attached Files


The attached program (teapots.c) generates an OpenGL image of teapots. Then, if the 'p' key is pressed, it calls subroutine "png.c" which writes that image to a file teapots.png . The <exc> key exits the program normally. (rename teapots.c.txt to teapots.c; rename png.c.txt to png.c)
The resulting file can be read by a common image reader; the reader does not hiccup over the CRC computation. However, that image is blank.
??
The program can be compiled by
gcc -o teapots teapots.c -lglut -lGL
Attached Files
![]() | teapots.c.txt (7.7 KB) |
![]() | png.c.txt (4.5 KB) |