00001 /* 00002 * PROPRIETARY INFORMATION. This software is proprietary to 00003 * Side Effects Software Inc., and is not to be reproduced, 00004 * transmitted, or disclosed in any way without written permission. 00005 * 00006 * Produced by: 00007 * 00008 * Mark Alexander 00009 * Side Effects 00010 * 477 Richmond Street West 00011 * Toronto, Ontario 00012 * Canada M5V 3E7 00013 * 416-504-9876 00014 * 00015 * NAME: PXL_Pixel.h 00016 * 00017 * COMMENTS: 00018 * Utility class for manipulating different types of pixel data (uint8, 00019 * uint16, int32, float32) 00020 * fast - setting to zero does white/black point calculations, 00021 * 1 does the faster int calculations. 00022 */ 00023 00024 #ifndef PXL_PIXEL_H 00025 #define PXL_PIXEL_H 00026 00027 #include <iostream.h> 00028 #include "PXL_Common.h" 00029 00030 00031 template<class Type, int fast> class PXL_Pixel 00032 { 00033 public: 00034 PXL_Pixel(unsigned int black=0, unsigned int white=0, Type value =0); 00035 PXL_Pixel(const PXL_Pixel &pix); 00036 00037 inline bool isSameType(PXL_DataFormat format, 00038 unsigned b, 00039 unsigned w) const; 00040 00041 inline void setBWPoints(float b, float w); 00042 00043 inline Type operator + (int) const; 00044 inline Type operator - (int) const; 00045 inline Type operator / (int) const; 00046 inline Type operator * (int) const; 00047 00048 inline Type operator +=(int); 00049 inline Type operator -=(int); 00050 inline Type operator /=(int); 00051 inline Type operator *=(int); 00052 00053 // Float addition and subtraction treated as (0.0 = black, 1.0 = white) 00054 inline Type operator + (float) const; 00055 inline Type operator - (float) const; 00056 inline Type operator / (float) const; 00057 inline Type operator * (float) const; 00058 00059 inline Type operator +=(float); 00060 inline Type operator -=(float); 00061 inline Type operator /=(float); 00062 inline Type operator *=(float); 00063 00064 inline operator unsigned char () const; 00065 inline operator unsigned short () const; 00066 inline operator unsigned int () const; 00067 inline operator float () const; 00068 00069 // just assigns explicitly (no conversion), though clamping is done. 00070 inline Type assign(unsigned int); 00071 00072 // assigns explicitly. 00073 inline Type set(Type ); 00074 00075 inline Type operator= (float); 00076 00077 inline int operator==(unsigned int) const; 00078 inline int operator==(float) const; 00079 00080 inline Type maxValue() const; 00081 inline Type minValue() const; 00082 00083 inline void setRange(unsigned int b, unsigned int w); 00084 00085 inline unsigned int getWhite() const { return myWhite; } 00086 inline unsigned int getBlack() const { return myBlack; } 00087 inline Type getValue() const { return myValue; } 00088 inline PXL_DataFormat getFormat() const { return myType; } 00089 00090 inline void mapValue(unsigned int val); 00091 00092 inline int getIntFromFloat(float f) const; 00093 00094 00095 inline const char *formatName() const; 00096 private: 00097 Type myValue; 00098 unsigned int myBlack; 00099 unsigned int myWhite; 00100 PXL_DataFormat myType; 00101 float myPntScale; 00102 }; 00103 00104 00105 #include "PXL_PixelImpl.h" 00106 00107 #endif
1.5.9