You are not logged in.
Pages: 1
I'm trying to develop a script for loading the contents of a .BMP file into an array, and a script to save them back into a .bmp.
I can load alright, but the file always becomes unusable when I save.
A .zip of the source file and an image is located here.
Does anyone know what I'm doing wrong? Or does anybody have a working script?
NOTE: I know I'm not utilizing a lot of the header data, but I'm just trying to get the basic working before I go further.
Last edited by $pecter (2008-02-25 01:10:33)
Offline
repeat(4)
width+=file_bin_read_byte(file);
For one, that's not how little-endian 32-bit integers work. You can't just add the byte values together. Just like how 1111 doesn't have the value "4". You're completely ignoring place value.
Offline
For one, that's not how little-endian 32-bit integers work. You can't just add the byte values together. Just like how 1111 doesn't have the value "4". You're completely ignoring place value.
Wow, it was some extreme co-incidence that it worked on that image.
Now I'm confused...
So I would do it like this?
repeat(4)
width+=string(file_bin_read_byte(file));
width=bin_to_dec(bytes_to_bin(width));
Offline
More like this for reading a four-byte little-endian word:
// Coded for clarity, not brevity.
b1 = file_bin_read_byte(file);
b2 = file_bin_read_byte(file);
b3 = file_bin_read_byte(file);
b4 = file_bin_read_byte(file);
value = (b4 << 24) | (b3 << 16) | (b2 << 8) | (b1)
You might have better luck using these scripts from Leif902:
http://www.gmlscripts.com/script/file_bin_read_word
http://www.gmlscripts.com/script/file_bin_write_word
Abusing forum power since 1986.
Offline
Thanks xot, that works. I think I better read up on bitwise operations now.
PS. Sorry for the inconvenience of uploading the .gm6 and making you supply your own .bmp. I meant to upload a .zip.
NEW QUESTION
Now, with my previous code, I'm trying to encode some text into the 'unused' alpha 'channel' of the bmp.
I can't get it to save/load (I can't tell)!
This is what I've got so far.
Last edited by $pecter (2008-02-25 05:36:49)
Offline
Pages: 1