From 16a88c2f24ae69eca9d928171b833186f55b4065 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Sun, 19 Sep 2010 02:09:16 +0200 Subject: cubeit: Better PNG output --- src/cubeit.c | 142 +++++++++++++++++++++++------------------------------------ 1 file changed, 56 insertions(+), 86 deletions(-) diff --git a/src/cubeit.c b/src/cubeit.c index 977cf18f..84005500 100644 --- a/src/cubeit.c +++ b/src/cubeit.c @@ -312,116 +312,62 @@ static void *worker_thread(void *pargsv) static void write_slice(const char *filename, double *vals, int z, - int xs, int ys, int zs, double boost) + int xs, int ys, int zs, double boost, + double as, double bs, double ang) { -#ifdef HAVE_LIBPNG - FILE *fh; - png_structp png_ptr; - png_infop info_ptr; - png_bytep *row_pointers; int x, y, zf; float max = 0.0; + int zoom = 16; + double s = zoom * 1000.0 / 1e9; + cairo_surface_t *surface; + cairo_t *c; int w, h; - int pw, ph; - int zoom = 32; - pw = xs * zoom; - ph = ys * zoom; - w = xs; - h = ys; + w = xs; h = ys; + /* Find maximum value */ for ( zf=0; zf max ) max = val; - - } } } - - fh = fopen(filename, "wb"); - if ( !fh ) { - ERROR("Couldn't open output file.\n"); - return; } - png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, - NULL, NULL, NULL); - if ( !png_ptr ) { - ERROR("Couldn't create PNG write structure.\n"); - fclose(fh); - return; - } - info_ptr = png_create_info_struct(png_ptr); - if ( !info_ptr ) { - png_destroy_write_struct(&png_ptr, (png_infopp)NULL); - ERROR("Couldn't create PNG info structure.\n"); - fclose(fh); - return; - } - if ( setjmp(png_jmpbuf(png_ptr)) ) { - png_destroy_write_struct(&png_ptr, &info_ptr); - fclose(fh); - ERROR("PNG write failed.\n"); - return; - } - png_init_io(png_ptr, fh); - - png_set_IHDR(png_ptr, info_ptr, pw, ph, 8, - PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, - PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); - - row_pointers = malloc(ph*sizeof(png_bytep *)); - - /* Write the image data */ max /= boost; - if ( max <= 6 ) { max = 10; } - for ( y=0; y