Subversion Repositories RepoView

Rev

Rev 28 | Rev 34 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 28 Rev 29
Line 1... Line 1...
1
/* $Id: avatar.c 28 2024-08-21 17:37:09Z nishi $ */
1
/* $Id: avatar.c 29 2024-08-21 19:23:54Z nishi $ */
2
 
2
 
3
#include "rv_avatar.h"
3
#include "rv_avatar.h"
-
 
4
 
-
 
5
#include <stdio.h>
-
 
6
#include <stdlib.h>
-
 
7
 
-
 
8
#include <png.h>
-
 
9
 
-
 
10
void rv_avatar_generate(const char* name) {
-
 
11
	FILE* f = fopen(name, "wb");
-
 
12
 
-
 
13
	if(f == NULL) return;
-
 
14
 
-
 
15
	png_structp pngp = NULL;
-
 
16
	png_infop infop = NULL;
-
 
17
	png_bytep row = NULL;
-
 
18
 
-
 
19
	pngp = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
-
 
20
	infop = png_create_info_struct(pngp);
-
 
21
 
-
 
22
	if(setjmp(png_jmpbuf(pngp))) {
-
 
23
		goto closeall;
-
 
24
	}
-
 
25
 
-
 
26
closeall:
-
 
27
	fclose(f);
-
 
28
	if(infop != NULL) png_free_data(pngp, infop, PNG_FREE_ALL, -1);
-
 
29
	if(pngp != NULL) png_destroy_write_struct(&pngp, (png_infopp)NULL);
-
 
30
	if(row != NULL) free(row);
-
 
31
}