📄 readimage.c
字号:
#include <stdio.h>#include <stdlib.h>#include <GL/gl.h>GLubyte*readImage( const char* filename, GLsizei* width, GLsizei *height ){ int n; GLubyte* pixels; FILE* infile = fopen( filename, "rb" ); if ( !infile ) { fprintf( stderr, "Unable to open file '%s'\n", filename ); return NULL; } fread( width, sizeof( GLsizei ), 1, infile ); fread( height, sizeof( GLsizei ), 1, infile ); n = 3 * (*width) * (*height); pixels = (GLubyte *) malloc( n * sizeof( GLubyte )); if ( !pixels ) { fprintf( stderr, "Unable to malloc() bytes for pixels\n" ); return NULL; } fread( pixels, sizeof( GLubyte ), n, infile ); fclose( infile ); return pixels;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -