nanogui: Can we make PIXELVAL a 16-bit entity?


Previous by date: 10 Dec 1999 18:36:52 -0000 Re: Can we make PIXELVAL a 16-bit entity?, Greg Haerr
Next by date: 10 Dec 1999 18:36:52 -0000 Pseudo terminal access for Microwindows terminal, Greg Haerr
Previous in thread: 10 Dec 1999 18:36:52 -0000 Re: Can we make PIXELVAL a 16-bit entity?, Greg Haerr
Next in thread: 10 Dec 1999 18:36:52 -0000 Re: Can we make PIXELVAL a 16-bit entity?, Morten Rolland

Subject: Re: Can we make PIXELVAL a 16-bit entity?
From: "Greg Haerr" ####@####.####
Date: 10 Dec 1999 18:36:52 -0000
Message-Id: <008d01bf432b$cf50d8a0$15320cd0@gregh>

: If not, a macro 'RGB2PIXEL(r,g,b)' could be used to do this, along
: with 'PIXEL2GREEN(PIXELVAL c)' etc. To manipulate the PIXELVAL
: 'images'.  Applications like MPEG players would like to avoid using
: macros and instead do their own lookups etc. for speed, while some
: applications like our own, would use precompiled binary files
: in 565 format for buttons etc.

Morten,
    In thinking more about your needs and the last email, we could need the
following macros:

RGB2PIXEL(r,g,b)    returns PIXELVAL according to compiletime or runtime PF_XXX?
    It's possible that we might need this to operate at runtime, rather than
compiletime.
For the simpler compiletime case, we can only make it work when running in the
truecolor
modes:
    PF_TRUECOLOR24            (32bpp)
    PF_TRUECOLOR565          (16bpp)
    PF_TRUECOLOR332          (8bpp)
For PF_PALETTE, we're kinda in trouble, unless we're running a fixed palette.

So to solve this at compiletime (the fastest), I suggest the following macros:

RGB2PIXEL24(r,g,b)        convert RGB to 32bpp 24bit truecolor
RGB2PIXEL565(r,g.b)      convert RGB to 16bpp 5/6/5 truecolor
RGB2PIXEL332(r,g,b)      convert RGB to 8bpp 3/3/2 truecolor

For runtime conversion, a single RGBToPixel() routine could run on the client
side and statically get the PF_XXX pixtype thru GrGetScreenInfo once, and then
calculate a PIXELVAL from the passed parameters.  It could work in PF_PALETTE
mode by calling GrGetSystemPaletteEntries.  This is slower, but can work
regardless
of the server's PIXELVAL size.  (But probably isn't needed by you)

For reading PIXELVALs, the following macros could also be needed, again
depending on the type of PIXELVAL:


PIXEL24GREEN(pixelval)        returns the 8 bit green component of 24bpp
pixelval
PIXEL565GREEN(pixelval)      returns the 6 bit green component of 16bpp pixelval
PIXEL332GREEN(pixelval)      returns the 3 bit green component of 8bpp pixelval
and likewise for RED and BLUE.

For runtime conversion, the function
PixelToGreen(PIXELVAL pixelval) could be used and kept in the client library.
Again, it could get the system palette if running in palette, rather than
truecolor modes.

With the above design, a Nano-X applications programmer has two choices in which
to write his application:  (1) assume knowledge of the PIXELVAL implementation,
in
which case he uses the macros, and the application only runs on that
implementation,
or he can use the runtime functions, which are slower, and the application will
run on
any implementation.

Regards,

Greg


Previous by date: 10 Dec 1999 18:36:52 -0000 Re: Can we make PIXELVAL a 16-bit entity?, Greg Haerr
Next by date: 10 Dec 1999 18:36:52 -0000 Pseudo terminal access for Microwindows terminal, Greg Haerr
Previous in thread: 10 Dec 1999 18:36:52 -0000 Re: Can we make PIXELVAL a 16-bit entity?, Greg Haerr
Next in thread: 10 Dec 1999 18:36:52 -0000 Re: Can we make PIXELVAL a 16-bit entity?, Morten Rolland


Powered by ezmlm-browse 0.20.