Initial commit
This commit is contained in:
commit
d5c932d8e1
710 changed files with 50282 additions and 0 deletions
40
.tmp_axprobe/diff3.swift
Executable file
40
.tmp_axprobe/diff3.swift
Executable file
|
|
@ -0,0 +1,40 @@
|
|||
import Foundation
|
||||
func load(_ path: String) -> (Data, Int, Int, Int, Int) {
|
||||
let d = try! Data(contentsOf: URL(fileURLWithPath: path))
|
||||
let pixOff = Int(d.withUnsafeBytes { $0.load(fromByteOffset: 10, as: UInt32.self) })
|
||||
let w = Int(d.withUnsafeBytes { $0.load(fromByteOffset: 18, as: Int32.self) })
|
||||
let hRaw = Int(d.withUnsafeBytes { $0.load(fromByteOffset: 22, as: Int32.self) }); let h = abs(hRaw)
|
||||
let B = Int(d.withUnsafeBytes { $0.load(fromByteOffset: 28, as: UInt16.self) })/8
|
||||
let rb = (B*w+3) & ~3
|
||||
return (d, pixOff, w, h, hRaw > 0 ? 1 : 0) // 1 = bottom-up
|
||||
}
|
||||
let (A, poA, w, h, flipA) = load("new.bmp")
|
||||
let (B2, poB, _, _, flipB) = load("after3.bmp")
|
||||
let rb = (4*w+3) & ~3
|
||||
let BS = 45
|
||||
var blocks: [(Int,Int,Int)] = []
|
||||
var y = 0
|
||||
while y < h { var x = 0
|
||||
while x < w {
|
||||
var diff = 0
|
||||
var yy = y; while yy < min(y+BS, h) {
|
||||
let ra = poA + (flipA==1 ? (h-1-yy) : yy) * rb
|
||||
let rb2 = poB + (flipB==1 ? (h-1-yy) : yy) * rb
|
||||
var xx = x; while xx < min(x+BS, w) {
|
||||
let ia = ra + xx*4, ib = rb2 + xx*4
|
||||
let dr = abs(Int(A[ia+2]) - Int(B2[ib+2]))
|
||||
let dg = abs(Int(A[ia+1]) - Int(B2[ib+1]))
|
||||
let db = abs(Int(A[ia]) - Int(B2[ib]))
|
||||
if dr+dg+db > 60 { diff += 1 }
|
||||
xx += 2
|
||||
}
|
||||
yy += 2
|
||||
}
|
||||
if diff > 8 { blocks.append((x,y,diff)) }
|
||||
x += BS
|
||||
}
|
||||
y += BS
|
||||
}
|
||||
print("changed blocks (x,y,diffPx):")
|
||||
for b in blocks { print(" x=\(b.0)-\(b.0+BS) y=\(b.1)-\(b.1+BS) px=\(b.2)") }
|
||||
if blocks.isEmpty { print(" none") }
|
||||
Loading…
Reference in a new issue