From 5e0fc865a8b6063cbcb3451fbac4cdbe841889df Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Wed, 12 Feb 2003 01:12:34 +0000 Subject: [PATCH] start of pseudocolor init --- otk/pseudorendercontrol.cc | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/otk/pseudorendercontrol.cc b/otk/pseudorendercontrol.cc index f6162cec..b3ee06c3 100644 --- a/otk/pseudorendercontrol.cc +++ b/otk/pseudorendercontrol.cc @@ -23,13 +23,34 @@ PseudoRenderControl::PseudoRenderControl(int screen) : RenderControl(screen) { printf("Initializing PseudoColor RenderControl\n"); - const ScreenInfo *info = display->screenInfo(_screen); + int depth = info->depth(); + + _cpc = 4; // XXX THIS SHOULD BE A USER OPTION + _ncolors = _cpc * _cpc * _cpc; + + if (_cpc < 2 || ncolors > 1 << depth) { + fprintf(stderr, + _("PseudoRenderControl: Invalid colormap size. Using maximum size +available.\n")); + _cpc = 1 << (depth/3); + _ncolors = 1 << depth; // _cpc * _cpc * _cpc + } + + if (!(_colors = new XColor[_ncolors])) { + fprintf(stderr, + _("PseudoRenderControl: error allocating colormap\n")); + ::exit(1); + } + + } PseudoRenderControl::~PseudoRenderControl() { printf("Destroying PseudoColor RenderControl\n"); + + delete _colors; } void PseudoRenderControl::reduceDepth(Surface &sf, XImage *im) const -- 2.45.2