comp.lang.ada
 help / color / mirror / Atom feed
From: Jano <nono@unizar.es>
Subject: Re: BMP/JPG/GIF library in Ada?
Date: Fri, 20 Feb 2004 00:50:12 +0100
Date: 2004-02-20T00:50:12+01:00	[thread overview]
Message-ID: <MPG.1a9f6a1dad6a8ac39896c0@news.able.es> (raw)
In-Reply-To: nl8Zb.79279$uV3.536494@attbi_s51

tmoran@acm.org dice...
> >>     type Triple_DIBitmap_Type (Height, Width : Claw.Int) is ...
> >Similar. I've chosen a constrained representation inheriting from Controlled.
>   Interesting.  Claw's DIBitmap types start at Root_DIBitmap_Type, which
> is abstract tagged, but not Controlled.  Why do you inherit from Controlled?
> Is there something special you do for initialization or finalization?

There's no mysterious reason, I'd say. The internal array of data is 
allocated in the heap so it must be freed on finalization, and cloned in 
adjust. I considered the unconstrained Claw approach but I kinda like 
this other way, and I was concerned about stack overflows for large 
bitmaps. Since neither of the two supposed much more work, I elected the 
stack-safest way. Besides, I like the possibility of having the bitmap 
as part of an enclosing non-limited type, and forget about constraints 
or having to do the heap work in that outer type.

> 
> >  procedure Create (
> >     This : out Object; Width : in Positive; Height : in Positive);
>   Why a Create procedure instead of just a declaration (as above)?  This
> implies you must be using heap allocation since you don't know the
> Height or Width when you declare an instance of Object, right?

Exactly, as outlined above.

> 
> >     procedure Triple_DIBitmap_Type_Output (
> >         Stream : access Ada.Streams.Root_Stream_Type'class;
> >         Item   : in Triple_DIBitmap_Type);
> >     for Triple_DIBitmap_Type'Write use Triple_DIBitmap_Type_Write;
> >  function Get_stream (This : in Object)
> >     return Ada.Streams.Stream_element_array;
>   Why this instead of the 'Output mechanism plus a predefined
> "new Ada.Streams.Root_Stream_Type" that marshalls into an array?

Do you read my mind :)? In fact, internally I'm doing that to create the 
array, but preferred to hide the marshalling inside the function, and 
besides that eliminates the need for the caller to know the array size 
in advance. Since I needed the array instead of the 'Output attributes, 
I've exposed that function instead of writing the attributes, but 
obviously is a matter of a few of lines to have them too.

What worries me is that even if using the heap I evade the stack 
overflows, when returning the array I'm doomed anyway. I wonder if c++ 
references aren't so crazy an idea sometimes.

You may think I'm obsessed with the stack thing, but I've found that in 
windows, past certain stack sizes, the compiler don't obey me anymore 
when I want to increase it, so really there is a limitation by that side 
(about 4 mB or so, I'd say, but never have tested it in detail).

> >Claw is Windows specific, it isn't?
>   Yes.  Claw.Bitmaps includes calls to Windows' routines for painting etc
> as well as just the data structure handling.

Do you know which kind of license carries the Claw demo? Could it be 
used in a GPLed project? I should look at it...
 
>   If this is for web serving, I'm guessing you intend to dynamically draw
> on a bmp internally, since that's simple, and then convert to gif or jpg
> to transmit more reasonably sized data, right?

That's it. Currently I'm using it for a local web interface, so the 
compression is low in the to-do list, and I'm using directly the 
uncompressed BMP.



  reply	other threads:[~2004-02-19 23:50 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-02-16 20:40 BMP/JPG/GIF library in Ada? Brian Catlin
2004-02-16 21:32 ` Randy Brukardt
2004-02-16 22:59 ` Gautier Write-only
2004-02-17 17:53   ` Brian Catlin
2004-02-18 19:09     ` Jano
2004-02-18 20:20       ` tmoran
2004-02-19 18:48         ` Jano
2004-02-19 19:43           ` tmoran
2004-02-19 23:50             ` Jano [this message]
2004-02-20 20:20               ` Randy Brukardt
2004-02-20 21:10                 ` Jeff C,
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox