91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

Apple 對 iPhone 應(yīng)用程序中的 png 圖片進(jìn)行了特殊的處理,在 png 文件頭之后加了一個非標(biāo)準(zhǔn)的 CgBI 數(shù)據(jù)段,IDAT 段圖像數(shù)據(jù)也沒有傳統(tǒng)的壓縮數(shù)據(jù)頭和尾,并且紅色和藍(lán)色是反的,這樣就無法在 Mac 或 Windows 正常使用了。將本python文件放于導(dǎo)出的png文件目錄下,并執(zhí)行python ipin.py,可用將png圖片還原正常。

資源截圖

代碼片段和文件信息

#---
#?iPIN?-?iPhone?PNG?Images?Normalizer?v1.0
#?Copyright?(C)?2007
#
#?Author:
#??Axel?E.?Brzostowski
#??http://www.axelbrz.com.ar/
#??axelbrz@gmail.com
#
#?References:
#??http://iphone.fiveforty.net/wiki/index.php/PNG_Images
#??http://www.libpng.org/pub/png/spec/1.2/PNG-Contents.html
#
#?Changes:
#??2011.6.14.??handle?cases?of?multiple?IDAT?chunks
#
#?This?program?is?free?software:?you?can?redistribute?it?and/or?modify
#?it?under?the?terms?of?the?GNU?General?Public?License?as?published?by
#?the?Free?Software?Foundation?either?version?3?of?the?License.
#
#?This?program?is?distributed?in?the?hope?that?it?will?be?useful
#?but?WITHOUT?ANY?WARRANTY;?without?even?the?implied?warranty?of
#?MERCHANTABILITY?or?FITNESS?FOR?A?PARTICULAR?PURPOSE.??See?the
#?GNU?General?Public?License?for?more?details.
#
#---

from?struct?import?*
from?zlib?import?*
import?stat
import?sys
import?os

def?getNormalizedPNG(filename):
????pngheader?=?“\x89PNG\r\n\x1a\n“
???
????file?=?open(filename?“rb“)
????oldPNG?=?file.read()
????file.close()

????if?oldPNG[:8]?!=?pngheader:
????????return?None
???
????newPNG?=?oldPNG[:8]
???
????chunkPos?=?len(newPNG)
????pendingIDATChunks?=?[]
???
????#?For?each?chunk?in?the?PNG?file
????while?chunkPos????????
????????#?Reading?chunk
????????chunkLength?=?oldPNG[chunkPos:chunkPos+4]
????????chunkLength?=?unpack(“>L“?chunkLength)[0]
????????chunkType?=?oldPNG[chunkPos+4?:?chunkPos+8]
????????chunkData?=?oldPNG[chunkPos+8:chunkPos+8+chunkLength]
????????chunkCRC?=?oldPNG[chunkPos+chunkLength+8:chunkPos+chunkLength+12]
????????chunkCRC?=?unpack(“>L“?chunkCRC)[0]
????????chunkPos?+=?chunkLength?+?12

????????#?Parsing?the?header?chunk
????????if?chunkType?==?“IHDR“:
????????????width?=?unpack(“>L“?chunkData[0:4])[0]
????????????height?=?unpack(“>L“?chunkData[4:8])[0]

????????#?Parsing?the?image?chunk
????????if?chunkType?==?“IDAT“:
????????????try:
????????????????#?Uncompressing?the?image?chunk
????????????????bufSize?=?width?*?height?*?4?+?height
????????????????if?pendingIDATChunks:
????????????????????chunkData?=?decompress(?‘‘.join(pendingIDATChunks)?+?chunkData?-8?bufSize)
????????????????else:
????????????????????chunkData?=?decompress(?chunkData?-8?bufSize)
???????????????
????????????except?Exception?e:
????????????????#?The?PNG?image?is?normalized
????????????????pendingIDATChunks.append(chunkData)
????????????????continue
????????????else:
????????????????pendingIDATChunks?=?[]

????????????#?Swapping?red?&?blue?bytes?for?each?pixel
????????????newdata?=?““
????????????for?y?in?xrange(height):
????????????????i?=?len(newdata)
????????????????newdata?+=?chunkData[i]
????????????????for?x?in?xrange(width):
????????????????????i?=?len(newdata)
?????????????????

評論

共有 條評論

相關(guān)資源