comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Colors in 8-bit Z buffer
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Colors in 8-bit Z buffer [message #89946] Wed, 07 January 2015 10:02 Go to next message
Matthew Argall is currently offline  Matthew Argall
Messages: 286
Registered: October 2011
Senior Member
I am wondering there are any tricks to managing the color table in an 8-bit Z buffer. I read "Graphics without Graphics Windows" on the coyote website as well as comments in cgSetColorState. Both indicate why there are problems.

Say I want to create several graphics, each with independent color choices. The last graphic seems to determine how all others will appear. An example is below. I can set the pixel depth to 24 and things work fine. The Pixel depth is 8-bits by default, though, which was making things not working out the way I wanted. Made me curious...

Below is an example.


=============
How It Should Look
=============

;Create window and positions
window, /Free, XSize=400, YSize=600
pos = cgLayout([1,3])

;Create data
data1 = cgDemoData(1)
data2 = cgDemoData(13)
data3 = cgDemoData(21)

;Draw plots and images
cgPlot, data1, AXISCOLOR='Grey', POSITION=pos[*,0], TITLE='Time Series', XTITLE='Time (s)', YTITLE='Data', COLOR='Purple'
cgImage, data2, /NOERASE, /AXES, AXKEY={AXISCOLOR: 'Purple'}, POSITION=pos[*,1], TITLE='Hurricane Gilbert', XTITLE='Lat', YTITLE='Lon', CTINDEX=15
cgImage, data3, /NOERASE, /AXES, AXKEY={AXISCOLOR: 'Blue'}, POSITION=pos[*,2], TITLE='Red Blood Cells', XTITLE='Height (um)', YTITLE='Length (um)', CTINDEX=3


===========
Z Buffer Example
===========

;Set up the Z Buffer
xsize = 400
ysize = 600
thisDevice = !D.Name
Set_Plot, 'Z'
Device, Get_Pixel_Depth=thisDepth
Device, Set_Pixel_Depth=8, Set_Resolution=[xsize, ysize], Z_Buffer=0
cgErase, 'White'

;Create data
data1 = cgDemoData(1)
data2 = cgDemoData(13)
data3 = cgDemoData(21)

;Create window and positions
window, /Free, XSize=xsize, YSize=ysize
pos = cgLayout([1,3])

;Draw plots and images
cgPlot, data1, AXISCOLOR='Grey', POSITION=pos[*,0], TITLE='Time Series', XTITLE='Time (s)', YTITLE='Data', COLOR='Purple'
cgImage, data2, /NOERASE, /AXES, AXKEY={AXISCOLOR: 'Purple'}, POSITION=pos[*,1], TITLE='Hurricane Gilbert', XTITLE='Lat', YTITLE='Lon', CTINDEX=15
cgImage, data3, /NOERASE, /AXES, AXKEY={AXISCOLOR: 'Blue'}, POSITION=pos[*,2], TITLE='Red Blood Cells', XTITLE='Height (um)', YTITLE='Length (um)', CTINDEX=3

;Save the buffer
img = cgSnapShot()
wDelete, !D.Window

;Reset the device
Device, Set_Pixel_Depth=thisDepth, Z_Buffer=1
Set_Plot, thisDevice

;Display the contents of the buffer
window, /Free, XSize=xsize, YSize=ysize
cgImage, img
Re: Colors in 8-bit Z buffer [message #89947 is a reply to message #89946] Wed, 07 January 2015 12:27 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Matthew Argall writes:

> I am wondering there are any tricks to managing the color table in an 8-bit Z buffer. I read "Graphics without Graphics Windows" on the coyote website as well as comments in cgSetColorState. Both indicate why there are problems.
>
> Say I want to create several graphics, each with independent color choices. The last graphic seems to determine how all others will appear. An example is below. I can set the pixel depth to 24 and things work fine. The Pixel depth is 8-bits by default, though, which was making things not working out the way I wanted. Made me curious...

The reason this works on your display is that the Coyote Graphics
commands *always* work in a 24-bit color space if they can. The "if they
can" part was also true for the Z-graphics buffer in the early days of
Coyote Graphics. But, the Coyote Graphics system was way ahead of its
time, and the author didn't realize there were still hundreds of
programmers writing programs the same way they wrote them in the 1970s,
so he had to give up his quixotic dreams of "one ring to control them
all."

The problem (explained more fully in the comments in cgSetColorState) is
that although it is not a problem to put the Z-buffer into a 24-bit
state, it is a lot more difficult to set it back to an 8-bit state.
Basically, because of the way the Z-buffer works, setting the state back
to 8-bit means you erase whatever is in the Z-buffer. This is
problematic, because to do anything useful you have to take a picture of
the buffer before you erase it, etc. A chicken and egg thing...

If this is what you care about, though, just set the Z-buffer up as a
24-bit device and leave it there. The Coyote Graphics routines will work
perfectly. :-)

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: differential equation solving when changing the coefficients with time
Next Topic: IDL and Mac Retina Displays

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 09:22:43 PDT 2025

Total time taken to generate the page: 0.00415 seconds