Quote:
Originally Posted by dimasic
Lua's type conversion made me crazy. But when my code has made screenshot with its own colors, I suddenly noticed that the code is almost identical to the NuPogodi's code (after he made some corrections).
In resulting file the high and the low bits are still equal, so the tiny loss of contrast in highlights should be. But who cares?
|
Lua's type conversion ? ?
What type conversion ?
It is 8-bit clean strings.
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.
If the high nibble == 0 and data is in low nibble from you pbm file on writing, just duplicate the low for bits ( val + (val * 16)) in the byte to be written.
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).