[vox-tech] xlib/gdk questions
Mark K. Kim
vox-tech@lists.lugod.org
Mon, 3 Jun 2002 13:12:54 -0700 (PDT)
On Mon, 3 Jun 2002, Peter Jay Salzman wrote:
> 1: colormaps
> ============
> when an xlib book talks about a colormap, is it talking about something
> which is global in scope? something that's shared by all Windows? is
> it determined by the graphics card?
>
> or something which exists for each Window on a display?
An application can use a global colormap (which limits its colors) or an
application can make its own global colormap. In 8-bit mode, that means
whenever the app gains focus, all other windows are gonna look weird,
and when the app loses focus it'll look weird.
As I recall, if you don't specifically create a colormap, you end up using
the global one (or maybe you request for the global colormap). Also,
colormap isn't necessary if you're using 16bit or above. But it doesn't
hurt to set one up if you're not writing a code with too many colors.
As I recall.
> 2: visuals
> ==========
> same question for a visual. a visual describes how pixel colors are
> interpreted -- whether we use a colormap (1, 8, 16 bpp) or a true RGB
> triplet (24, 32 bpp). this makes it sound like there's one visual for
> each server, since depth information should be the same for all Windows.
> yet from reading, it sounds like each Window has a visual. what's the
> deal?
Don't know.
> btw, what exactly is 32bpp? how can any true-color color map have a
> depth that's not divisible by 3? doesn't each color goes from 0 to FF?
> what are the extra bits used for?
32bpp = 8 bit red, 8 bit green, 8 bit blue, 8 bit alpha. The alpha
channel can be used to blend things, to get translucency. For example:
bitmap one with alpha
bitmap two with alpha
bitmap three where you blit one and two together
so you can get translucent colors on bitmap three. But I think the
final number of colors you can see is actually 24-bits (if you blend
[200,0,0] with [201,0,0], you don't end up with [200.5,0,0]).
> 3: Graphics Contexts and Color
> ==============================
> suppose i want to do some plotting in Xlib or Gdk. suppose my plot has
> 1000 colors. do i really have to:
>
> 1. allocate a color. 1000 times.
> 2. declare 1000 graphics contexts
>
> that seems more than painful; it's masochistic. is this what someone
> needs to do to draw a picture that contains 1000 colors?
Don't know.
-Mark "sometimes-it's-okay-to-say-I-don't-know" Kim
--
Mark K. Kim
http://www.cbreak.org/
PGP key available upon request.