[Gridflow-cvs] [svn] commit: r5526 - /trunk/src/png.cxx

svn-gridflow at artengine.ca svn-gridflow at artengine.ca
Mon Apr 26 00:06:32 EDT 2010


Author: matju
Date: Mon Apr 26 00:06:31 2010
New Revision: 5526

Log:
can write png (rgb only)

Modified:
    trunk/src/png.cxx

Modified: trunk/src/png.cxx
==============================================================================
--- trunk/src/png.cxx (original)
+++ trunk/src/png.cxx Mon Apr 26 00:06:31 2010
@@ -52,38 +52,45 @@
 	if (!png) RAISE("!png");
 	info = png_create_info_struct(png);
 	if (!info) {if (png) png_destroy_write_struct(&png, NULL); RAISE("!info");}
-	if (setjmp(png_jmpbuf(png))) {png_destroy_write_struct(&png, &info);     RAISE("png write error");}
-  if (setjmp(png->jmpbuf)) {png_write_destroy(png); free(png); free(info); RAISE("png write error");}
-  png_init_io(png, f);
-  info->width  = in->dim->get(1);
-  info->height = in->dim->get(0);
-  info->bit_depth = 8;
-//  info->color_type = channels==3 ?  PNG_COLOR_TYPE_RGB : PNG_COLOR_TYPE_GRAY;
-  info->color_type = PNG_COLOR_TYPE_RGB;
-//    info->color_type |= PNG_COLOR_MASK_ALPHA;
-  info->interlace_type = 1;
-  png_write_info(png,info);
+	if (setjmp(png->jmpbuf)) {png_destroy_write_struct(&png, &info);         RAISE("png write error");}
+	//if (setjmp(png->jmpbuf)) {png_write_destroy(png); free(png); free(info); RAISE("png write error");}
+	png_init_io(png, f);
+	//info->width  = in->dim->get(1);
+	//info->height = in->dim->get(0);
+	//info->bit_depth = 8;
+	//info->rowbytes = in->dim->prod(1);
+	//info->channels = 3;
+	//info->depth = 3;
+	// info->color_type = channels==3 ?  PNG_COLOR_TYPE_RGB : PNG_COLOR_TYPE_GRAY;
+	//info->color_type = PNG_COLOR_TYPE_RGB;
+	// info->color_type |= PNG_COLOR_MASK_ALPHA;
+	//info->interlace_type = 1;
+
+	png_set_IHDR(png,info,in->dim->v[1],in->dim->v[0],8,
+                 PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
+
+	png_write_info(png,info);
 	png_set_packing(png);
 // this would have been the GRID_FLOW section
-  int rowsize = in->dim->get(1)*in->dim->get(2);
+	int rowsize = in->dim->get(1)*in->dim->get(2);
 	int rowsize2 = in->dim->get(1)*3;
 	uint8 row[rowsize2];
 	while (n) {
-	  post("n=%ld",long(n));
+		post("n=%ld n/1800=%f",long(n),n/1800.0);
 		bit_packing->pack(in->dim->get(1),data,row);
 		png_write_row(png,row);
 		n-=rowsize; data+=rowsize;
 	}
 // this would have been the GRID_FINISH section
-  post("GRID FINISH 1");
-  png_write_end(png,info);
-  post("GRID FINISH 2");
-  png_write_destroy(png);
-  post("GRID FINISH 3");
-  fflush(f);
-  free(png);
-  free(info);
-  //fclose(f);
+	post("GRID FINISH 1");
+	png_write_end(png,info);
+	post("GRID FINISH 2");
+	png_write_destroy(png);
+	post("GRID FINISH 3");
+	fflush(f);
+	free(png);
+	free(info);
+	//fclose(f);
 } GRID_FINISH {
 } GRID_END
 



More information about the Gridflow-cvs mailing list