Quote:
Originally Posted by knc1
Lua's type conversion ? ?
What type conversion ?
It is 8-bit clean strings.
|
Heh. When we read bytestring from framebuffer and parse it byte by byte with string:char and try to write them to output file, then we will get not bytestring, but string of hexadecimal representation of symbols. "0" from framebuffer will be "30" char string in output file as the NuPogodi's code (before correction) and dozen of my tries (before I found the right way) made. It's very strange at the first glance that there's no way to get bytes from string directly, without string:byte + string:char conversion.
Quote:
If the high nibble == the low nibble (which it does) on reading from the frame buffer just divide the byte by 16 (right shift 4).
That gives 0 ... 15 right justified in the byte.
|
I know this. But when we divide the XX byte by 16 and then multiply the result by 16, we'll got X0. It's the right thing we want to get, but not in the case of FF - we'll got F0 and the greyish background in screenshot. When we are solving the problem by mathematical, not the bitewise ops, we must add the "if - then" case for FF bytes. IMHO, XX bytes instead of X0 in the resulting file are not the problem at all, but our code is more simple, without if-then and math.floor.
Quote:
Not exactly brain surgery here - just simple math.
Even easier if using Lua 5.2 (which has bit ops) or your using the Lua 5.1 on the Kindles (just load the luabit library for bit ops).
|
Yes, I've found that the external libraries of bitewise ops are exist. But I think that is not very much reasonable to add them into distribution as we need them only once.
Anyway, thank you!