libpng错误:读取错误
我有一些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);
- AFNetworking – 检查域的可达性
- 如何在不同的时间每天重复本地通知
- 如何在iOS(Xamarin C#)游戏中dynamicpopup和隐藏UIPickerView?
- 将textLabel垂直放置在tableView的UITableViewHeaderFooterView中:willDisplayHeaderView:forSection:
- 使用C ++访问iOS上的Documents文件夹
- 在swift中,Self.Type不能直接转换为扩展名为Objective-c类的AnyClass
- ContentView中的button会导致MonoTouch运行时崩溃。 Monotouch 4.0中的错误?
- 使用部分缓冲区将多字节Unicode字节数组转换为NSString
- 如何使用AFNetwork的AFHTTPRequestOperationManager设置HTTP请求正文?