我正在寻找一种解码某些 png 文件的方法,我听说过 libpng,但我不明白它是如何工作的。它将 png 文件转换为 ARGB8888 格式的字节数组还是其他格式?
尝试使用Boost :: GIL PNG IO支持编译我的文件时,我总是遇到此错误:
(我正在运行Mac OS X Leopard和Boost 1.42,LibPNG 1.4)
/usr/local/include/boost/gil/extension/io/png_io_private.hpp: In member function 'void boost::gil::detail::png_reader::init()':
/usr/local/include/boost/gil/extension/io/png_io_private.hpp:155: error: 'png_infopp_NULL' was not declared in this scope
/usr/local/include/boost/gil/extension/io/png_io_private.hpp:160: error: 'png_infopp_NULL' was not declared in this scope
/usr/local/include/boost/gil/extension/io/png_io_private.hpp: In destructor 'boost::gil::detail::png_reader::~png_reader()':
/usr/local/include/boost/gil/extension/io/png_io_private.hpp:174: error: 'png_infopp_NULL' was not declared in this scope
/usr/local/include/boost/gil/extension/io/png_io_private.hpp: In member function 'void boost::gil::detail::png_reader::apply(const View&)':
/usr/local/include/boost/gil/extension/io/png_io_private.hpp:186: error: 'int_p_NULL' was not declared in this scope
/usr/local/include/boost/gil/extension/io/png_io_private.hpp: In member function 'void boost::gil::detail::png_reader_color_convert<CC>::apply(const View&)':
/usr/local/include/boost/gil/extension/io/png_io_private.hpp:228: error: 'int_p_NULL' was not declared in this scope …Run Code Online (Sandbox Code Playgroud) 这是我的功能...我不知道为什么它不起作用。生成的图像看起来与 .png 的样子完全不同。但也没有错误。
bool Bullet::read_png(std::string file_name, int pos)
{
png_structp png_ptr;
png_infop info_ptr;
FILE *fp;
if ((fp = fopen(file_name.c_str(), "rb")) == NULL) {
return false;
}
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (png_ptr == NULL) {
fclose(fp);
return false;
}
info_ptr = png_create_info_struct(png_ptr);
if (info_ptr == NULL) {
fclose(fp);
png_destroy_read_struct(&png_ptr, NULL, NULL);
return false;
}
if (setjmp(png_jmpbuf(png_ptr))) {
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
fclose(fp);
return false;
}
png_init_io(png_ptr, fp);
png_read_png(png_ptr, info_ptr, PNG_TRANSFORM_STRIP_16 | PNG_TRANSFORM_SWAP_ALPHA | PNG_TRANSFORM_EXPAND, NULL);
png_uint_32 width = png_get_image_width(png_ptr, …Run Code Online (Sandbox Code Playgroud) 我正在寻找如何在 C 中使用 libpng 调整图像大小的建议。我已经编写了一个函数,可以从结构中生成 png 图像。我想让我的图像更大:例如 1 像素扩展到 9 像素 (3x3)。有什么功能可以做到这一点吗?
鉴于以下简单项目:
QT += core
QT -= gui
TARGET = ConsoleTest08
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
LIBS += -L/usr/local/lib
Run Code Online (Sandbox Code Playgroud)
使用这个简单的main.cpp文件:
int main(int argc, char *argv[])
{
return 0;
}
Run Code Online (Sandbox Code Playgroud)
从Qt Creator运行时,我有以下错误:
dyld: Symbol not found: __cg_png_create_info_struct
Referenced from: /System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO
Expected in: /usr/local/lib/libPng.dylib
in /System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO
The program has unexpectedly finished.
Run Code Online (Sandbox Code Playgroud)
它从终端运行良好.
这是我的配置:
我刚刚更新到Qt Creator 3.6.0,所以我怀疑是一个错误.
我通过brew安装了libpng …
我是iPhone开发的新手,并尝试使用libpng加载PNG,但在尝试了这么多之后无法将其添加到我的项目中.将libpng添加到项目中时出现以下错误.请帮我解决这些错误:
"_deflateReset",来自......
"_inflateEnd",引自......
"_*inflate",引自......
"_deflate",引自......
" inflateInit ",引自......
"_crc32",引自......
" deflateInit2 ",引自......
"_inflateReset",引自......
"_deflateEnd",引自......
这是Xcode中的错误消息:在检查/Path/image@2x.png pngcrush捕获的alpha时libpng error: Not enough image dCommand /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/copypng emitted errors but did not return a nonzero exit code to indicate failure
但即使出现此错误,应用程序也正常运行.甚至图像也在运行iOS 6.0的iPhone 4上加载
我尝试删除图像并再次添加.还尝试将其保存到预览中的png中.
(在ubuntu下),我尝试:
install.packages("png")
Run Code Online (Sandbox Code Playgroud)
得到:
** testing if installed package can be loaded
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/home/kaveh/R/x86_64-pc-linux-gnu-library/3.2/png/libs/png.so':
libpng16.so.16: cannot open shared object file: No such file or directory
Run Code Online (Sandbox Code Playgroud)
我认为它必须与libpngobselete有关,但我已经使用以下链接从这个链接安装了它:
./configure
make check
make install
Run Code Online (Sandbox Code Playgroud)
所以我真的不知道还能做些什么〜
我一直在尝试使用iconutil从文件夹"folderthumb.iconset"中的.png图像生成.icns图标,使用以下命令:
iconutil -c icns folderthumb.iconset
Run Code Online (Sandbox Code Playgroud)
当源png具有alpha透明度时,一切顺利.但是,当PNG不透明时(来自sips,hasAlpha = no),iconutil会返回错误:
不受欢迎的图像格式
我的libpng是v1.6,安装有brew.
有没有人提出如何解决这个问题的提示?