android png idat 还原,png IDAT数据块还原问题
发布日期:2021-06-24 15:44:00 浏览次数:2 分类:技术文章

本文共 1733 字,大约阅读时间需要 5 分钟。

png由于fireworks生成的数再进一步处理,还原出来的数据还要计算下

这两天查遍了互联网,和无数次生成数据手工计算还原,希望找到个规律

从一篇提示想到手工猜测,我用php写了一个模板,枚举了很多种算法。直接显示结果

如果能还原出来跟fireworks看到的值一样说明民成功的。

这里有一个仁兄提问,他说是位运算

我后来发现是加减运算

http://tieba.baidu.com/f?kz=859640399

0818b9ca8b590ca3270a3433284dd417.png

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

转载地址:https://blog.csdn.net/weixin_33613462/article/details/117647465 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:Vue打开动态html页面,vue.js中怎么打开新页面?
下一篇:android 模拟器 启动,android开发之启动模拟器并安装游戏apk

发表评论

最新留言

哈哈,博客排版真的漂亮呢~
[***.90.31.176]2024年04月25日 07时30分17秒

关于作者

    喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!

推荐文章