//======= Copyright © 1996-2005, Valve Corporation, All rights reserved. ======// // // Purpose: // // $Header: $ // $NoKeywords: $ //=============================================================================// #ifndef FLOAT_BM_H #define FLOAT_BM_H #ifdef _WIN32 #pragma once #endif #include #include "tier0/dbg.h" #include struct PixRGBAF { float Red; float Green; float Blue; float Alpha; }; #define SPFLAGS_MAXGRADIENT 1 class FloatBitMap_t { public: int Width, Height; // bitmap dimensions float *RGBAData; // actual data FloatBitMap_t(void) // empty one { Width=Height=0; RGBAData=0; } FloatBitMap_t(int width, int height); // make one and allocate space FloatBitMap_t(char const *filename); // read one from a file (tga or pfm) FloatBitMap_t(FloatBitMap_t const *orig); // quantize one to 8 bits void WriteTGAFile(char const *filename) const; bool LoadFromPFM(char const *filename); // load from floating point pixmap (.pfm) file void WritePFM(char const *filename); // save to floating point pixmap (.pfm) file void InitializeWithRandomPixelsFromAnotherFloatBM(FloatBitMap_t const &other); inline float & Pixel(int x, int y, int comp) const { Assert((x>=0) && (x=0) && (y= Width) x -= Width; if ( y < 0 ) y+=Height; else if ( y >= Height ) y -= Height; return RGBAData[4*(x+Width*y)+comp]; } inline float & PixelClamped(int x, int y, int comp) const { // like Pixel except wraps around to other side x=clamp(x,0,Width-1); y=clamp(y,0,Height-1); return RGBAData[4*(x+Width*y)+comp]; } inline float & Alpha(int x, int y) const { Assert((x>=0) && (x=0) && (y=0) && (x=0) && (y=0) && (x=0) && (y=0) && (x=0) && (y