Re: [AD] Allegro5 and colors |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
> Laurence Withers wrote:
>
> >-----BEGIN PGP SIGNED MESSAGE-----
> >Hash: SHA1
> >
> >On Sunday 08 September 2002 18:54, Bob wrote:
> >
> >
> >>However, if we want to support depths larger than 32 bpp, we can't
> >>pass that value as a 32-bit int (obviously).
> >>
> >>
> >
> >typedef char al_color[8];
> >al_color al_makecol(BITMAP*, int, int, int); // rgb, obviously :-)
> >al_color al_makecol_yuv(BITMAP*, int, int, int);
> >al_color al_makecol_cmyk(BITMAP*, int, int, int, int);
> >
>
> How safe is returning an array from a function? How fast is it? Does
> speed matter in our case?
I don't see why something like this wouldn't work properly
AL_COLOR color;
color = al_mpa_rgba_b(bmp, r, g, b, a);
al_put_pixel(bmp, x, y, color);
or (here would be the good thing, no need for dummy structs)
al_put_pixel(bmp, x, y, al_mpa_rgba_b(bmp, r, g, b, a));
being al_map_rgba_b:
AL_COLOR al_map_rgba_b(BITMAP *, int, int, int);
and of course AL_COLOR a typedef struct (with whatever we wish inside)
After all C *can* handle structs as it handles for example ints (I just
tested with DJGPP)
I mean, something like
AL_COLOR color = al_map_rgba_b(blabla);
would copy the contents of the returned struct to the color struct, it is
not like that has the problems of char * or whatever to need dummies