/usr/include/OverlayUnidraw/grayraster.h is in ivtools-dev 1.2.11a1-8.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | /*
* Copyright (c) 1998-1999 Vectaport Inc.
* Copyright (c) 1997 R.B. Kissh & Associates, Vectaport Inc.
* Copyright (c) 1994-1996 Vectaport Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and
* its documentation for any purpose is hereby granted without fee, provided
* that the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the names of the copyright holders not be used in
* advertising or publicity pertaining to distribution of the software
* without specific, written prior permission. The copyright holders make
* no representations about the suitability of this software for any purpose.
* It is provided "as is" without express or implied warranty.
*
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
* IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL,
* INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
* FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
#define NDEBUG
/*
* Gray Raster component declarations.
*/
#ifndef gray_rastercomp_h
#define gray_rastercomp_h
#include <OverlayUnidraw/ovraster.h>
#include <Attribute/attrvalue.h>
/* class GrayRaster */
//: gray-level image with arbitary numeric values.
class GrayRaster : public OverlayRaster {
public:
GrayRaster(unsigned long width, unsigned long height,
AttributeValue::ValueType type = AttributeValue::UCharType,
void* data = nil);
// construct a GrayRaster of 'width','height' and 'type', with an optional
// copy of 'data', a linear array of 'width'*'height' values of 'type'.
GrayRaster(const GrayRaster& raster);
// construct a GrayRaster by copying 'raster'.
virtual ~GrayRaster();
virtual OverlayRaster* copy() const;
// interface to GrayRaster copy constructor.
virtual void poke(
unsigned long x, unsigned long y,
ColorIntensity red, ColorIntensity green, ColorIntensity blue,
float alpha
);
// Convert 'red','green','blue' to graylevel value using
// this equation: 0.299 r + 0.587 g + 0.114 b, then poke at 'x','y'.
virtual void graypeek(unsigned long x, unsigned long y, unsigned int& v);
// convert value of value_type() at 'x','y' to an unsigned int.
virtual void graypeek(unsigned long x, unsigned long y, unsigned long& v);
// convert value of value_type() at 'x','y' to an unsigned long.
virtual void graypeek(unsigned long x, unsigned long y, float& v);
// convert value of value_type() at 'x','y' to a float.
virtual void graypeek(unsigned long x, unsigned long y, double& v);
// convert value of value_type() at 'x','y' to a double.
virtual void graypeek(unsigned long x, unsigned long y, AttributeValue& v);
// insert value of value_type() at 'x','y' into an AttributeValue.
virtual void graypoke(unsigned long x, unsigned long y, unsigned int v);
// convert unsigned int to value_type(), then poke at 'x','y'.
virtual void graypoke(unsigned long x, unsigned long y, unsigned long v);
// convert unsigned long to value_type(), then poke at 'x','y'.
virtual void graypoke(unsigned long x, unsigned long y, float v);
// convert unsigned float to value_type(), then poke at 'x','y'.
virtual void graypoke(unsigned long x, unsigned long y, double v);
// convert double to value_type(), then poke at 'x','y'.
virtual void graypoke(unsigned long x, unsigned long y, AttributeValue v);
// convert numeric AttributeValue to value_type(), then poke at 'x','y'.
virtual void highlight(unsigned long x, unsigned long y);
// highlight pixel at 'x','y' by setting red value to 1.0.
virtual void unhighlight();
// clear pixel highlighting by restoring red value.
virtual void flush() const;
// scale pixel values to onscreen graylevels and flush to display.
virtual int status() const;
// 0 if ok, -1 if error.
virtual OverlayRaster* scale(
ColorIntensity mingray, ColorIntensity maxgray, CopyString& cmd
);
// create new raster scaled between 'mingray' and 'maxgray', and return
// command string to reproduce this effect after save/restore.
virtual OverlayRaster* pseudocolor(
ColorIntensity mingray, ColorIntensity maxgray, CopyString& cmd
);
// create new raster pseudo-colored between 'mingray' and 'maxgray',
// and return command string to reproduce this effect after save/restore.
virtual OverlayRaster* logscale(
ColorIntensity mingray, ColorIntensity maxgray, CopyString& cmd
);
// create new raster logarithmically scaled between 'mingray' and 'maxgray',
// and return command string to reproduce this effect after save/restore.
virtual AttributeValue::ValueType value_type() const { return _type; }
// pixel type.
virtual boolean write(ostream& out, boolean gray=false);
// write raster to ostream.
virtual boolean read(istream& in, boolean gray=false);
// read raster from istream.
virtual boolean gray_flag() { return true; }
// always true.
boolean top2bottom() const { return _t2b; }
// orientation of pixel rows. Default is true.
void top2bottom(boolean t2b) { _t2b = t2b; }
// set orientation of pixel rows.
virtual OverlayRaster* addgrayramp(
CopyString& cmd, RampAlignment = R_LT
);
// embed gray-level ramp in raster at given alignment, and return 'cmd'
// string to reproduce this effect after save/restore.
virtual OverlayRaster* addgrayramp(
CopyString& cmd, IntCoord x, IntCoord y
);
// embed gray-level ramp in raster at 'x', 'y', and return 'cmd' string
// to reproduce this effect after save/restore.
void set_minmax(double minval, double maxval, boolean fixminmax = false);
// set 'minval' and 'maxval' used for flush().
protected:
void init(AttributeValue::ValueType type =AttributeValue::UCharType,
void* data=nil);
// initialize raster of 'type' with optional 'data'.
unsigned char ipeek(unsigned long x, unsigned long y);
// raw byte peek.
void ipoke(unsigned long x, unsigned long y, int byte);
// raw byte poke.
void vpeek(unsigned long x, unsigned long y, AttributeValue&);
// raw AttributeValue peek.
void vpoke(unsigned long x, unsigned long y, AttributeValue&);
// raw AttributeValue poke.
virtual void scale(
ColorIntensity mingray, ColorIntensity maxgray
);
// immediate-mode linear scaling.
virtual void logscale(
ColorIntensity mingray, ColorIntensity maxgray
);
// immediate-mode logarithmic scaling.
virtual OverlayRaster* pseudocolor(
ColorIntensity mingray, ColorIntensity maxgray
);
// immediate-mode pseudocoloring.
virtual void paintgrayramp(
IntCoord left, IntCoord bottom, unsigned width, unsigned height,
boolean horiz
);
// immediate-mode grayramp embedding.
void gainbias_minmax(double& gain, double& bias,
double& dmin, double& dmax) const;
// determine 'dmin' and 'dmax', then compute 'gain' and 'bias' for
// mapping to 0 to 255.
virtual boolean grayraster() { return true; }
// always true.
protected:
unsigned char* _pixel_map; // map from intensity-byte to colormap-byte
unsigned char* _data; // raw pixel data of _type
AttributeValue::ValueType _type; // numeric type of pixels
boolean _t2b; // top2bottom() flag
double _minval; // cached minimum pixel value
double _maxval; // cached maximum pixel value
int _minmax_set; // true when _minval,_maxval computed
};
inline void GrayRaster::ipoke(
unsigned long x, unsigned long y, int byte
) {
assert((x >=0) && (x < pwidth()));
assert((y >=0) && (y < pheight()));
((unsigned char*)_data)[rep()->pwidth_ * y + x]
= (unsigned char)byte;
}
inline unsigned char GrayRaster::ipeek(
unsigned long x, unsigned long y
) {
assert((x >=0) && (x < pwidth()));
assert((y >=0) && (y < pheight()));
return (unsigned char)((unsigned char*)_data)[rep()->pwidth_ * y + x];
}
#endif
|