我正在尝试使用SDL加载PNG文件,但该程序不起作用,并且此错误出现在控制台中
"libpng警告:iCCP:已知错误的sRGB配置文件"
为什么出现此警告?我该怎么做才能解决这个问题?
使用任何PHP应用程序导致:
dyld: Library not loaded: /usr/local/lib/libpng15.15.dylib
Referenced from: /usr/local/bin/php
Reason: image not found
[1] 4494 trace trap php
Run Code Online (Sandbox Code Playgroud)
我的大多数php应用程序都是使用自制程序安装的,但作曲家除外(使用curl安装)
我尝试删除libpng并用homebrew重新安装无济于事.
接下来是切换到错误消息中所述的最新版本的libpng 1.5:
$ brew info libpng
libpng: stable 1.6.10 (bottled)
http://www.libpng.org/pub/png/libpng.html
/usr/local/Cellar/libpng/1.5.17 (15 files, 1.0M)
Poured from bottle
/usr/local/Cellar/libpng/1.5.18 (15 files, 1.0M)
Poured from bottle
/usr/local/Cellar/libpng/1.6.10 (17 files, 1.3M) *
$ brew switch libpng 1.5.18
Cleaning /usr/local/Cellar/libpng/1.5.17
Cleaning /usr/local/Cellar/libpng/1.5.18
Cleaning /usr/local/Cellar/libpng/1.6.10
16 links created for /usr/local/Cellar/libpng/1.5.18
Run Code Online (Sandbox Code Playgroud)
现在错误已更改为:
dyld: Library not loaded: /usr/local/lib/libpng16.16.dylib
Referenced from: /usr/local/lib/libfreetype.6.dylib
Reason: image not found
[1] …
Run Code Online (Sandbox Code Playgroud) 我刚刚使用VS2008在64位Windows机器上构建了libpng.它libpng.lib
在\ projects\visualc71\Win32_Lib_Release目录中生成一个文件(配置使用的是"LIB Release").
我曾经dumpbin
检查过这个LIB文件:
C:\Temp\libpng-1.4.3>dumpbin projects\visualc71\Win32_LIB_Release\libpng.lib
Microsoft (R) COFF/PE Dumper Version 9.00.30729.01
Copyright (C) Microsoft Corporation. All rights reserved.
Dump of file projects\visualc71\Win32_LIB_Release\libpng.lib
File Type: LIBRARY
Summary
8E4 .debug$S
DF2 .drectve
2BCD .rdata
21165 .text
C:\Temp\libpng-1.4.3>
Run Code Online (Sandbox Code Playgroud)
但是它没有显示LIB文件的体系结构.如何查找给定的LIB文件是为32位还是64位架构构建的?
我想使用ImageMagick保存到无损PNG时达到最大压缩量.我正在批量转换许多PSD.
我尝试了一些东西,但它看起来像我生成的PNG图像不像原始图像那样清晰,尽管我的妻子看不到它.
这些是我正在玩的当前论点:
convert -depth 24 -define png:compression-filter=1 \
-define png:compression-level=9 -define png:compression-strategy=2
Run Code Online (Sandbox Code Playgroud)
根据:http: //www.imagemagick.org/script/command-line-options.php#define
和http://www.w3.org/TR/PNG-Filters.html
这意味着:
根据文档:"有效值为0到4,表示默认,过滤,huffman_only,rle和固定的ZLIB压缩策略.如果您使用的旧zlib不支持Z_RLE(1.2.0之前)或Z_FIXED(之前) 1.2.2.2),值3和4分别使用zlib默认策略."
顺便说一句,我的图像是960x720像素.
(如果我使用默认压缩策略0,我会得到大文件.可能是9的压缩过滤器和0的压缩策略产生较小尺寸的图像,但我仍然不确定它是否是无损的).
问题:
我目前正在使用以下内容将PNG写入文件:
#include <png.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
/* Pixels in this bitmap structure are stored as BGR. */
typedef struct _RGBPixel {
uint8_t blue;
uint8_t green;
uint8_t red;
} RGBPixel;
/* Structure for containing decompressed bitmaps. */
typedef struct _RGBBitmap {
RGBPixel *pixels;
size_t width;
size_t height;
size_t bytewidth;
uint8_t bytes_per_pixel;
} RGBBitmap;
/* Returns pixel of bitmap at given point. */
#define RGBPixelAtPoint(image, x, y) \
*(((image)->pixels) + (((image)->bytewidth * (y)) \
+ ((x) * (image)->bytes_per_pixel)))
/* …
Run Code Online (Sandbox Code Playgroud) 我正在尝试编译一个同时使用libjpeg和libpng的项目.我知道libpng需要zlib,所以我独立编译了所有三个并将它们(libjpeg.a,libpng.a和libz.a)放在一个名为的文件夹中linrel32
.我执行的是:
g++ -Llinrel32/ program.cpp otherfile.cpp -o linrel32/executable -Izlib/ -Ilpng140/ -Ijpeg/ -lpthread -lX11 -O2 -DLINUX -s -lz -lpng -ljpeg
所以我包括了三个库.仍然,链接器抱怨:
linrel32//libpng.a(png.o): In function `png_calculate_crc':
png.c:(.text+0x97d): undefined reference to `crc32'
linrel32//libpng.a(png.o): In function `png_reset_crc':
png.c:(.text+0x9be): undefined reference to `crc32'
linrel32//libpng.a(png.o): In function `png_reset_zstream':
png.c:(.text+0x537): undefined reference to `inflateReset'
linrel32//libpng.a(pngread.o): In function `png_read_destroy':
pngread.c:(.text+0x6f4): undefined reference to `inflateEnd'
linrel32//libpng.a(pngread.o): In function `png_read_row':
pngread.c:(.text+0x1267): undefined reference to `inflate'
linrel32//libpng.a(pngread.o): In function `png_create_read_struct_2':
Run Code Online (Sandbox Code Playgroud)
(...你明白了:D)
collect2: ld returned 1 exit status
Run Code Online (Sandbox Code Playgroud)
我知道缺少的函数来自zlib,我在那里添加了zlib.打开libz.a,似乎有一个很好的结构.重新编译它,一切看起来都很好.但它不是...... …
摘要
我想尽快写一个.png文件,而不用考虑压缩.也就是说,我不太关心文件大小,但我确实关心写入是否尽快发生.
动机
我正在使用客户端的OpenLayers和后端的python/C++创建基于Web的地图应用程序.当用户在地图上移动时,应用程序需要能够快速绘制动态内容.我有基于图块(256x256图块)和单图像("单图块")版本的工作,但在这两种情况下,后端渲染的最慢部分实际上是将图像保存为png文件(无论是否-disk或in-memory).例如,我可以在大约200毫秒内生成某个视图的"原始","tga"或"tiff"版本,但生成.png版本需要更多的时间,因为.png保存需要几乎整整一秒,而实际保存其他格式的时间是100毫秒或更短(即使"原始"文件是.png文件大小的五倍).此文件节省的时间也远远超过将结果图像从服务器传输到客户端的时间.(我的应用程序的一个重要特性是,通常"后端"将与浏览器在同一台机器上运行,因此传输时间可以忽略不计,即使对于大文件也是如此.)
我以为我可以通过调用快速编写.png(在使用C++中的libpng时)
png_set_compression_level( png_ptr, 0 );
Run Code Online (Sandbox Code Playgroud)
在调用任何png_write_...
函数之前.但是,虽然该调用确实似乎阻止了libpng压缩文件(生成的文件大小与.raw文件大小相同),但它并没有使.png的保存速度明显加快.
请帮忙
我需要为这些图像使用.png,因为我需要它们是基本地图顶部的透明叠加层,我需要的不仅仅是GIF提供的256种颜色.OpenLayers只是使用html img标签,所以我的理解是我只能使用有效的img格式.
我认为有一种方法可以通过不进行任何实际压缩来快速编写.png文件(我知道.png是"始终压缩"但我想这可能包括"空压缩").看起来你应该能够编写一个简单的固定标题,然后是未压缩的数据,然后是一些固定的页脚.或者也许是相同的想法,但是以逐行的方式.关键是我可以非常快速地在内存中通过这个2.5 MB的原始数据循环进行各种循环,并且可以非常快速地将其转储到各种文件格式,所以看起来我应该能够将它转储到固定的,未压缩的.png格式也很快.
听起来不错吗?你知道在哪里可以找到代码的例子吗?
我试图在ubuntu 14.04下编译并运行此代码.我下载并安装了libpng 1.6.12版.我能够使用编译代码gcc test.c -lpng
但是当我尝试运行它时,我收到此错误:
./a.out: error while loading shared libraries: libpng16.so.16: cannot open shared object file: No such file or directory
编辑:
所以我找到了libpng16.so.16,它进入/usr/local/lib
并且我将其复制/usr/local/include/libpng16/
到/usr/local/include/
并重新编译代码,无论如何问题仍然存在.
有什么建议 ?
我有一个C#/ .NET实用程序,我写了从磁盘加载PNG图像
Bitmap b = Bitmap.FromStream(new MemoryStream(File.ReadAllBytes(filename))) as Bitmap;
Run Code Online (Sandbox Code Playgroud)
对它们执行多次转换(旋转,缩放,alpha),然后根据应用的转换将生成的PNG图像保存回具有不同文件名的磁盘
b.Save(outputName, ImageFormat.Png);
Run Code Online (Sandbox Code Playgroud)
我已经使用该实用程序成功编写了数千个PNG.但是,偶尔有一个PNG无法加载到使用libpng的单独程序中.在该程序中,libpng给出错误"找到太多IDAT"
查看PNG文件会在IEND块之前的文件末尾显示"流氓"IDAT块.一个这样的IDAT块(以及下面的IEND块)在十六进制编辑器中看起来像这样.这些是文件中的最后24个字节.
IDAT: 0x00 0x00 0xFF 0xF4 0x49 0x44 0x41 0x54 0x35 0xAF 0x06 0x1E
IEND: 0x00 0x00 0x00 0x00 0x49 0x45 0x4e 0x44 0xAE 0x42 0x60 0x82
Run Code Online (Sandbox Code Playgroud)
IDAT块长度显示为0xFFF4.但是,很明显,IDAT块中没有那么多字节(甚至文件也没有.)
还有其他人遇到过这个问题吗?我可以用以下几种方法之一解决问题.我可以手动编辑PNG文件以删除最后一个IDAT块(或将其大小设置为0.)我可以运行修复损坏的PNG的辅助程序.但是,我想要一个C#/ .NET解决方案,我可以轻松地将其添加到我的原始程序中.理想情况下,我想要一个不需要我重新打开PNG作为二进制文件的解决方案; 检查IDAT坏块; 并重写PNG.但是,我开始认为这就是我需要做的.
如何在centos上使用yum安装libpng?
我尝试yum install libpng
但是这不起作用
任何帮助将不胜感激