[EMAIL PROTECTED] wrote:

> > Adding a few simple "example-callbacks" that render into such a structure or
> > a LibGGI visual can give the same ease of use if desired, but without
> > straining my swap, if I don't want that.
> I like this idea.

Good. I'll then add a proposed API below ... I'm making this up while
writing the mail, so please bear with me, if it isn't perfect ... :-).

> > That could be done by chaining a load and a save call appropriately.
> This sounds like the idea behind streams, we bind a few streams together via
> callbacks, and we have complete flexibility as to permute the stream without
> wasting memory. The same chaining will do color space conversion...

Yeah. That's the idea ... I worked too much with EvStack, you know ...

> I think we need to work out the API for the image library, it should use
> dlopen to access modules for each graphics format. And each available format
> should be registed in a table.

Yeah. I suggest to handle it like LibGGI, but this time with a "real"
autotarget. I.e. you can specify format at "Open"-time, or leave it to the
lib, which will figure out by loading an "auto"-format that will probe 
for stuff as appropriate.

> I think you should be able to add modules without recompiling the underlying
> system, so each module will need an init function which will update the table,
> like in the linux kernel.

Even better: We make a "smart" module that tries to guess the image-type.
It will then try to load the corresponding handler (using the equivalent of
/etc/ggi/libggi.conf). If the loading or the handler fails, the smart module
kicks in again and tries alternatives.

> I will write up a proposal for the API if no one else wants too? 
> I just dont have alot of time to work on it :(

I'll try to give you something to play with below:

/*
 * This is a design study for a Generic Picture Format library
 */
 
 
/* Startup/Shutdown:
 */
 
gpfInit(void);
gpfExit(void);
gpfPanic(const char *format,...);

/* Opening and Closing picture sources
 */
 
gpf_handle_t gpfOpen(const char *type,const char *location,const char *options, void 
*locationdata, void *optiondata);

/* Open a file of a given type (NULL for autoselect), from "location".
 * location should be in a recognized standard format which has semantics
 * as determined by the library that handles type.
 * Standard behaviour (especially that of the auto target) should be to
 * accept filenames and URLs. Some special formats should be defined
 * to allow for reading from internal sources, pipes and functions.
 */

gpfClose (gpf_handle_t handle);

/* Close a given stream, flush buffers and free ressources.
 */
 
gpfFlush(gpf_handle_t handle);
/* Flush buffers just as close would, but keep the file open.
 * May not make sense on all targets.
 */


int gpfSelectImage(gpf_handle_t handle,int imagenumber); /* for multiimage Formats */

typedef struct {
        int width,height;
        pixelformat_t pixelformat; /* We can probably borrow from DirectBuffer here */
} gpf_imageinfo_t;

int gpfGetImageInfo(gpf_handle_t handle,gpf_imageinfo_t *info);

/* get the most important image data */

typedef int (*gpfReadCallback)(int x,int y, int width,int height, void *data, int 
pixelwidth);
 
gpfRead(gpf_handle_t handle,gpfReadCallback cb);

/* Try to read the selected image. the callback will be used like you would use
 * write() and PutBox(); I.e. you call it with the rectangle you have data for
 * and it returns the number of pixels it processed. This gives a small complication,
 * if it doesn't accept whole lines, but that can be taken care of by a single
 * glue function that handles the case by trying to first send the rest of
 * incomplete lines.
 *
 * The reader-libs should use reasonably sized buffers, like one line for simple
 * format, or 8 lines for JPG. Don't know yet what to do about interlaced or
 * progressive formats
 */


O.K. - I'm a bit tired right now ... comments welcome ... the callback stuff
is definitely not perfect. It kind of defeats streaming conversion, as I
can't run two functions simultaneously ... Maybe something that gets
initiated by the Read/Write, and is then driven by the "callbacks" ...
That might also accomodate mmaping stuff better (you can just be given a
pointer into the mmaped file as return code ...).

CU, ANdy

-- 
= Andreas Beck                    |  Email :  <[EMAIL PROTECTED]> =

Reply via email to