raw_surface - Create a new surface using a table as input.
vid
raw_surface( width, height, bytes_per_pixel, input_table, out_file
)
This function creates a new 'raw' surface using user-supplied values for pixel
data. The internal representation is set to a compile- time system default
(typically RGBA 888). If the optional out_file argument is set,
a PNG image will also be stored in the APPL_TEMP namespace.
Using an out_file is primarily intended as a debugging/developer
feature and the actual encode/store operation is synchronous.
- 1
- There might be a loss of precision imposed by the texture format native to
the system that is running.
- 2
-
width and height should be within the
compile-time constraints of
MAX_SURFACEW and MAX_SURFACEH , exceeding those
dimensions is a terminal state transition.
- 3
- Only acceptable bytes_per_pixel values are 1, 3 and 4. All others
are terminal state transitions.
- 4
- All input_table values will be treated as 8-bit unsigned
integers.
- 5
-
input_table is expected to have exactly width
height bytes_per_pixel values, starting at index 1. Any deviation
is a terminal state transition.
function raw_surface0()
local rtbl = {};
local ofs = 1;
for row=1,64 do
for col=1,64 do
rtbl[ofs+0] = math.random(255);
rtbl[ofs+1] = math.random(255);
rtbl[ofs+2] = math.random(255);
ofs = ofs + 3;
end
end
local vid = raw_surface(64, 64, 3, rtbl);
show_image(vid);
end