c语言读取png文件大小,求助: C语言- 利用libpng读取png大小,并转换为jpg类型图片...

大家好,

最近研究C语言图像处理这方面遇到一个难题,详情如下:

目标: 将png类型图片的信息读入内存,提取所需要的数据并保存,然后转换为如jpg等其它图片格式。

1. libpng库已经装好,通过makefile调用库文件路径也正确。

2. 写了一个读取函数, 如下:

#include 

#include 

#include 

#include 

#include 

#include 

#include "png.h"

#include "pngio.h"

#include "error.h"

#include "image.h"

/*==============================================================================*

*  read_png                                                    *

*==============================================================================*/

int x, y;

int width, height;

int channels;

png_byte color_type;

png_byte bit_depth;

png_structp png_ptr;

png_infop info_ptr;

int number_of_passes;

png_bytep *row_pointers;

png_uint_32 w, h;

size_t npixels;

//png_uint_32* raster;

//png_uint_32

int read_png (char * input_filename, picture *thePicture, FILE *status_log)

{

int err = no_err;

char header[8];    // 8 is the maximum size that can be checked

/* open file and test for it being a png */

FILE *fp = fopen(input_filename, "rb");

if (fp

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值