Created
July 7, 2020 18:11
-
-
Save Vindaar/3011943acb6fc479f9cf92db02590f91 to your computer and use it in GitHub Desktop.
Toying around with the garbled frames in the Halo 3 trailer for MCC on PC
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import nimPNG, sequtils, strutils, os, cligen | |
const startY = 257 | |
const shiftWidth = 78 | |
const shiftHeight = 9 | |
const switch = 548 | |
proc main(input: string, | |
output: string, | |
start = startY, | |
shiftY = shiftHeight, | |
shiftX = shiftWidth, | |
reverse = switch) = | |
let | |
pattern = loadPng24(input) | |
width = pattern.width | |
height = pattern.height | |
var data = pattern.data | |
template shift(a, b, x, y, w, s: untyped): untyped = | |
let frm = y * w * 3 + x | |
let to = frm - s | |
b[to] = a[frm] | |
b[to + 1] = a[frm + 1] | |
b[to + 2] = a[frm + 2] | |
for y in start ..< height: | |
for x in 0 .. (width * 3 - 3): | |
let row = (y - start) div shiftY | |
let toLeft = row * (shiftX * 3) | |
if y < reverse: | |
shift(pattern.data, data, x, y, width, toLeft) | |
else: | |
shift(pattern.data, data, x, y, width, -toLeft) | |
echo savePNG24(output, data, width, height) | |
when isMainModule: | |
dispatch main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment