libpng 错误:读取错误
libpng error: Read Error
我有一些png图像。我打开它。比我把它保存到文件。当我尝试打开保存的图像时,我遇到了问题。libpng 错误:png_read_rows
上读取错误
下面是编写代码:
png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
png_infop info_ptr = png_create_info_struct(png_ptr);
//created png struct
setjmp(png_jmpbuf(png_ptr))
//signed
png_init_io(png_ptr, file);
png_set_IHDR(png_ptr, info_ptr, width, height, 8, PNG_COLOR_TYPE_RGBA, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
//set header
unsigned char * buffer = (unsigned char*)malloc(4 *width * height);
// created buffer
unsigned char ** row_pointers = (unsigned char**) malloc(height * sizeof(unsigned char *)); // created rows pointers
for (int i= 0; i< height ; i++) {
row_pointers[i] = buffer + i * 4 * width;
}
memset(buffer, 255, 4 * height * width); // fill buffer with white image for example.
// **I mean that the same problem is even when i do not write the opened image,
//but just fill it with white**.
png_write_image(png_ptr, row_pointers);
//write data
png_write_end(png_ptr, NULL);
png_destroy_write_struct(&png_ptr, (png_infopp)NULL);
如 libpng/example.c 所示,将其放在 png_set_IHDR() 之后:
// Write the file header information. REQUIRED
png_write_info(png_ptr, info_ptr);
相关文章:
- 分段错误 - 读取初始化指针的数组
- 在指向函数中读取变量时出现分割错误
- 读取某些文件时出现分段错误,似乎与文件大小无关
- 从对象C++中的文件读取内容时出现分段错误
- 我编写了以下代码来读取C++矩阵,然后打印其行和列.我收到此错误
- 可能的 ComputeCPP SYCL 错误读取嵌套缓冲区
- Eigen SparseLU解决错误读取访问冲突,这>m_sup_to_col被0x111011101110112
- 访问违规读取位置和错误读取字符串的错误
- libpng 错误:读取错误
- 错误读取字符到矩阵
- 分段错误读取 JSON 文件
- 斯特托克获取分段错误读取文件
- ifstream 初始化错误 - 读取字符时出错
- 读取错误-读取时无限
- 异常错误:读取位置0xDDDDDDDD时发生访问冲突
- 如何修复此错误读取位置0x00000008时发生访问冲突
- GDB:<错误读取变量>,带有 C++ 向量
- 找不到错误 读取大小 4 瓦尔格林德无效
- 分割错误读取文件
- libpng错误:读取错误(Visual Studio 2010)