fix: 空渠道检测改用JSONObject.has + 移除gitignore误排除manifest
This commit is contained in:
74
check_png.py
Normal file
74
check_png.py
Normal file
@@ -0,0 +1,74 @@
|
||||
import sys
|
||||
import io
|
||||
|
||||
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
|
||||
|
||||
with open(r"D:\Yuzu-GCA\screen_fixed.png", 'rb') as f:
|
||||
data = f.read()
|
||||
|
||||
print(f"Total size: {len(data)}")
|
||||
|
||||
# Check PNG structure
|
||||
# Signature: 8 bytes
|
||||
# Then chunks: each chunk has 4-byte length, 4-byte type, data, 4-byte CRC
|
||||
|
||||
offset = 8 # skip signature
|
||||
|
||||
while offset < len(data):
|
||||
if offset + 8 > len(data):
|
||||
break
|
||||
length = int.from_bytes(data[offset:offset+4], 'big')
|
||||
chunk_type = data[offset+4:offset+8].decode('ascii', errors='replace')
|
||||
print(f"Chunk at offset {offset}: type='{chunk_type}', length={length}")
|
||||
|
||||
if chunk_type == 'IHDR':
|
||||
w = int.from_bytes(data[offset+8:offset+12], 'big')
|
||||
h = int.from_bytes(data[offset+12:offset+16], 'big')
|
||||
bit_depth = data[offset+16]
|
||||
color_type = data[offset+17]
|
||||
print(f" Width={w}, Height={h}, BitDepth={bit_depth}, ColorType={color_type}")
|
||||
# Height seems wrong (854591). Expected ~1920 or ~2340
|
||||
# 0x000D0A3F: maybe it was 0x00000780 (1920) or 0x00000924 (2340)?
|
||||
# Let me look at the raw bytes around height
|
||||
print(f" Raw height bytes: {' '.join(f'{b:02X}' for b in data[offset+12:offset+16])}")
|
||||
# Expected height around 1920 = 0x780, or 2340 = 0x924
|
||||
# What we have: 00 0D 0A 3F = 0x000D0A3F
|
||||
# Could it be that 0D 0A is an inserted CR LF?
|
||||
# If we remove 0D 0A: remaining would be 00 3F... but that's only 2 bytes
|
||||
# Actually: 00 [0D 0A] 3F -> 00 3F? That's too short.
|
||||
# Maybe: 00 [0D] 0A 3F, and 0D was inserted? Then original: 00 0A 3F = 2623 pixels?
|
||||
# Or maybe: 00 00 0A 3F was original? No.
|
||||
|
||||
# Let me check: common heights: 1920=0x780, 2000=0x7D0, 2340=0x924
|
||||
# 0x0A3F = 2623 (close to nothing standard)
|
||||
# What if the actual height bytes are 00 00 0A 3F? That's still 2623.
|
||||
# What about 00 00 07 80 (1920)? Then 0D 0A replaced 00 07 somehow?
|
||||
|
||||
offset += 12 + length
|
||||
|
||||
if offset > 200:
|
||||
break
|
||||
|
||||
# Let me search for CR LF (0D 0A) in the PNG data
|
||||
crlf_count = 0
|
||||
for i in range(len(data) - 1):
|
||||
if data[i] == 0x0D and data[i+1] == 0x0A:
|
||||
crlf_count += 1
|
||||
if crlf_count <= 10:
|
||||
print(f"CR LF at offset {i}: context: {' '.join(f'{b:02X}' for b in data[max(0,i-4):i+6])}")
|
||||
|
||||
print(f"\nTotal CR LF sequences: {crlf_count}")
|
||||
|
||||
# Also count lone 0A
|
||||
lone_lf = 0
|
||||
for i in range(len(data)):
|
||||
if data[i] == 0x0A and (i == 0 or data[i-1] != 0x0D):
|
||||
lone_lf += 1
|
||||
print(f"Lone LF: {lone_lf}")
|
||||
|
||||
# Count lone 0D
|
||||
lone_cr = 0
|
||||
for i in range(len(data)):
|
||||
if data[i] == 0x0D and (i == len(data)-1 or data[i+1] != 0x0A):
|
||||
lone_cr += 1
|
||||
print(f"Lone CR: {lone_cr}")
|
||||
Reference in New Issue
Block a user