png由于fireworks生成的数再进一步处理,还原出来的数据还要计算下
这两天查遍了互联网,和无数次生成数据手工计算还原,希望找到个规律
从一篇提示想到手工猜测,我用php写了一个模板,枚举了很多种算法。直接显示结果
如果能还原出来跟fireworks看到的值一样说明民成功的。
这里有一个仁兄提问,他说是位运算
我后来发现是加减运算
http://tieba.baidu.com/f?kz=859640399
01 就是后面一个RGBA加上前边一个RGBA
02 就是下面原始数据加上上面解码出来的RGBA
04 在下面有说明
03 是前边一个字节加上上边对应一个字节然后除2 然后加上本字节 比如(前R+上R)/2+R(本字节R)
这个适合真彩情况,window画图生成的png并没有编码,直接放RRGGBBAA
我推理了一天才发现03这种情况 所以如果png IDAT 遇到真彩解码或编码问题可以多试下
行头为04数据格式
00
C
B
04
A
X
Type byte
Filter name
Predicted value
0
None
Zero (so that the raw byte value passes through unaltered)
1
Sub
Byte A (to the left)
2
Up
Byte B (above)
3
Average
Mean of bytes A and B, rounded down
4
Paeth
A, B, or C, whichever is closest to p = A + B − C
Table 1. Predictor states used for differential encoding in the PNG image format.
The Paeth filter computes a simple linear function of the three neighboring pixels (a, b, c), then
chooses as predictor the neighboring pixel closest to the computed value as defined by the
following pseudo-code:
// Input: color values a,b, and c as illustrated in Figure 3
// a = left, b = above, c = upper left
// Output: a paeth-prediction for a,b, and c
04方式求出X的伪代码
paeth_predict(a,b,c)
p := a+b-c
pa := abs(p-a)
pb := abs(p-b)
pc := abs(p-c)
IF (pa<=pb AND pa<=pc) p := a
ELSE IF (pb <= pc) p := b
ELSE p := c
paeth_predict := p
Compression of a pixel value x dependent on its neighbors a,b, and c works by calculating
compressed(x) = x - paeth_predict(a,b,c)
and decompression works by reversing the formula to
uncompressed(x) = compressed(x) + paeth_predict(a,b,c).
http://en.wikipedia.org/wiki/Portable_Network_Graphics
http://ngs.ics.uci.edu/teaching/winter2011/Multimedia/textbook/MM_Chapter_lossycomp_100220.pdf
具体看下面这里
http://www.w3.org/TR/PNG/#9Filters