Posted 24 August 2013 - 04:15 PM
So, I have this file and I want to read it, the thing is that at 0x000008 - 0x00000B shoudl read 0x0000000D but when I read it I get 0x504E470D, why is this?
glass = peripheral.wrap('left')
function drawPixel(x_, y_, color_)
glass.addBox(x_ + 16, y_ + 16, 1, 1, color_, 1)
end
function readChunk(handle)
length = bit.blshift(handle.read(), 24) + bit.blshift(handle.read(), 16) + bit.blshift(handle.read(), 8) + handle.read()
print(string.format("%X", length))
end
function drawApple()
appleFile = fs.open('apple.png', 'rb')
if appleFile.read() ~= 0x89 and appleFile.read() ~= 0x50 and appleFile.read() ~= 0x4E and appleFile.read() ~= 0x47 and appleFile.read() ~= 0x0D and appleFile.read() ~= 0x0A and appleFile.read() ~= 0x1A and appleFile.read() ~= 0x0A then
print("apple.ong is invalid!")
appleFile.close()
return false
end
readChunk(appleFile)
end
drawApple()