NLMISC::CBitmap Class Reference

Class Bitmap. More...

#include <bitmap.h>

Inherited by NL3D::ITexture.

List of all members.

Public Types

enum  TType {
  RGBA = 0, Luminance, Alpha, AlphaLuminance,
  DXTC1, DXTC1Alpha, DXTC3, DXTC5,
  DsDt, ModeCount, DonTKnow = 0xffffffff
}

Public Member Functions

 CBitmap ()
virtual ~CBitmap ()
void swap (CBitmap &other)
uint8 load (NLMISC::IStream &f, uint mipMapSkip=0)
 Read a bitmap(TGA or DDS) from an IStream.
void makeDummy ()
 Make a dummy "?" texture.
void makeNonPowerOf2Dummy ()
 Make a dummy "2" texture.
bool convertToType (TType type)
 Convert bitmap to another type conversion to rgba always work.
TType getPixelFormat () const
 Return the format of pixels stored at the present time in the object buffer.
virtual uint32 getWidth (uint32 numMipMap=0) const
 Return the image width, or a mipmap width.
virtual uint32 getHeight (uint32 numMipMap=0) const
 Return the image height, or a mipmap height.
uint32 getSize (uint32 numMipMap=0) const
 Return the size (in pixels) of the image: <=> getHeight()*getWidth().
uint32 getMipMapCount () const
 Return the number of mipmaps.
uint32 computeNeededMipMapCount () const
void rotateCCW ()
 Rotate a bitmap in CCW mode.
void buildMipMaps ()
 Build the mipmaps of the bitmap if they don't exist.
void releaseMipMaps ()
 Release the mipmaps of the bitmap if they exist.
void reset (TType type=RGBA)
 Reset the buffer.
void resample (sint32 nNewWidth, sint32 nNewHeight)
 Resample the bitmap.
void resize (sint32 nNewWidth, sint32 nNewHeight, TType newType=DonTKnow, bool resetTo0=true)
 Resize the bitmap.
void resizeMipMap (uint32 numMipMap, sint32 nNewWidth, sint32 nNewHeight, bool resetTo0=true)
 ADVANCED USE Resize a single mipmap level.
void setMipMapCount (uint32 mmc)
 ADVANCED USE To use in conjunction with resizeMipMap.
bool writeTGA (NLMISC::IStream &f, uint32 d=0, bool upsideDown=false)
 Write a TGA (24 or 32 bits) from the object pixels buffer.
bool writePNG (NLMISC::IStream &f, uint32 d=0)
 Write a PNG (24 or 32 bits) from the object pixels buffer.
bool writeJPG (NLMISC::IStream &f, uint8 quality=80)
 Write a JPG from the object pixels buffer.
void loadGrayscaleAsAlpha (bool loadAsAlpha)
 Tell the bitmap to load grayscale bitmap as alpha or luminance format.
bool isGrayscaleAsAlpha () const
 Tell if the bitmap loads grayscale bitmap as alpha or luminance format.
bool blit (const CBitmap *src, sint32 x, sint32 y)
 Perform a simple blit from the source to this bitmap at the (x, y) pos The dimension of the original bitmap are preserved For now, this texture and the source must have the same format With DXTC format, the dest coordinates must be a multiple of 4 mipmap are not rebuild when present IMPORTANT : copy to self is not handled correctly.
void blit (const CBitmap &src, sint srcX, sint srcY, sint srcWidth, sint srcHeight, sint destX, sint destY)
 Extended version of blit.
CRGBAF getColor (float x, float y) const
 Get the color in the bitmap for the first mipmap The mipmaps must be built.
CRGBAF getColor (float x, float y, bool tileU, bool tileV) const
CRGBA getPixelColor (sint x, sint y, uint32 numMipMap=0) const
 Get the pixel at the given coorrdinate.
void flipH ()
 Horizontal flip (all the columns are flipped) Works only with RGBA, and DXTC formats (only if w/h is a power of 2).
void flipV ()
 Vertical flip (all the rows are flipped) Works only with RGBA, and DXTC formats (only if w/h is a power of 2).
void rot90CW ()
 Rotation of the bitmap of 90 degree in clockwise.
void rot90CCW ()
 Rotation of the bitmap of 90 degree in counter clockwise.
void blend (CBitmap &Bm0, CBitmap &Bm1, uint16 factor, bool inputBitmapIsMutable=false)
 Set this bitmap as the result of the blend bewteen 2 bitmap REQUIRE : - Bm0 and Bm1 should have the same size.
void getData (uint8 *&extractData)
void getDibData (uint8 *&extractData)
CBitmapoperator= (const CBitmap &from)

Static Public Member Functions

static void loadSize (NLMISC::IStream &f, uint32 &width, uint32 &height)
 Determinate the bitmap size from a bitmap(TGA or DDS) from an IStream.
static void loadSize (const std::string &path, uint32 &retWidth, uint32 &retHeight)
 same than other loadSize(), but with a pathName.

Public Attributes

enum NLMISC::CBitmap::TType PixelFormat

Static Public Attributes

static const uint32 bitPerPixels [ModeCount]
static const uint32 DXTC1HEADER = NL_MAKEFOURCC('D','X', 'T', '1')
static const uint32 DXTC3HEADER = NL_MAKEFOURCC('D','X', 'T', '3')
static const uint32 DXTC5HEADER = NL_MAKEFOURCC('D','X', 'T', '5')

Protected Attributes

CObjectVector< uint8_Data [MAX_MIPMAP]
uint8 _MipMapCount
bool _LoadGrayscaleAsAlpha
uint32 _Width
uint32 _Height

Private Member Functions

uint32 blend (uint32 &n0, uint32 &n1, uint32 coef0)
 blend 2 integers between 0 and 255 .
uint8 readDDS (NLMISC::IStream &f, uint mipMapSkip)
 Read a DDS from an IStream.
uint8 readTGA (NLMISC::IStream &f)
 Read a TGA from an IStream.
uint8 readPNG (NLMISC::IStream &f)
bool decompressDXT1 (bool alpha)
 Decompress bitmap compressed with S3TC DXT1 algorithm.
bool decompressDXT3 ()
 Decompress bitmap compressed with S3TC DXT3 algorithm.
bool decompressDXT5 ()
 Decompress bitmap compressed with S3TC DXT3 algorithm.
void resamplePicture32 (const NLMISC::CRGBA *pSrc, NLMISC::CRGBA *pDest, sint32 nSrcWidth, sint32 nSrcHeight, sint32 nDestWidth, sint32 nDestHeight)
 The resample function.
void resamplePicture32Fast (const NLMISC::CRGBA *pSrc, NLMISC::CRGBA *pDest, sint32 nSrcWidth, sint32 nSrcHeight, sint32 nDestWidth, sint32 nDestHeight)
 The FAST resample function : works only when reducing the size by two and when the image is square.
float getColorInterp (float x, float y, float xy00, float xy01, float xy10, float xy11) const
 Quadratic interpolator.
CRGBA getRGBAPixel (sint x, sint y, uint32 numMipMap) const
void makeDummyFromBitField (const uint8 bitmap[1024])
void flipHDXTCBlockColor (uint8 *bitColor, uint32 w)
void flipVDXTCBlockColor (uint8 *bitColor, uint32 h)
void flipHDXTCBlockAlpha3 (uint8 *bitColor, uint32 w)
void flipVDXTCBlockAlpha3 (uint8 *bitColor, uint32 h)
void flipHDXTCBlockAlpha5 (uint8 *bitColor, uint32 w)
void flipVDXTCBlockAlpha5 (uint8 *bitColor, uint32 h)
void flipDXTC (bool vertical)
void flipDXTCMipMap (bool vertical, uint mm, uint type)

Static Private Member Functions

static void uncompress (uint16 color, NLMISC::CRGBA &)
 Extracting RGBA infos from a 16bits word.



bool convertToDXTC5 ()
 Change bitmap format.
bool convertToRGBA ()
bool luminanceToRGBA ()
bool alphaToRGBA ()
bool alphaLuminanceToRGBA ()
bool convertToLuminance ()
bool rgbaToLuminance ()
bool alphaToLuminance ()
bool alphaLuminanceToLuminance ()
bool convertToAlpha ()
bool rgbaToAlpha ()
bool luminanceToAlpha ()
bool alphaLuminanceToAlpha ()
bool convertToAlphaLuminance ()
bool rgbaToAlphaLuminance ()
bool luminanceToAlphaLuminance ()
bool alphaToAlphaLuminance ()
CRGBA getDXTC1Texel (sint x, sint y, uint32 numMipMap) const
CRGBA getDXTC3Texel (sint x, sint y, uint32 numMipMap) const
CRGBA getDXTC5Texel (sint x, sint y, uint32 numMipMap) const
static CRGBA getDXTCColorFromBlock (const uint8 *block, sint x, sint y)
 name DXTC single texel read
CObjectVector< uint8 > & getPixels (uint32 numMipMap=0)
 Return the pixels buffer of the image, or of one of its mipmap.
const CObjectVector< uint8 > & getPixels (uint32 numMipMap=0) const
void unattachPixels (CObjectVector< uint8 > *mipmapDestArray, uint maxMipMapCount=MAX_MIPMAP)
 Gain ownership of this texture datas.

Detailed Description

Class Bitmap.

Author:
Stephane Coutelas
Nevrax France
Date:
2000

Definition at line 90 of file bitmap.h.


Member Enumeration Documentation

Enumerator:
RGBA 
Luminance 
Alpha 
AlphaLuminance 
DXTC1 
DXTC1Alpha 
DXTC3 
DXTC5 
DsDt 
ModeCount 
DonTKnow 

Definition at line 266 of file bitmap.h.


Constructor & Destructor Documentation

NLMISC::CBitmap::CBitmap (  )  [inline]

Definition at line 288 of file bitmap.h.

References _Height, _LoadGrayscaleAsAlpha, _MipMapCount, _Width, PixelFormat, and RGBA.

virtual NLMISC::CBitmap::~CBitmap (  )  [inline, virtual]

Definition at line 297 of file bitmap.h.


Member Function Documentation

bool NLMISC::CBitmap::alphaLuminanceToAlpha (  )  [private]
bool NLMISC::CBitmap::alphaLuminanceToLuminance (  )  [private]
bool NLMISC::CBitmap::alphaLuminanceToRGBA (  )  [private]
bool NLMISC::CBitmap::alphaToAlphaLuminance (  )  [private]
bool NLMISC::CBitmap::alphaToLuminance (  )  [private]

Definition at line 757 of file bitmap.cpp.

References _Height, _Width, Luminance, and PixelFormat.

Referenced by convertToLuminance().

bool NLMISC::CBitmap::alphaToRGBA (  )  [private]
void NLMISC::CBitmap::blend ( CBitmap Bm0,
CBitmap Bm1,
uint16  factor,
bool  inputBitmapIsMutable = false 
)

Set this bitmap as the result of the blend bewteen 2 bitmap REQUIRE : - Bm0 and Bm1 should have the same size.

  • Both bitmap should be convertible to RGBA pixel format. The result is a RGBA bitmap. NB: this just works with the first mipmaps
    Parameters:
    factor The blend factor. 0 means the result is equal to Bm0, 256 means the result is equal to Bm1
    inputBitmapIsMutable when true, bitmap can be converted in place when needed (no copy done)

blend 4 component at each pass

Definition at line 3631 of file bitmap.cpp.

References _Data, _Height, _Width, convertToRGBA(), NLMISC::CSystemInfo::hasMMX(), nlassert, PixelFormat, resize(), and RGBA.

uint32 NLMISC::CBitmap::blend ( uint32 n0,
uint32 n1,
uint32  coef0 
) [private]

blend 2 integers between 0 and 255 .

Parameters:
n0 first integer
n1 second integer
coef coefficient for the first integer (must be in [0,256])

Definition at line 1431 of file bitmap.cpp.

Referenced by decompressDXT5(), and NL3D::CTextureBlend::doGenerate().

void NLMISC::CBitmap::blit ( const CBitmap src,
sint  srcX,
sint  srcY,
sint  srcWidth,
sint  srcHeight,
sint  destX,
sint  destY 
)

Extended version of blit.

The destinaion of the blit is 'this' bitmap Source and dest rect are clamped as necessary. For now, only RGBA is uspported (an asertion occurs otherwise) mipmap are not updated. IMPORTANT : copy to self is not handled correctly

Definition at line 2530 of file bitmap.cpp.

References getHeight(), getPixels(), getWidth(), nlassert, PixelFormat, and RGBA.

bool NLMISC::CBitmap::blit ( const CBitmap src,
sint32  x,
sint32  y 
)

Perform a simple blit from the source to this bitmap at the (x, y) pos The dimension of the original bitmap are preserved For now, this texture and the source must have the same format With DXTC format, the dest coordinates must be a multiple of 4 mipmap are not rebuild when present IMPORTANT : copy to self is not handled correctly.

Returns:
true if the params were corrects and if the blit occurs. In debug build there's an assertion

Definition at line 2599 of file bitmap.cpp.

References _Data, _Height, _Width, bitPerPixels, DonTKnow, DXTC1, DXTC1Alpha, DXTC3, DXTC5, nlassert, and PixelFormat.

Referenced by NL3D::CTextureGrouped::doGenerate(), and NL3D::CCoarseMeshBuild::expand().

void NLMISC::CBitmap::buildMipMaps (  ) 
uint32 NLMISC::CBitmap::computeNeededMipMapCount (  )  const

Definition at line 1584 of file bitmap.cpp.

References _Height, _MipMapCount, _Width, and NLMISC::isPowerOf2().

Referenced by NL3D::CDriverD3D::generateD3DTexture().

bool NLMISC::CBitmap::convertToAlpha (  )  [private]
bool NLMISC::CBitmap::convertToAlphaLuminance (  )  [private]
bool NLMISC::CBitmap::convertToDXTC5 (  )  [private]

Change bitmap format.

about DXTC1 to DXTC5 : Does nothing if the format is not DXTC1 about alpha encoding : alpha0 == alpha1 code(x,y) == 7 for every (x,y)

about luminance to alpha and alpha to luminance : the buffer keeps unchanged

Definition at line 508 of file bitmap.cpp.

Referenced by convertToType().

bool NLMISC::CBitmap::convertToLuminance (  )  [private]
bool NLMISC::CBitmap::convertToRGBA (  )  [private]
bool NLMISC::CBitmap::convertToType ( CBitmap::TType  type  ) 
bool NLMISC::CBitmap::decompressDXT1 ( bool  alpha  )  [private]
bool NLMISC::CBitmap::decompressDXT3 (  )  [private]
bool NLMISC::CBitmap::decompressDXT5 (  )  [private]

Decompress bitmap compressed with S3TC DXT3 algorithm.

Exceptions:
EAllocationFailure : can't allocate memory.

Definition at line 1293 of file bitmap.cpp.

References _Data, _Height, _MipMapCount, _Width, blend(), NLMISC::CRGBA::blendFromui(), G, NLMISC::MAX_MIPMAP, PixelFormat, NLMISC::CObjectVector< T, EnableObjectBehavior >::resize(), RGBA, NLMISC::CObjectVector< T, EnableObjectBehavior >::size(), and uncompress().

Referenced by convertToRGBA().

void NLMISC::CBitmap::flipDXTC ( bool  vertical  )  [private]
void NLMISC::CBitmap::flipDXTCMipMap ( bool  vertical,
uint  mm,
uint  type 
) [private]
void NLMISC::CBitmap::flipH (  ) 

Horizontal flip (all the columns are flipped) Works only with RGBA, and DXTC formats (only if w/h is a power of 2).

Definition at line 3483 of file bitmap.cpp.

References _Data, _MipMapCount, buildMipMaps(), flipDXTC(), getHeight(), getWidth(), PixelFormat, releaseMipMaps(), and RGBA.

Referenced by NL3D::CDriverGL::setupTextureEx().

void NLMISC::CBitmap::flipHDXTCBlockAlpha3 ( uint8 bitColor,
uint32  w 
) [private]

Definition at line 3230 of file bitmap.cpp.

References INT64_CONSTANT.

Referenced by flipDXTCMipMap().

void NLMISC::CBitmap::flipHDXTCBlockAlpha5 ( uint8 bitColor,
uint32  w 
) [private]

Definition at line 3292 of file bitmap.cpp.

References INT64_CONSTANT.

Referenced by flipDXTCMipMap().

void NLMISC::CBitmap::flipHDXTCBlockColor ( uint8 bitColor,
uint32  w 
) [private]

Definition at line 3187 of file bitmap.cpp.

Referenced by flipDXTCMipMap().

void NLMISC::CBitmap::flipV (  ) 

Vertical flip (all the rows are flipped) Works only with RGBA, and DXTC formats (only if w/h is a power of 2).

Definition at line 3522 of file bitmap.cpp.

References _Data, _MipMapCount, buildMipMaps(), flipDXTC(), getHeight(), getWidth(), PixelFormat, releaseMipMaps(), and RGBA.

Referenced by NL3D::CDriverGL::getBuffer(), readTGA(), and NL3D::CDriverGL::setupTextureEx().

void NLMISC::CBitmap::flipVDXTCBlockAlpha3 ( uint8 bitColor,
uint32  h 
) [private]

Definition at line 3273 of file bitmap.cpp.

References swap().

Referenced by flipDXTCMipMap().

void NLMISC::CBitmap::flipVDXTCBlockAlpha5 ( uint8 bitColor,
uint32  h 
) [private]

Definition at line 3325 of file bitmap.cpp.

References INT64_CONSTANT.

Referenced by flipDXTCMipMap().

void NLMISC::CBitmap::flipVDXTCBlockColor ( uint8 bitColor,
uint32  h 
) [private]

Definition at line 3213 of file bitmap.cpp.

References swap().

Referenced by flipDXTCMipMap().

CRGBAF NLMISC::CBitmap::getColor ( float  x,
float  y,
bool  tileU,
bool  tileV 
) const
CRGBAF NLMISC::CBitmap::getColor ( float  x,
float  y 
) const

Get the color in the bitmap for the first mipmap The mipmaps must be built.

If not just return the bilinear at the given point. NB: coordinates are clamped.

Parameters:
tiled If false coordinate are clamped, else the bitmap is considered to tile

Definition at line 2737 of file bitmap.cpp.

References NLMISC::CRGBAF::A, Alpha, NLMISC::CRGBAF::B, DXTC1, DXTC1Alpha, DXTC3, DXTC5, G, NLMISC::CRGBAF::G, getColorInterp(), getHeight(), getPixelColor(), getPixels(), getWidth(), Luminance, nlassert, PixelFormat, NLMISC::CRGBAF::R, and RGBA.

float NLMISC::CBitmap::getColorInterp ( float  x,
float  y,
float  xy00,
float  xy01,
float  xy10,
float  xy11 
) const [private]

Quadratic interpolator.

Returns:
the interpolation in (x,y) of the values (xy**)

Definition at line 2726 of file bitmap.cpp.

References NLMISC::clamp().

Referenced by getColor().

void NLMISC::CBitmap::getData ( uint8 *&  extractData  ) 

Definition at line 4021 of file bitmap.cpp.

References _Data, _Height, _Width, Alpha, Luminance, nlstop, PixelFormat, and RGBA.

void NLMISC::CBitmap::getDibData ( uint8 *&  extractData  ) 

Definition at line 4039 of file bitmap.cpp.

References _Data, _Height, _Width, Alpha, Luminance, nlstop, PixelFormat, and RGBA.

CRGBA NLMISC::CBitmap::getDXTC1Texel ( sint  x,
sint  y,
uint32  numMipMap 
) const [private]

Definition at line 3868 of file bitmap.cpp.

References NLMISC::CRGBA::Black, getDXTCColorFromBlock(), getHeight(), getPixels(), and getWidth().

Referenced by getPixelColor().

CRGBA NLMISC::CBitmap::getDXTC3Texel ( sint  x,
sint  y,
uint32  numMipMap 
) const [private]

Definition at line 3881 of file bitmap.cpp.

References NLMISC::CRGBA::Black, getDXTCColorFromBlock(), getHeight(), getPixels(), and getWidth().

Referenced by getPixelColor().

CRGBA NLMISC::CBitmap::getDXTC5Texel ( sint  x,
sint  y,
uint32  numMipMap 
) const [private]

Definition at line 3897 of file bitmap.cpp.

References NLMISC::CRGBA::Black, getDXTCColorFromBlock(), getHeight(), getPixels(), and getWidth().

Referenced by getPixelColor().

CRGBA NLMISC::CBitmap::getDXTCColorFromBlock ( const uint8 block,
sint  x,
sint  y 
) [static, private]

name DXTC single texel read

Definition at line 3808 of file bitmap.cpp.

References NLMISC::CRGBA::A, NLMISC::CRGBA::blendFromui(), NLMISC::CRGBA::set(), and uncompress().

Referenced by getDXTC1Texel(), getDXTC3Texel(), and getDXTC5Texel().

uint32 NLMISC::CBitmap::getHeight ( uint32  numMipMap = 0  )  const [virtual]

Return the image height, or a mipmap height.

Parameters:
mipMap mipmap level
Returns:
image height (0 if mipmap not found)

Definition at line 1481 of file bitmap.cpp.

References _Height, and _Width.

Referenced by NL3D::CHLSColorTexture::addMask(), NL3D::CTextureGrouped::areValid(), blit(), NL3D::CLodCharacterTmpBitmap::build(), NL3D::CCoarseMeshBuild::buildBitmap(), NL3D::CTextureFile::buildBitmapFromFile(), NL3D::CHeightMap::buildFromBitmap(), NL3D::CFontManager::computeString(), NL3D::CFastHLSModifier::convertDDSBitmap(), NL3D::CFastHLSModifier::convertDDSBitmapDXTC1Or1A(), NL3D::CFastHLSModifier::convertDDSBitmapDXTC3Or5(), NL3D::CFastHLSModifier::convertRGBABitmap(), NL3D::CTextureGrouped::doGenerate(), NL3D::CTextureCube::doGenerate(), draw2dLine(), NL3D::CCoarseMeshBuild::expand(), NL3D::CDriverGL::fillBuffer(), NL3D::CDriverD3D::fillBuffer(), flipDXTC(), flipDXTCMipMap(), flipH(), flipV(), NL3D::CPatchDLMContext::generate(), NL3D::CDriverD3D::generateD3DTexture(), getColor(), getDXTC1Texel(), getDXTC3Texel(), getDXTC5Texel(), getRGBAPixel(), getSize(), NL3D::GetTextureSize(), NL3D::CTileBank::getTileNoiseMap(), NL3D::CTextureDrvInfosGL::initFrameBufferObject(), NL3D::CDriverGL::isTextureRectangle(), NL3D::CZoneLighter::lightWater(), CEGUI::NeLTexture::loadFromFile(), NL3D::CShapeBank::processWSUploadTexture(), RenderTriangle(), rot90CCW(), rot90CW(), NL3D::CHLSColorTexture::setBitmap(), NL3D::CDriverGL::setupTextureEx(), NL3D::CDriverGL::uploadTexture(), NL3D::CDriverD3D::uploadTexture(), and NL3D::CAsyncTextureManager::uploadTexturePart().

uint32 NLMISC::CBitmap::getMipMapCount (  )  const [inline]
CRGBA NLMISC::CBitmap::getPixelColor ( sint  x,
sint  y,
uint32  numMipMap = 0 
) const

Get the pixel at the given coorrdinate.

Works in RGBA and DXTC modes. Outside of the bitmap it returns Black (or if mipmap is not found)

Definition at line 3954 of file bitmap.cpp.

References NLMISC::CRGBA::Black, DXTC1, DXTC1Alpha, DXTC3, DXTC5, getDXTC1Texel(), getDXTC3Texel(), getDXTC5Texel(), getRGBAPixel(), nlstop, PixelFormat, and RGBA.

Referenced by getColor().

TType NLMISC::CBitmap::getPixelFormat (  )  const [inline]
const CObjectVector<uint8>& NLMISC::CBitmap::getPixels ( uint32  numMipMap = 0  )  const [inline]

Definition at line 355 of file bitmap.h.

References _Data.

CObjectVector<uint8>& NLMISC::CBitmap::getPixels ( uint32  numMipMap = 0  )  [inline]

Return the pixels buffer of the image, or of one of its mipmap.

Return a reference of an array in pixel format get with getPixelFormat().

Returns:
CObjectVector<uint8>& RGBA pixels

Definition at line 350 of file bitmap.h.

References _Data.

Referenced by NL3D::CHLSColorTexture::addMask(), blit(), NL3D::CLodCharacterTmpBitmap::build(), NL3D::CTextureFile::buildBitmapFromFile(), NL3D::CHLSColorTexture::buildColorVersion(), NL3D::CHeightMap::buildFromBitmap(), NL3D::CFastHLSModifier::convertDDSBitmapDXTC1Or1A(), NL3D::CFastHLSModifier::convertDDSBitmapDXTC3Or5(), NL3D::CFastHLSModifier::convertRGBABitmap(), NL3D::CTextureDLM::copyRect(), NL3D::CTextureDLM::CTextureDLM(), NL3D::CTextureFont::CTextureFont(), NL3D::CTextureMem::doGenerate(), NL3D::CTextureEmboss::doGenerate(), NL3D::CTextureBump::doGenerate(), draw2dLine(), NL3D::CTextureFont::dumpTextureFont(), NL3D::CCoarseMeshBuild::expand(), NL3D::CDriverGL::fillBuffer(), NL3D::CDriverD3D::fillBuffer(), NL3D::CTextureDLM::fillRect(), NL3D::CDriverGL::getBufferPart(), NL3D::CDriverD3D::getBufferPart(), getColor(), getDXTC1Texel(), getDXTC3Texel(), getDXTC5Texel(), getRGBAPixel(), NL3D::CTileBank::getTileNoiseMap(), NL3D::CZoneLighter::lightWater(), NL3D::CTextureDLM::modulateAndfillRect565(), NL3D::CTextureDLM::modulateAndfillRect8888(), NL3D::CTextureDLM::modulateConstantAndfillRect(), NL3D::CTextureFar::rebuildPatch(), NL3D::CTextureNear::refillRect(), RenderTriangle(), NL3D::CHLSColorTexture::setBitmap(), NL3D::CDriverGL::setupTextureEx(), NL3D::CDriverD3D::setupTextureEx(), NL3D::CDriverGL::uploadTexture(), and NL3D::CDriverD3D::uploadTextureInternal().

CRGBA NLMISC::CBitmap::getRGBAPixel ( sint  x,
sint  y,
uint32  numMipMap 
) const [private]

Definition at line 3798 of file bitmap.cpp.

References NLMISC::CRGBA::Black, getHeight(), getPixels(), and getWidth().

Referenced by getPixelColor().

uint32 NLMISC::CBitmap::getSize ( uint32  numMipMap = 0  )  const

Return the size (in pixels) of the image: <=> getHeight()*getWidth().

Parameters:
mipMap mipmap level
Returns:
image size (0 if mipmap not found)

Definition at line 1505 of file bitmap.cpp.

References getHeight(), and getWidth().

Referenced by NL3D::CShapeBank::processWSUploadTexture(), NL3D::CDriverGL::setupTextureEx(), NL3D::CDriverD3D::setupTextureEx(), NL3D::CAsyncTextureManager::update(), and NL3D::CAsyncTextureManager::uploadTexturePart().

uint32 NLMISC::CBitmap::getWidth ( uint32  numMipMap = 0  )  const [virtual]

Return the image width, or a mipmap width.

Parameters:
mipMap mipmap level
Returns:
image width (0 if mipmap not found)

Definition at line 1456 of file bitmap.cpp.

References _Height, and _Width.

Referenced by NL3D::CHLSColorTexture::addMask(), NL3D::CShadowMapManager::allocateTexture(), NL3D::CTextureGrouped::areValid(), blit(), NL3D::CLodCharacterTmpBitmap::build(), NL3D::CCoarseMeshBuild::buildBitmap(), NL3D::CTextureFile::buildBitmapFromFile(), NL3D::CHeightMap::buildFromBitmap(), NL3D::CFontManager::computeString(), NL3D::CFastHLSModifier::convertDDSBitmap(), NL3D::CFastHLSModifier::convertDDSBitmapDXTC1Or1A(), NL3D::CFastHLSModifier::convertDDSBitmapDXTC3Or5(), NL3D::CFastHLSModifier::convertRGBABitmap(), NL3D::CTextureDLM::copyRect(), NL3D::CTextureGrouped::doGenerate(), NL3D::CTextureCube::doGenerate(), draw2dLine(), NL3D::CCoarseMeshBuild::expand(), NL3D::CDriverGL::fillBuffer(), NL3D::CDriverD3D::fillBuffer(), NL3D::CTextureDLM::fillRect(), flipDXTC(), flipDXTCMipMap(), flipH(), flipV(), NL3D::CPatchDLMContext::generate(), NL3D::CDriverD3D::generateD3DTexture(), getColor(), getDXTC1Texel(), getDXTC3Texel(), getDXTC5Texel(), getRGBAPixel(), getSize(), NL3D::GetTextureSize(), NL3D::CTileBank::getTileNoiseMap(), NL3D::CTextureDrvInfosGL::initFrameBufferObject(), NL3D::CDriverGL::isTextureRectangle(), NL3D::CZoneLighter::lightWater(), CEGUI::NeLTexture::loadFromFile(), NL3D::CTextureDLM::modulateAndfillRect565(), NL3D::CTextureDLM::modulateAndfillRect8888(), NL3D::CTextureDLM::modulateConstantAndfillRect(), NL3D::CShapeBank::processWSUploadTexture(), NL3D::CTextureNear::refillRect(), RenderTriangle(), rot90CCW(), rot90CW(), NL3D::CHLSColorTexture::setBitmap(), NL3D::CDriverGL::setupTextureEx(), NL3D::CDriverGL::uploadTexture(), NL3D::CDriverD3D::uploadTexture(), and NL3D::CAsyncTextureManager::uploadTexturePart().

bool NLMISC::CBitmap::isGrayscaleAsAlpha (  )  const [inline]

Tell if the bitmap loads grayscale bitmap as alpha or luminance format.

Returns:
true if the bitmap loads grayscale bitmaps as alpha, false if it loads grayscale bitmaps as luminance.

Definition at line 545 of file bitmap.h.

References _LoadGrayscaleAsAlpha.

uint8 NLMISC::CBitmap::load ( NLMISC::IStream f,
uint  mipMapSkip = 0 
)

Read a bitmap(TGA or DDS) from an IStream.

Bitmap supported are DDS (DXTC1, DXTC1 with Alpha, DXTC3, DXTC5, and uncompressed TGA (24 and 32 bits).

Parameters:
IStream The stream must be in reading mode.
mipMapSkip if the file is a DDS with mipMap. N=mipMapSkip mipmaps are skipped.
Returns:
image depth (24 or 32), or 0 if load failed
Exceptions:
ESeekFailed : seek has failed

Definition at line 101 of file bitmap.cpp.

References NLMISC::IStream::begin, NLMISC::DDS_HEADER, NLMISC::IStream::isReading(), nlassert, NLMISC::PNG_HEADER, readDDS(), readPNG(), readTGA(), NLMISC::IStream::seek(), and NLMISC::IStream::serial().

Referenced by NL3D::CTextureFile::buildBitmapFromFile(), NL3D::CTextureMem::doGenerate(), and CEGUI::NeLTexture::loadFromFile().

void NLMISC::CBitmap::loadGrayscaleAsAlpha ( bool  loadAsAlpha  )  [inline]

Tell the bitmap to load grayscale bitmap as alpha or luminance format.

Parameters:
loadAsAlpha is true to load grayscale bitmaps as alpha. false to load grayscale bitmaps as luminance. default value is true.

Definition at line 534 of file bitmap.h.

References _LoadGrayscaleAsAlpha.

Referenced by NL3D::CTextureFile::buildBitmapFromFile(), and NL3D::CTileBank::getTileNoiseMap().

void NLMISC::CBitmap::loadSize ( const std::string &  path,
uint32 retWidth,
uint32 retHeight 
) [static]

same than other loadSize(), but with a pathName.

See also:
loadSize()

Definition at line 3176 of file bitmap.cpp.

References loadSize(), and NLMISC::CIFile::open().

void NLMISC::CBitmap::loadSize ( NLMISC::IStream f,
uint32 width,
uint32 height 
) [static]

Determinate the bitmap size from a bitmap(TGA or DDS) from an IStream.

load just header of the file. Bitmap supported are DDS (DXTC1, DXTC1 with Alpha, DXTC3, DXTC5, and uncompressed TGA (24 and 32 bits). NB: at the end, f is seeked to begin.

Parameters:
IStream The stream must be in reading mode.
width the width of the image. 0 if fails.
height the height of the image. 0 if fails.
Exceptions:
ESeekFailed : seek has failed

Definition at line 2981 of file bitmap.cpp.

References NLMISC::IStream::begin, NLMISC::IStream::current, NLMISC::DDS_HEADER, DDSD_LINEARSIZE, NLMISC::IStream::isReading(), NLMISC::JPG_HEADER, NL_MAKEFOURCC, nlassert, NLMISC_BSWAP16, NLMISC_BSWAP32, nlwarning, NLMISC::PNG_HEADER, NLMISC::IStream::seek(), NLMISC::IStream::serial(), and NLMISC::IStream::serialCheck().

Referenced by NL3D::GetTextureSize(), and loadSize().

bool NLMISC::CBitmap::luminanceToAlpha (  )  [private]
bool NLMISC::CBitmap::luminanceToAlphaLuminance (  )  [private]
bool NLMISC::CBitmap::luminanceToRGBA (  )  [private]
void NLMISC::CBitmap::makeDummy (  ) 
void NLMISC::CBitmap::makeDummyFromBitField ( const uint8  bitmap[1024]  )  [private]
void NLMISC::CBitmap::makeNonPowerOf2Dummy (  ) 

Make a dummy "2" texture.

Useful for file not power of 2. Mode is rgba.

Definition at line 231 of file bitmap.cpp.

References makeDummyFromBitField().

Referenced by NL3D::CTextureFile::buildBitmapFromFile().

CBitmap& NLMISC::CBitmap::operator= ( const CBitmap from  )  [inline]
uint8 NLMISC::CBitmap::readDDS ( NLMISC::IStream f,
uint  mipMapSkip 
) [private]

Read a DDS from an IStream.

The bitmap is readen as a set of bytes and stocked compressed. Width and Height are multiple of 4.

Parameters:
IStream The stream must be in reading mode.
Returns:
image depth
Exceptions:
EDDSBadHeader : surface is header is not valid.

Definition at line 301 of file bitmap.cpp.

References _Data, _Height, _MipMapCount, _Width, NLMISC::IStream::current, DDSD_LINEARSIZE, DXTC1, DXTC1Alpha, DXTC1HEADER, DXTC3, DXTC3HEADER, DXTC5, DXTC5HEADER, NLMISC::getPowerOf2(), min, nlwarning, PixelFormat, NLMISC::CObjectVector< T, EnableObjectBehavior >::resize(), NLMISC::IStream::seek(), NLMISC::IStream::serial(), NLMISC::IStream::serialBuffer(), and NLMISC::CObjectVector< T, EnableObjectBehavior >::size().

Referenced by load().

uint8 NLMISC::CBitmap::readPNG ( NLMISC::IStream f  )  [private]
uint8 NLMISC::CBitmap::readTGA ( NLMISC::IStream f  )  [private]

Read a TGA from an IStream.

TGA pictures can be in 24 or 32 bits, RLE or uncompressed

Parameters:
f IStream (must be a reading stream)
Returns:
image depth if succeed, 0 else

Definition at line 1970 of file bitmap.cpp.

References _Data, _Height, _LoadGrayscaleAsAlpha, _MipMapCount, _Width, Alpha, NLMISC::IStream::begin, NLMISC::IStream::end, flipV(), NLMISC::IStream::getPos(), NLMISC::IStream::isReading(), Luminance, nlinfo, PixelFormat, NLMISC::CObjectVector< T, EnableObjectBehavior >::resize(), RGBA, NLMISC::IStream::seek(), NLMISC::IStream::serial(), and NLMISC::IStream::serialBuffer().

Referenced by load().

void NLMISC::CBitmap::releaseMipMaps (  ) 
void NLMISC::CBitmap::resample ( sint32  nNewWidth,
sint32  nNewHeight 
)

Resample the bitmap.

If mipmaps exist they are deleted, then rebuilt after resampling.

Parameters:
nNewWidth width after resample
nNewHeight height after resample

Definition at line 1623 of file bitmap.cpp.

References _Data, _Height, _MipMapCount, _Width, buildMipMaps(), NLMISC::contReset(), nlassert, PixelFormat, releaseMipMaps(), resamplePicture32(), NLMISC::CObjectVector< T, EnableObjectBehavior >::resize(), and RGBA.

Referenced by NL3D::CCoarseMeshBuild::buildBitmap(), NL3D::CDriverD3D::generateD3DTexture(), and NL3D::CDriverGL::setupTextureEx().

void NLMISC::CBitmap::resamplePicture32 ( const NLMISC::CRGBA pSrc,
NLMISC::CRGBA pDest,
sint32  nSrcWidth,
sint32  nSrcHeight,
sint32  nDestWidth,
sint32  nDestHeight 
) [private]

The resample function.

Parameters:
pSrc CRGBA array
pDest CRGBA array for storing resampled texture
nSrcWidth original width
nSrcHeight original height
nDestWidth width after resample
nDestHeight height after resample

Definition at line 1747 of file bitmap.cpp.

References nlassert, and resamplePicture32Fast().

Referenced by resample().

void NLMISC::CBitmap::resamplePicture32Fast ( const NLMISC::CRGBA pSrc,
NLMISC::CRGBA pDest,
sint32  nSrcWidth,
sint32  nSrcHeight,
sint32  nDestWidth,
sint32  nDestHeight 
) [private]

The FAST resample function : works only when reducing the size by two and when the image is square.

Parameters:
pSrc CRGBA array
pDest CRGBA array for storing resampled texture
nSrcWidth original width
nSrcHeight original height
nDestWidth width after resample
nDestHeight height after resample

Definition at line 1937 of file bitmap.cpp.

References NLMISC::CRGBA::avg4(), and nlassert.

Referenced by resamplePicture32().

void NLMISC::CBitmap::reset ( TType  type = RGBA  ) 

Reset the buffer.

Mipmaps are deleted and bitmap is not valid anymore.

Parameters:
type is the new type used for this texture

Definition at line 1728 of file bitmap.cpp.

References _Data, _Height, _MipMapCount, _Width, NLMISC::contReset(), PixelFormat, and NLMISC::CObjectVector< T, EnableObjectBehavior >::resize().

Referenced by NL3D::CHLSColorTexture::buildColorVersion(), NL3D::CDriverGL::getBufferPart(), and NL3D::ITexture::release().

void NLMISC::CBitmap::resize ( sint32  nNewWidth,
sint32  nNewHeight,
TType  newType = DonTKnow,
bool  resetTo0 = true 
)

Resize the bitmap.

If mipmaps exist they are deleted and not rebuilt. This is not a crop. Pixels are lost after resize.

Parameters:
nNewWidth width after resize
nNewHeight height after resize
newType is the new type of the bitmap. If don_t_know, keep the same pixel format that before.
resetTo0 by default the vector are filled by 0. set false to gain performances.

Definition at line 1674 of file bitmap.cpp.

References _Height, _Width, DonTKnow, PixelFormat, releaseMipMaps(), and resizeMipMap().

Referenced by blend(), NL3D::CHLSColorTexture::buildColorVersion(), NL3D::CTextureDLM::CTextureDLM(), NL3D::CTextureFont::CTextureFont(), NL3D::CTextureNear::CTextureNear(), NL3D::CTextureMem::doGenerate(), NL3D::CTextureGrouped::doGenerate(), NL3D::CTextureFar::doGenerate(), NL3D::CTextureEmboss::doGenerate(), NL3D::CTextureBump::doGenerate(), NL3D::CTextureCross::doGenerate(), NL3D::CTextureFont::dumpTextureFont(), NL3D::CCoarseMeshBuild::expand(), NL3D::CDriverGL::getBufferPart(), NL3D::CDriverD3D::getBufferPart(), and readPNG().

void NLMISC::CBitmap::resizeMipMap ( uint32  numMipMap,
sint32  nNewWidth,
sint32  nNewHeight,
bool  resetTo0 = true 
)

ADVANCED USE Resize a single mipmap level.

resize() should have been called before. This is not a crop. Pixels are lost after resize. No validity check is made. It is the user responsabitility fo setup correct mipmap size.

Parameters:
numMipMap id of the mipmap
nNewWidth width after resize
nNewHeight height after resize
resetTo0 by default the vector are filled by 0. set false to gain performances.

Definition at line 1694 of file bitmap.cpp.

References _Data, bitPerPixels, NLMISC::contReset(), NLMISC::CObjectVector< T, EnableObjectBehavior >::fill(), NLMISC::MAX_MIPMAP, nlassert, PixelFormat, and NLMISC::CObjectVector< T, EnableObjectBehavior >::resize().

Referenced by NL3D::CHLSColorTexture::buildColorVersion(), and resize().

bool NLMISC::CBitmap::rgbaToAlpha (  )  [private]
bool NLMISC::CBitmap::rgbaToAlphaLuminance (  )  [private]
bool NLMISC::CBitmap::rgbaToLuminance (  )  [private]
void NLMISC::CBitmap::rot90CCW (  ) 

Rotation of the bitmap of 90 degree in counter clockwise.

Definition at line 3595 of file bitmap.cpp.

References _Data, _Height, _MipMapCount, _Width, buildMipMaps(), NLMISC::contReset(), getHeight(), getWidth(), PixelFormat, releaseMipMaps(), NLMISC::CObjectVector< T, EnableObjectBehavior >::resize(), and RGBA.

void NLMISC::CBitmap::rot90CW (  ) 
void NLMISC::CBitmap::rotateCCW (  ) 

Rotate a bitmap in CCW mode.

See also:
releaseMipMaps().

Definition at line 2504 of file bitmap.cpp.

References _Data, _Height, _Width, Alpha, AlphaLuminance, Luminance, PixelFormat, and RGBA.

void NLMISC::CBitmap::setMipMapCount ( uint32  mmc  ) 

ADVANCED USE To use in conjunction with resizeMipMap.

Setup the correct total number of mipmap No validity check is made. It is the user responsabitility fo setup correct mipmap count.

Definition at line 1719 of file bitmap.cpp.

References _MipMapCount.

Referenced by NL3D::CHLSColorTexture::buildColorVersion().

void NLMISC::CBitmap::swap ( CBitmap other  ) 
void NLMISC::CBitmap::unattachPixels ( CObjectVector< uint8 > *  mipmapDestArray,
uint  maxMipMapCount = MAX_MIPMAP 
)

Gain ownership of this texture datas.

As a result, the bitmap is reseted (put in the same state than when ctor is called, e.g a single mipmap with null size) The CObjectVector objects that contains the bitmap (one per mipmap) datas are 'swapped' with those in the array provided by the caller. NB : The user must provide at least min(getMipMapCount(), maxMipMapCount) entries in the array

Parameters:
mipmapArray Array of mipmap that receive the bitmap datas
maxMipMapCount Max number of mipmap to be copied in the destination array.

Definition at line 3991 of file bitmap.cpp.

References _Data, _Height, _LoadGrayscaleAsAlpha, _MipMapCount, _Width, NLMISC::CObjectVector< T, EnableObjectBehavior >::clear(), min, nlassert, PixelFormat, RGBA, and NLMISC::CObjectVector< T, EnableObjectBehavior >::swap().

void NLMISC::CBitmap::uncompress ( uint16  color,
NLMISC::CRGBA r 
) [inline, static, private]

Extracting RGBA infos from a 16bits word.

(used by S3TC decompression)

Parameters:
color a 16bits integer
r a CRGBA

Definition at line 1443 of file bitmap.cpp.

References NLMISC::CRGBA::A, NLMISC::CRGBA::B, NLMISC::CRGBA::G, and NLMISC::CRGBA::R.

Referenced by decompressDXT1(), decompressDXT3(), decompressDXT5(), and getDXTCColorFromBlock().

bool NLMISC::CBitmap::writeJPG ( NLMISC::IStream f,
uint8  quality = 80 
) [inline]

Write a JPG from the object pixels buffer.

If the current pixel format is not rgba then the method does nothing If the pixel format is Alpha then we save in 8 bpp

Parameters:
f IStream (must be a reading stream)
quality 0=very bad quality 100=best quality
Returns:
true if succeed, false else

Definition at line 726 of file bitmap.h.

References nlwarning.

bool NLMISC::CBitmap::writePNG ( NLMISC::IStream f,
uint32  d = 0 
)

Write a PNG (24 or 32 bits) from the object pixels buffer.

If the current pixel format is not rgba then the method does nothing If the pixel format is Alpha then we save in 8 bpp

Parameters:
f IStream (must be a reading stream)
d depth : 8 or 16 or 24 or 32 (0 for automatic)
Returns:
true if succeed, false else

Definition at line 290 of file bitmap_png.cpp.

References _Data, _Height, _Width, Alpha, NLMISC::IStream::isReading(), Luminance, nlwarning, PixelFormat, RGBA, NLMISC::setPNGError(), NLMISC::setPNGWarning(), and NLMISC::writePNGData().

bool NLMISC::CBitmap::writeTGA ( NLMISC::IStream f,
uint32  d = 0,
bool  upsideDown = false 
)

Write a TGA (24 or 32 bits) from the object pixels buffer.

If the current pixel format is not rgba then the method does nothing If the pixel format is Alpha then we save in 8 bpp

Parameters:
f IStream (must be a reading stream)
d depth : 8 or 16 or 24 or 32 (0 for automatic)
upsideDown if true, the bitmap will be saved with the upside down
Returns:
true if succeed, false else

Definition at line 2319 of file bitmap.cpp.

References _Data, _Height, _Width, Alpha, NLMISC::IStream::isReading(), Luminance, PixelFormat, RGBA, and NLMISC::IStream::serial().

Referenced by NL3D::CTextureFont::dumpTextureFont(), NL3D::CZoneLighter::lightWater(), and NL3D::CNELU::screenshot().


Member Data Documentation

const uint32 NLMISC::CBitmap::DXTC1HEADER = NL_MAKEFOURCC('D','X', 'T', '1') [static]

Definition at line 282 of file bitmap.h.

Referenced by readDDS().

const uint32 NLMISC::CBitmap::DXTC3HEADER = NL_MAKEFOURCC('D','X', 'T', '3') [static]

Definition at line 283 of file bitmap.h.

Referenced by readDDS().

const uint32 NLMISC::CBitmap::DXTC5HEADER = NL_MAKEFOURCC('D','X', 'T', '5') [static]

Definition at line 284 of file bitmap.h.

Referenced by readDDS().


The documentation for this class was generated from the following files:

Generated on Thu Jan 7 08:30:17 2010 for NeL by  doxygen 1.6.1