Skip to content

Instantly share code, notes, and snippets.

@hotchpotch
Created December 12, 2013 11:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hotchpotch/7926427 to your computer and use it in GitHub Desktop.
Save hotchpotch/7926427 to your computer and use it in GitHub Desktop.
glitch in RubyMotion (memo)
def glitchnize(image_data)
bytes = image_data.bytes
length = image_data.length
d = Pointer.new(:uchar, length)
length.times do |i|
c = bytes[i]
if c == 42 && rand > 0.8
d[i] = rand(255)
else
d[i] = c
end
end
NSData.dataWithBytes(d, length: length)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment