浏览代码

[bug] fix size of data

Former-commit-id: df0d7ca4e2c13cf34c10b81d7aaf962205f62dbe
pancha 8 年之前
父节点
当前提交
a9ba6a1083
共有 1 个文件被更改,包括 2 次插入2 次删除
  1. 2 2
      include/igl/png/render_to_png.cpp

+ 2 - 2
include/igl/png/render_to_png.cpp

@@ -17,7 +17,7 @@ IGL_INLINE bool igl::png::render_to_png(
   const bool alpha,
   const bool fast)
 {
-  unsigned char * data = new unsigned char[width*height];
+  unsigned char * data = new unsigned char[4*width*height];
   glReadPixels(
     0,
     0,
@@ -35,7 +35,7 @@ IGL_INLINE bool igl::png::render_to_png(
       data[4*(i+j*width)+3] = 255;
     }
   }
-  bool ret = stbi_write_png(png_file.c_str(), width, height, 4, data, width*sizeof(unsigned char));
+  bool ret = stbi_write_png(png_file.c_str(), width, height, 4, data, 4*width*sizeof(unsigned char));
   delete [] data;
   return ret;
 }