Lisp HUG Maillist Archive

Fastest array-as-image?

I have an array of ARGB values, representing an image. What's the 
fastest way to display that in a port?

The only way I've found to do this is to loop over the image and call 
gp:draw-rectangle, with a 1x1 rectangle, and with a :foreground color 
made from each array pixel ARGB values. This is very slow. I can't use 
gp:draw-point (which might be somewhat faster), since it ignores the 
foreground color.

I'm also trying to display an ARGB image that's computed as a function 
of x and y, but I assume that would be a similar solution to the 1st 
problem.

TIA for any help.

I'm using LW 4.3.7 on Mac OS X, if that matters.

  - Stoney

-- 
Stonewall Ballard
stoney@sb.org           http://stoney.sb.org/


Re: Fastest array-as-image?

On Thu, Sep 02, 2004, 14:25, Stonewall Ballard <sb.list@sb.org> wrote
>I have an array of ARGB values, representing an image. What's the 
>fastest way to display that in a port?
>
>The only way I've found to do this is to loop over the image and call 
>gp:draw-rectangle, with a 1x1 rectangle, and with a :foreground color 
>made from each array pixel ARGB values. This is very slow. I can't use 
>gp:draw-point (which might be somewhat faster), since it ignores the 
>foreground color.
>
>I'm also trying to display an ARGB image that's computed as a function 
>of x and y, but I assume that would be a similar solution to the 1st 
>problem.
>
>TIA for any help.
>
>I'm using LW 4.3.7 on Mac OS X, if that matters.

Look at GP:DRAW-IMAGE.  You'll need to do some undocumented hack to get an 
IMAGE from you data.  I thiink you can make an instance of GP:EXTERNAL-IMAGE, 
passing your array as the value of the :DATA initarg.

Once you have an EXTERNAL-IMAGE you'll need to feed it to 
GP:CONVERT-EXTERNAL-IMAGE to get an image you can display.



Re: Fastest array-as-image?

On Sep 2, 2004, at 3:13 PM, Mark Nahabedian wrote:

> On Thu, Sep 02, 2004, 14:25, Stonewall Ballard <sb.list@sb.org> wrote
>> I have an array of ARGB values, representing an image. What's the
>> fastest way to display that in a port?
>>
>> The only way I've found to do this is to loop over the image and call
>> gp:draw-rectangle, with a 1x1 rectangle, and with a :foreground color
>> made from each array pixel ARGB values. This is very slow. I can't use
>> gp:draw-point (which might be somewhat faster), since it ignores the
>> foreground color.
>>
>> I'm also trying to display an ARGB image that's computed as a function
>> of x and y, but I assume that would be a similar solution to the 1st
>> problem.
>>
>> TIA for any help.
>>
>> I'm using LW 4.3.7 on Mac OS X, if that matters.
>
> Look at GP:DRAW-IMAGE.  You'll need to do some undocumented hack to 
> get an
> IMAGE from you data.  I thiink you can make an instance of 
> GP:EXTERNAL-IMAGE,
> passing your array as the value of the :DATA initarg.
>
> Once you have an EXTERNAL-IMAGE you'll need to feed it to
> GP:CONVERT-EXTERNAL-IMAGE to get an image you can display.

This was a good idea. There wasn't any need to call 
convert-external-image. I just used load-image with a DIB (.bmp) format 
array derived from the original ARGB array. An extra copy, but it's 
still fairly fast.

BTW, I also tried using an image-access to draw the array into the 
image. It was slightly faster than using draw-rectangle, but not by 
much.

Thanks!

  - Stoney

-- 
Stonewall Ballard
stoney@sb.org           http://stoney.sb.org/


Re: Fastest array-as-image?

Hi,

I am building an application that needs to capture pixel arrays from  
the screen.  I'm using LWM 4.4.5/OS X.  Using FFI & Cocoa, I can get  
access to the screen data and build a pixel array in LispWorks, but  
now I am struggling to efficiently display the image array using CAPI.

I am now examining the possibility of manually constructing an  
external-image, and then converting and displaying the image in one  
shot.  I know the graphics-ports:external-image class has a :DATA  
slot, and that the data slot accepts a vector of type (SIMPLE-ARRAY  
(UNSIGNED-BYTE 8)).  However, I am stuck on the format of this  
vector.  Is it RGB, RGBA, etc, does it store image size or other  
header information?

I found this hint from a year ago, but I don't think the question of  
the :DATA format has ever been answered.  Unlike the other  
approaches, loading an image in from disk is not an option in this case.

Thanks in advance for any help,
-Chris

On Sep 2, 2004, at 3:13 PM, Mark Nahabedian wrote:

> On Thu, Sep 02, 2004, 14:25, Stonewall Ballard <sb.list@sb.org> wrote
>> I have an array of ARGB values, representing an image. What's the
>> fastest way to display that in a port?
>>
>> The only way I've found to do this is to loop over the image and call
>> gp:draw-rectangle, with a 1x1 rectangle, and with a :foreground color
>> made from each array pixel ARGB values. This is very slow. I can't  
>> use
>> gp:draw-point (which might be somewhat faster), since it ignores the
>> foreground color.
>>
>> I'm also trying to display an ARGB image that's computed as a  
>> function
>> of x and y, but I assume that would be a similar solution to the 1st
>> problem.
>>
>> TIA for any help.
>>
>> I'm using LW 4.3.7 on Mac OS X, if that matters.
>
> Look at GP:DRAW-IMAGE.  You'll need to do some undocumented hack to  
> get an
> IMAGE from you data.  I thiink you can make an instance of  
> GP:EXTERNAL-IMAGE,
> passing your array as the value of the :DATA initarg.
>
> Once you have an EXTERNAL-IMAGE you'll need to feed it to
> GP:CONVERT-EXTERNAL-IMAGE to get an image you can display.
>
>


______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________


Updated at: 2020-12-10 08:55 UTC