2012-05-08 43 views
6
png_read_info (png_ptr, info_ptr); 
{ 
    png_byte color_type = info_ptr->color_type; 
    png_byte bit_depth = info_ptr->bit_depth; 
    ... 

對於最後兩行,我得到了libpng 1.5.10錯誤:提領指向不完全類型

error: dereferencing pointer to incomplete type

有什麼不對?在libpng 1.4中,這總是好的。

+1

這意味着您還沒有正確的頭。包括 – Shahbaz

+1

@Shahbaz'png.h'。 '-I/usr/include/libpng15'存在。 – askovpen

回答

17

png_info結構是從1.5.0的png.h刪除,現在你應該使用這個指針與png_get_*png_set_*功能。

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..

例如:

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

不存在函數'png_get_width','png_get_height'。如何獲得'info_ptr-> height','info_ptr-> width'? – askovpen

+0

它具有匹配的功能,請參閱編輯 – MByD