lua-users home
lua-l archive

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


On Sun, Sep 30, 2012 at 2:46 PM, Tom <tmbdev@gmail.com> wrote:
>> For instance, a "memoryview" module can be put together quite
>>
>> easily using LuaJIT (just to avoid a C interface) and Roberto's struct:
>
>
> Well, let's say I have an ImageMagic library and an ndarray library.  How do
> I use your memoryview module to convert the ImageMagic image to an ndarray?
>
> -- load an image using ImageMagick library
> img = Image()
> img:open("lena.jpg")
>
> -- allocate an array
> a = ndarray(img.height,img.width)
>
> -- efficiently copy the pixels of img into a
>>>> put some FFI expression here <<<
>
>
> Tom

Using LuaJIT or luaffi, it's probably going to be something along the lines of:

ffi.C.memcpy(img.data, a.pointer, img.bytes)

but I don't know the APIs of either of those objects you're describing.

/s/ Adam