Well for images I can try, though I am far from the best person to ask.
Memblocks are BLOCKS stored in MEMory that can be referenced quickly.
Using the command MAKE MEMBLOCK FROM IMAGE, you can do just that, load an image into memory for editing on its most basic level.
There are 4 types of data to be read/written from/to a memblock:
BYTE-1 byte
WORD-2 bytes
DWORD-4 bytes
FLOAT-4 bytes
A byte will be a number between 0 and 255
Words will be between 0 and 65535
DWords will be between 0 and 2147483648
Floats will be between -2147483648 and 2147483648
When an image resolution is 16 bit, each pixel will be 2 bytes. For 32 (which I have had more luck making work) it uses 4 bytes (DWORD).
For the rest of this, I will assume we are working in 32 bit depth, since it works a little nicer.
There are 4 bytes to every pixel:
Byte 1: Red Color Value
Byte 2: Green Color Value
Byte 3: Blue Color Value
Byte 4: Alpha value (don't worry about it)
To figure out where each pixel is in the memblock, you use this conversion:
Position=HeaderSize+BytesPerPixel*PixelNumber
and
PixelNumber=Y*Width+X
The header to an image is broken down like:
Bytes 0-3 (4 bytes-DWORD): Width
Bytes 4-7 (4 bytes-DWORD): Height
Bytes 8-11 (4 bytes-DWORD): Depth
So, the header size will be 12 (4+4+4)
In a 32 bit picture, the equation to figure out the position number of a pixel will be:
Position=12+4*(Y*Width+X)
So, now we know where everything is stored, but how do we get to it. We use the Position number and the following commands:
MEMBLOCK BYTE
MEMBLOCK WORD
MEMBLOCK DWORD
MEMBLOCK FLOAT
Amazing stuff huh? Each command requires 2 arguments in this fashion:
MEMBLOCK DWORD(Memblock Number,Position)
So if you read the color value from the pixel, you can get the color values and do what you need to with them.
Again, I am not the GREATEST with memblocks, but I have used them here and there.
Let me know if I can clear anything up.
Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose