#include#include #include #define WIDTH (3) #define HEIGHT (3) int main() { unsigned char **image; // image[HEIGHT][WIDTH]の形式です int i, j; image = (png_bytepp)malloc(HEIGHT * sizeof(png_bytep)); // 以下3行は2次元配列を確保します for (j = 0; j < HEIGHT; j++) image[j] = (png_bytep)malloc(WIDTH * sizeof(png_byte)); for (i = 0; i < WIDTH; i++) { // 以下5行は単純なテストパターンを作ります for (j = 0; j < HEIGHT; j++) { image[j][i] = (unsigned char)i; } } unsigned char *image2; image2 = (png_bytep) malloc( HEIGHT * WIDTH * sizeof(png_byte)); for (i = 0; i < WIDTH; i++) { // 以下5行は単純なテストパターンを作ります for (j = 0; j < HEIGHT; j++) { //printf("%d ", image[j][i]); image2[j * WIDTH + i] = image[j][i]; printf("%d ", image2[j * WIDTH + i]); } } // TODO: write image2 to png stream // http://www.jah.ne.jp/~naoyuki/Writings/MngPng.html return 0; }
Dec 21, 2007
Read and write png files bytes by bytes
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment