你好,我使用libpng和c语言将灰度PNG图像转换为原始图像。在该库中,函数png_init_io需要文件指针来读取PNG图像。但是我将PNG图像作为缓冲区传递,是否有其他替代函数可以从PNG图像缓冲区中读取原始图像?请帮帮我。
int read_png(char *file_name,int *outWidth,int *outHeight,unsigned char **outRaw) /* We need to open the file */
{
......
/* Set up the input control if you are using standard C streams */
png_init_io(png_ptr, fp);
......
}
我需要的是这样的
int read_png(unsigned char *pngbuff, int pngbuffleng, int *outWidth,int *outHeight,unsigned char **outRaw) /* We need to open the file */
{
}
pngbuff
缓冲区包含与PNG文件相同的字节吗? - leonbloylibbpg
库(它也使用了png_init_io
函数)- https://stackoverflow.com/questions/53315767/libbpg-how-to-pass-bytes-instead-of-file-path - user924