libpng 1.5.10 error: dereferencing pointer to incomplete type

孤街浪徒 提交于 2019-12-01 03:06:40

问题


png_read_info (png_ptr, info_ptr);
{ 
    png_byte color_type = info_ptr->color_type;
    png_byte bit_depth  = info_ptr->bit_depth;
    ...

For last 2 lines I get

error: dereferencing pointer to incomplete type

What's wrong? In libpng 1.4 this was always ok.


回答1:


The png_info struct was removed from the png.h in 1.5.0 and now you should use this pointer with the png_get_* and png_set_* functions.

As specified in libpng manual:

The png_info structure is designed to provide information about the PNG file. At one time, the fields of png_info were intended to be directly accessible to the user. However, this tended to cause problems with applications using dynamically loaded libraries, and as a result a set of interface functions for png_info (the png_get_*() and png_set_*() functions) was developed, and direct access to the png_info fields was deprecated..

For example:

png_uint_32 height;
height = png_get_image_height( png_ptr,  info_ptr);



回答2:


If you are trying to set contents of info_ptr which is no longer directly accessible, use png_set_IHDR()

As specified in libpng manual



来源:https://stackoverflow.com/questions/10507610/libpng-1-5-10-error-dereferencing-pointer-to-incomplete-type

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!