[gtkada] Controlling pixel values

Richard Thursby thursby at novatechnologies.net
Sat Aug 21 02:15:56 CEST 2004


Hello:

I have an application that I am porting to GtkAda that has some interesting color requirements.  The application runs on an embedded graphics chip and has full control over the colormap to match specific pixel values to specific colors.  The application draws various objects with specific pixel values.  All objects are the same color unless they overlap each other.  The colors of the overlapping regions become new (highlighted) colors.  Below is a representation of the application's display with three objects being drawn (Object_A, Object_B, Object_C):

+---------------------+
|Object_A             |
|Pixel: 2#001#        |
|Color: Color_A       |
|  +-----------------------------------+
|  |Overlap_Region_1  |        Object_B|
|  |Pixel: 2#011#     |   Pixel: 2#010#|
|  |Color: Color_B    |  Color: Color_A|
|  |                  |                |
|  | +-----------------------------------+
|  | |Overlap_Region_2|                | |
|  | |Pixel: 2#111#   |                | |
|  | |Color: Color_C  |Overlap_Region_3| |
+----|----------------+   Pixel: 2#110#| |
   | |                   Color: Color_B| |
   +-|---------------------------------+ |
     |                                   |
     |                           Object C|
     |                      Pixel: 2#100#|
     |                     Color: Color_A|
     +-----------------------------------+

The colormap would be the following:

Pixel   Color
------  -------
2#000#  Black
2#001#  Color_A
2#010#  Color_A
2#011#  Color_B
2#100#  Color_A
2#101#  Color_B
2#110#  Color_B
2#111#  Color_C

Overlap_Region_1 is the overlap of Object_A and Object_B.  Overlap_Region_2 is the overlap of Object_A, Object_B, and Object_C.  Overlap_Region_3 is the overlap of Object_B and Object_C.

The application clears the background to 2#000# before any objects are drawn.  The objects are drawn with the pixel values or'd together.  The Colors (Color_A, Color_B, Color_C) will change during the life of the application as the user adjusts the brightness of the display.

I have tried prototyping a solution using a private colormap.  I have never used a private colormap before, but I would expect that I should be able to map specific pixel values to specific colors.  My understanding is that I should have a number of colorcells (256 on my display) whose pixel values are indices into the HW colormap.  However, I have found in my testing that I cannot assign arbitrary pixel values to arbitrary colors.  I am missing the part where the colorcells are mapped to actual HW colors.

Is a private colormap the way to go or is there another way to accomplish the task?  What are the gotchas with using private colormaps under GtkAda?  It appears in my testing that I have to create the main window with the private colormap or it does not work.  How do GtkAda color values relate to straight Xwindow color values (i.e. are they one-to-one or is there some translation)?

Any suggestions would be greatly appreciated.

Thanks,

Rich
-------------- next part --------------
An HTML attachment was scrubbed...
URL: /pipermail/gtkada/attachments/20040820/dc51f863/attachment.htm 


More information about the gtkada mailing list