[gtkada] Using Gdk.RGB.Draw_RGB_Image

Emmanuel Briot briot at gnat.com
Wed May 2 11:54:36 CEST 2001


manuel.op.de.coul at eon-benelux.com writes:
 > This array is constrained but indeed enormous. It looks like a problem
 > with the Gdk.RGB package to me.
 > It could be changed to make the Rgb_Buffer type unconstrained.


The reason that RGB_Buffer is defined as above is probably because we used to
have some functions returning this array. As you know, C doesn't provide
information for the bounds, and thus we had to use what we call a "flat array"
(don't know if this is standard terminology, or just internal to AdaCore), that
is an array that doesn't have bounds information.

However, such a type is only required if we have functions returning it. I just
checked Gdb.RGB, and since we only use this type for parameters, there is no
real need for it anymore.

Indeed, the suggested changed by Manuel seems good, and we will incorporate
them in some future release (not the next one, which is already packaged up and
completely frozen).

In the meanwhile, you can use some unchecked_conversion to use the package:


 declare
    type My_Rgb is array (Natural range <>) of Gchar;
    type My_Rgb_Access is access all My_Rgb;
    function Conv is new Unchecked_conversion
         (My_Rgb_Access, RGB_Buffer_Access);

    A : My_Rgb (1 .. 256);
 begin
    Draw_Rgb_Image (...., Rgb_Buf => Conv (A'Access), ...);
 end;


This should work, although I haven't tested it.

Emmanuel




More information about the gtkada mailing list