lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Or:

my_image = image{
    scan_line{ {r,g,b,a}, {r,g,b,a}, ... },
    scan_line{ {r,g,b,a}, {r,g,b,a}, ... },
    ...
}

Both image and scan_line can flatten their parameters into big, flat arrays.

I avoided using a function per pixel since it felt like overkill. On the
other hand, for the case at hand, you could probably flatten out the scan
lines to:

    scan_line{ "RGBA", r, g, b, a, r, g, b, a, r, g, b, a, ... }

(I threw in a format code but if you were living with a flat array that
isn't particularly necessary.)

On the other hand, I would look seriously at using strings. Unless you are
using double-precision data you are spending a lot of space to store it as a
table. Even with double-precision data the space overhead for big arrays of
doubles is essentially 100% because of alignment issues.

Mark

on 9/29/04 1:39 PM, Peter Loveday at peter@eyeonline.com wrote:

> my_image =
> {
>   { {r,g,b,a}, {r,g,b,a}, ... }, -- scanline 1
>   { {r,g,b,a}, {r,g,b,a}, ... }, -- scanline 2
>   ...
> }