# Home    # nevrax.com   
Nevrax
Nevrax.org
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
Docs
 
Documentation  
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  

NLMISC::CBitmap Class Reference

Class Bitmap. More...

#include <bitmap.h>

Inheritance diagram for NLMISC::CBitmap:

NL3D::ITexture NL3D::CTextureBlank NL3D::CTextureBlend NL3D::CTextureBump NL3D::CTextureCross NL3D::CTextureCube NL3D::CTextureDLM NL3D::CTextureFar NL3D::CTextureFile NL3D::CTextureFont NL3D::CTextureGrouped NL3D::CTextureMem NL3D::CTextureMultiFile NL3D::CTextureNear List of all members.

[NOHEADER]

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
CRGBA getDXTCColorFromBlock (const uint8 *block, sint x, sint y)

Public Types

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

Public Methods

 CBitmap ()
virtual ~CBitmap ()
uint8 load (NLMISC::IStream &f, uint mipMapSkip=0)
 Read a bitmap(TGA or DDS) from an IStream. More...

void makeDummy ()
 Make a dummy "?" texture. More...

bool convertToType (TType type)
 Convert bitmap to another type conversion to rgba always work. More...

TType getPixelFormat () const
 Return the format of pixels stored at the present time in the object buffer. More...

virtual uint32 getWidth (uint32 numMipMap=0) const
 Return the image width, or a mipmap width. More...

virtual uint32 getHeight (uint32 numMipMap=0) const
 Return the image height, or a mipmap height. More...

uint32 getSize (uint32 numMipMap=0) const
 Return the size (in pixels) of the image: <=> getHeight()*getWidth(). More...

uint32 getMipMapCount () const
 Return the number of mipmaps. More...

void rotateCCW ()
 Rotate a bitmap in CCW mode. More...

void buildMipMaps ()
 Build the mipmaps of the bitmap if they don't exist. More...

void releaseMipMaps ()
 Release the mipmaps of the bitmap if they exist. More...

void reset (TType type=RGBA)
 Reset the buffer. More...

void resample (sint32 nNewWidth, sint32 nNewHeight)
 Resample the bitmap. More...

void resize (sint32 nNewWidth, sint32 nNewHeight, TType newType=DonTKnow)
 Resize the bitmap. More...

void resizeMipMap (uint32 numMipMap, sint32 nNewWidth, sint32 nNewHeight)
 ADVANCED USE Resize a single mipmap level. More...

void setMipMapCount (uint32 mmc)
 ADVANCED USE To use in conjunction with resizeMipMap. More...

bool writeTGA (NLMISC::IStream &f, uint32 d, bool upsideDown=false)
 Write a TGA (24 or 32 bits) from the object pixels buffer. More...

bool writeJPG (NLMISC::IStream &f, uint8 quality=80)
 Write a JPG from the object pixels buffer. More...

void loadGrayscaleAsAlpha (bool loadAsAlpha)
 Tell the bitmap to load grayscale bitmap as alpha or luminance format. More...

bool isGrayscaleAsAlpha () const
 Tell if the bitmap loads grayscale bitmap as alpha or luminance format. More...

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. More...

CRGBAF getColor (float x, float y) const
 Get the color in the bitmap given a pixel size The mipmaps must be built. More...

CRGBA getPixelColor (sint x, sint y, uint32 numMipMap=0) const
 Get the pixel at the given coorrdinate. More...

void flipH ()
 Horizontal flip (all the columns are flipped). More...

void flipV ()
 Vertical flip (all the rows are flipped). More...

void rot90CW ()
 Rotation of the bitmap of 90 degree in clockwise. More...

void rot90CCW ()
 Rotation of the bitmap of 90 degree in counter clockwise. More...

void blend (const CBitmap &Bm0, const CBitmap &Bm1, uint16 factor)
 Set this bitmap as the result of the blend bewteen 2 bitmap REQUIRE : - Bm0 and Bm1 should have the same size. More...

std::vector< uint8 > & getPixels (uint32 numMipMap=0)
const std::vector< uint8 > & getPixels (uint32 numMipMap=0) const

Static Public Methods

void loadSize (NLMISC::IStream &f, uint32 &width, uint32 &height)
 Determinate the bitmap size from a bitmap(TGA or DDS) from an IStream. More...

void loadSize (const std::string &path, uint32 &retWidth, uint32 &retHeight)
 same than other loadSize(), but with a pathName. More...


Public Attributes

enum NLMISC::CBitmap::TType PixelFormat

Static Public Attributes

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

Protected Attributes

std::vector< uint8_Data [MAX_MIPMAP]
uint8 _MipMapCount
bool _LoadGrayscaleAsAlpha
uint32 _Width
uint32 _Height

Private Methods

uint32 blend (uint32 &n0, uint32 &n1, uint32 coef0)
 blend 2 integers between 0 and 255 . More...

uint8 readDDS (NLMISC::IStream &f, uint mipMapSkip)
 Read a DDS from an IStream. More...

uint8 readTGA (NLMISC::IStream &f)
 Read a TGA from an IStream. More...

bool decompressDXT1 (bool alpha)
 Decompress bitmap compressed with S3TC DXT1 algorithm. More...

bool decompressDXT3 ()
 Decompress bitmap compressed with S3TC DXT3 algorithm. More...

bool decompressDXT5 ()
 Decompress bitmap compressed with S3TC DXT3 algorithm. More...

void resamplePicture32 (const NLMISC::CRGBA *pSrc, NLMISC::CRGBA *pDest, sint32 nSrcWidth, sint32 nSrcHeight, sint32 nDestWidth, sint32 nDestHeight)
 The resample function. More...

float getColorInterp (float x, float y, float xy00, float xy01, float xy10, float xy11) const
 Quadratic interpolator. More...

CRGBA CBitmap::getRGBAPixel (sint x, sint y, uint32 numMipMap) const
bool convertToDXTC5 ()
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 ()

Static Private Methods

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


Detailed Description

Class Bitmap.

Author:
Stephane Coutelas , Nevrax France
Date:
2000

Definition at line 86 of file bitmap.h.


Member Enumeration Documentation

enum NLMISC::CBitmap::TType
 

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

Definition at line 233 of file bitmap.h.

Referenced by getPixelFormat.


Constructor & Destructor Documentation

NLMISC::CBitmap::CBitmap   [inline]
 

Definition at line 253 of file bitmap.h.

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

Referenced by blend, NL3D::CTextureFile::buildBitmapFromFile, NL3D::CTextureMem::CTextureMem, and NL3D::CTextureFont::dumpTextureFont.

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

Definition at line 262 of file bitmap.h.


Member Function Documentation

bool NLMISC::CBitmap::alphaLuminanceToAlpha   [private]
 

Definition at line 726 of file bitmap.cpp.

References _Data, _Height, _MipMapCount, _Width, Alpha, NLMISC::contReset, PixelFormat, and size.

Referenced by convertToAlpha.

bool NLMISC::CBitmap::alphaLuminanceToLuminance   [private]
 

Definition at line 641 of file bitmap.cpp.

References _Data, _Height, _MipMapCount, _Width, NLMISC::contReset, Luminance, PixelFormat, and size.

Referenced by convertToLuminance.

bool NLMISC::CBitmap::alphaLuminanceToRGBA   [private]
 

Definition at line 488 of file bitmap.cpp.

References _Data, _Height, _MipMapCount, _Width, PixelFormat, RGBA, and size.

Referenced by convertToRGBA.

bool NLMISC::CBitmap::alphaToAlphaLuminance   [private]
 

Definition at line 573 of file bitmap.cpp.

References _Data, _Height, _MipMapCount, _Width, AlphaLuminance, PixelFormat, and size.

Referenced by convertToAlphaLuminance.

bool NLMISC::CBitmap::alphaToLuminance   [private]
 

Definition at line 628 of file bitmap.cpp.

References _Height, _Width, Luminance, and PixelFormat.

Referenced by convertToLuminance.

bool NLMISC::CBitmap::alphaToRGBA   [private]
 

Definition at line 460 of file bitmap.cpp.

References _Data, _Height, _MipMapCount, _Width, PixelFormat, RGBA, and size.

Referenced by convertToRGBA.

void NLMISC::CBitmap::blend const CBitmap &    Bm0,
const CBitmap &    Bm1,
uint16    factor
 

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

Definition at line 2751 of file bitmap.cpp.

References _Data, _Height, _Width, CBitmap, nlassert, 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 1291 of file bitmap.cpp.

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

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.

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

Definition at line 2267 of file bitmap.cpp.

References _Data, _Height, _Width, bitPerPixels, DonTKnow, DXTC1, DXTC1Alpha, DXTC3, DXTC5, height, nlassert, PixelFormat, src, width, x, and y.

Referenced by NL3D::CTextureGrouped::doGenerate.

void NLMISC::CBitmap::buildMipMaps  
 

Build the mipmaps of the bitmap if they don't exist.

Work only in RGBA mode...

See also:
releaseMipMaps().

Definition at line 1375 of file bitmap.cpp.

References _Data, _Height, _MipMapCount, _Width, NLMISC::isPowerOf2, PixelFormat, RGBA, and w.

Referenced by NL3D::CTextureMem::doGenerate, flipH, flipV, resample, rot90CCW, and rot90CW.

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

bool NLMISC::CBitmap::convertToAlpha   [private]
 

Definition at line 784 of file bitmap.cpp.

References Alpha, AlphaLuminance, alphaLuminanceToAlpha, Luminance, luminanceToAlpha, RGBA, and rgbaToAlpha.

Referenced by convertToType.

bool NLMISC::CBitmap::convertToAlphaLuminance   [private]
 

Definition at line 815 of file bitmap.cpp.

References Alpha, AlphaLuminance, alphaToAlphaLuminance, Luminance, luminanceToAlphaLuminance, RGBA, and rgbaToAlphaLuminance.

Referenced by convertToType.

bool NLMISC::CBitmap::convertToDXTC5   [private]
 

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 387 of file bitmap.cpp.

Referenced by convertToType.

bool NLMISC::CBitmap::convertToLuminance   [private]
 

Definition at line 753 of file bitmap.cpp.

References Alpha, AlphaLuminance, alphaLuminanceToLuminance, alphaToLuminance, Luminance, RGBA, and rgbaToLuminance.

Referenced by convertToType.

bool NLMISC::CBitmap::convertToRGBA   [private]
 

Definition at line 845 of file bitmap.cpp.

References Alpha, AlphaLuminance, alphaLuminanceToRGBA, alphaToRGBA, decompressDXT1, decompressDXT3, decompressDXT5, DXTC1, DXTC1Alpha, DXTC3, DXTC5, Luminance, luminanceToRGBA, and RGBA.

Referenced by convertToType.

bool NLMISC::CBitmap::convertToType TType    type
 

Convert bitmap to another type conversion to rgba always work.

No-op if already rgba.

Parameters:
type  new type for the bitmap
Returns:
true if conversion succeeded, false else

Definition at line 889 of file bitmap.cpp.

References Alpha, AlphaLuminance, convertToAlpha, convertToAlphaLuminance, convertToDXTC5, convertToLuminance, convertToRGBA, DXTC5, Luminance, PixelFormat, RGBA, and type.

Referenced by NL3D::CHLSColorTexture::addMask, NL3D::CLodCharacterTmpBitmap::build, NL3D::CHeightMap::buildFromBitmap, and NL3D::CAsyncTextureManager::CTextureEntry::createCoarseBitmap.

bool NLMISC::CBitmap::decompressDXT1 bool    alpha [private]
 

Decompress bitmap compressed with S3TC DXT1 algorithm.

Parameters:
alpha  if alpha is true there's alpha.

Definition at line 928 of file bitmap.cpp.

References _Data, _Height, _MipMapCount, _Width, NLMISC::CRGBA::A, alpha, NLMISC::CRGBA::B, NLMISC::CRGBA::blendFromui, NLMISC::CRGBA::G, height, NLMISC::MAX_MIPMAP, PixelFormat, NLMISC::CRGBA::R, RGBA, NLMISC::CRGBA::set, src, uncompress, width, x, and y.

Referenced by convertToRGBA.

bool NLMISC::CBitmap::decompressDXT3   [private]
 

Decompress bitmap compressed with S3TC DXT3 algorithm.

Exceptions:
EAllocationFailure  : can't allocate memory.

Definition at line 1043 of file bitmap.cpp.

References _Data, _Height, _MipMapCount, _Width, alpha, NLMISC::CRGBA::B, NLMISC::CRGBA::blendFromui, NLMISC::CRGBA::G, height, NLMISC::MAX_MIPMAP, PixelFormat, NLMISC::CRGBA::R, RGBA, src, uncompress, width, x, and y.

Referenced by convertToRGBA.

bool NLMISC::CBitmap::decompressDXT5   [private]
 

Decompress bitmap compressed with S3TC DXT3 algorithm.

Exceptions:
EAllocationFailure  : can't allocate memory.

Definition at line 1153 of file bitmap.cpp.

References _Data, _Height, _MipMapCount, _Width, alpha, NLMISC::CRGBA::B, blend, NLMISC::CRGBA::blendFromui, NLMISC::CRGBA::G, height, NLMISC::MAX_MIPMAP, PixelFormat, NLMISC::CRGBA::R, RGBA, src, uncompress, width, x, and y.

Referenced by convertToRGBA.

void NLMISC::CBitmap::flipH  
 

Horizontal flip (all the columns are flipped).

Definition at line 2615 of file bitmap.cpp.

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

void NLMISC::CBitmap::flipV  
 

Vertical flip (all the rows are flipped).

Definition at line 2647 of file bitmap.cpp.

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

CRGBAF NLMISC::CBitmap::getColor float    x,
float    y
const
 

Get the color in the bitmap given a pixel size The mipmaps must be built.

If not just return the bilinear at the given point. The input x and y must be clamped between 0 and 1

Definition at line 2405 of file bitmap.cpp.

References Alpha, DXTC1, DXTC1Alpha, DXTC3, DXTC5, getColorInterp, getHeight, getPixelColor, getPixels, getWidth, Luminance, nlassert, PixelFormat, RGBA, x, and y.

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 2394 of file bitmap.cpp.

References NLMISC::clamp, res, x, and y.

Referenced by getColor.

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

Definition at line 2888 of file bitmap.cpp.

References getDXTCColorFromBlock, getHeight, getPixels, getWidth, w, x, and y.

Referenced by getPixelColor.

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

Definition at line 2901 of file bitmap.cpp.

References getDXTCColorFromBlock, getHeight, getPixels, getWidth, w, x, and y.

Referenced by getPixelColor.

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

Definition at line 2917 of file bitmap.cpp.

References getDXTCColorFromBlock, getHeight, getPixels, getWidth, w, x, and y.

Referenced by getPixelColor.

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

Definition at line 2830 of file bitmap.cpp.

References uncompress, x, and y.

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 1341 of file bitmap.cpp.

References _Height, _Width, and w.

Referenced by NL3D::CLodCharacterTmpBitmap::build, NL3D::CTextureFile::buildBitmapFromFile, flipH, flipV, getColor, getDXTC1Texel, getDXTC3Texel, getDXTC5Texel, getSize, rot90CCW, rot90CW, and NL3D::CHLSColorTexture::setBitmap.

uint32 NLMISC::CBitmap::getMipMapCount   const [inline]
 

Return the number of mipmaps.

Level0 is a mipmap...

Returns:
number of mipmaps. 0 if no image at all. 1 if no mipmaping (for the base level).

Definition at line 368 of file bitmap.h.

References _MipMapCount.

Referenced by NL3D::CHLSColorTexture::setBitmap.

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 2974 of file bitmap.cpp.

References DXTC1, DXTC1Alpha, DXTC3, DXTC5, getDXTC1Texel, getDXTC3Texel, getDXTC5Texel, nlstop, RGBA, x, and y.

Referenced by getColor.

TType NLMISC::CBitmap::getPixelFormat   const [inline]
 

Return the format of pixels stored at the present time in the object buffer.

Returns:
Pixel format (rgba luminance alpha alphaLuminance dxtc1 dxtc1Alpha dxtc3 dxtc5)

Definition at line 334 of file bitmap.h.

References PixelFormat, and TType.

Referenced by NL3D::CTextureGrouped::doGenerate, NL3D::CTextureFar::rebuildRectangle, and NL3D::CHLSColorTexture::setBitmap.

const std::vector<uint8>& NLMISC::CBitmap::getPixels uint32    numMipMap = 0 const [inline]
 

Definition at line 312 of file bitmap.h.

References _Data.

std::vector<uint8>& NLMISC::CBitmap::getPixels uint32    numMipMap = 0 [inline]
 

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

Returns:
vector<uint8>& RGBA pixels

Definition at line 307 of file bitmap.h.

References _Data.

Referenced by NL3D::CTextureFile::buildBitmapFromFile, NL3D::CHLSColorTexture::buildColorVersion, NL3D::CTextureDLM::copyRect, NL3D::CTextureFont::CTextureFont, NL3D::CTextureMem::doGenerate, NL3D::CTextureBump::doGenerate, NL3D::CTextureFont::dumpTextureFont, NL3D::CTextureDLM::fillRect, getColor, getDXTC1Texel, getDXTC3Texel, getDXTC5Texel, NL3D::CTextureDLM::modulateAndfillRect565, NL3D::CTextureDLM::modulateAndfillRect8888, NL3D::CTextureDLM::modulateConstantAndfillRect, NL3D::CTextureFar::rebuildRectangle, NL3D::CTextureNear::refillRect, and NL3D::CHLSColorTexture::setBitmap.

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 1365 of file bitmap.cpp.

References getHeight, and getWidth.

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 1316 of file bitmap.cpp.

References _Height, _Width, and w.

Referenced by NL3D::CLodCharacterTmpBitmap::build, NL3D::CTextureFile::buildBitmapFromFile, NL3D::CTextureDLM::copyRect, NL3D::CTextureDLM::fillRect, flipH, flipV, getColor, getDXTC1Texel, getDXTC3Texel, getDXTC5Texel, getSize, NL3D::CTextureDLM::modulateAndfillRect565, NL3D::CTextureDLM::modulateAndfillRect8888, NL3D::CTextureDLM::modulateConstantAndfillRect, NL3D::CTextureNear::refillRect, rot90CCW, rot90CW, and NL3D::CHLSColorTexture::setBitmap.

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 480 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 94 of file bitmap.cpp.

References NLMISC::IStream::begin, NLMISC::DDS, depth, height, NLMISC::IStream::isReading, nlassert, readDDS, readTGA, NLMISC::IStream::seek, NLMISC::IStream::serial, NLMISC::IStream::TSeekOrigin, and width.

Referenced by NL3D::CTextureFile::buildBitmapFromFile, and NL3D::CTextureMem::doGenerate.

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 469 of file bitmap.h.

References _LoadGrayscaleAsAlpha.

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 2604 of file bitmap.cpp.

References loadSize.

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 2515 of file bitmap.cpp.

References NLMISC::IStream::begin, NLMISC::DDS, DDSD_LINEARSIZE, depth, height, NLMISC::IStream::isReading, nlassert, NLMISC::IStream::seek, NLMISC::IStream::serial, and width.

Referenced by loadSize.

bool NLMISC::CBitmap::luminanceToAlpha   [private]
 

Definition at line 701 of file bitmap.cpp.

References _Data, _Height, _MipMapCount, _Width, Alpha, PixelFormat, and size.

Referenced by convertToAlpha.

bool NLMISC::CBitmap::luminanceToAlphaLuminance   [private]
 

Definition at line 546 of file bitmap.cpp.

References _Data, _Height, _MipMapCount, _Width, AlphaLuminance, PixelFormat, and size.

Referenced by convertToAlphaLuminance.

bool NLMISC::CBitmap::luminanceToRGBA   [private]
 

Definition at line 433 of file bitmap.cpp.

References _Data, _Height, _MipMapCount, _Width, PixelFormat, RGBA, and size.

Referenced by convertToRGBA.

void NLMISC::CBitmap::makeDummy  
 

Make a dummy "?" texture.

Usefull for file not found. Mode is rgba.

Definition at line 156 of file bitmap.cpp.

References _Data, _Height, _MipMapCount, _Width, PixelFormat, RGBA, and NLMISC::CRGBA::set.

Referenced by NL3D::CTextureFile::buildBitmapFromFile, NL3D::CTextureMultiFile::doGenerate, NL3D::CTextureMem::doGenerate, NL3D::CTextureGrouped::doGenerate, NL3D::CTextureBump::doGenerate, and NL3D::CTextureBlend::doGenerate.

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 216 of file bitmap.cpp.

References _Data, _Height, _MipMapCount, _Width, DDSD_LINEARSIZE, DXTC1, DXTC1Alpha, DXTC1HEADER, DXTC3, DXTC3HEADER, DXTC5, DXTC5HEADER, NLMISC::getPowerOf2, min, PixelFormat, NLMISC::IStream::seek, NLMISC::IStream::serial, NLMISC::IStream::serialBuffer, and w.

Referenced by load.

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 1749 of file bitmap.cpp.

References _Data, _Height, _LoadGrayscaleAsAlpha, _MipMapCount, _Width, Alpha, NLMISC::IStream::begin, depth, NLMISC::IStream::end, NLMISC::IStream::getPos, height, imageSize, NLMISC::IStream::isReading, Luminance, nlinfo, PixelFormat, r, RGBA, NLMISC::IStream::seek, NLMISC::IStream::serial, NLMISC::IStream::serialBuffer, NLMISC::toto, width, x, and y.

Referenced by load.

void NLMISC::CBitmap::releaseMipMaps  
 

Release the mipmaps of the bitmap if they exist.

Work for any mode.

See also:
buildMipMaps().

Definition at line 1446 of file bitmap.cpp.

References _Data, _MipMapCount, NLMISC::contReset, and NLMISC::MAX_MIPMAP.

Referenced by NL3D::CAsyncTextureManager::CTextureEntry::createCoarseBitmap, NL3D::CTextureBump::doGenerate, flipH, flipV, resample, resize, rot90CCW, and rot90CW.

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 1461 of file bitmap.cpp.

References _Data, _Height, _MipMapCount, _Width, buildMipMaps, NLMISC::contReset, nlassert, PixelFormat, releaseMipMaps, resamplePicture32, and RGBA.

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 1567 of file bitmap.cpp.

References nlassert.

Referenced by resample.

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 1548 of file bitmap.cpp.

References _Data, _Height, _MipMapCount, _Width, NLMISC::contReset, PixelFormat, and type.

Referenced by NL3D::CHLSColorTexture::buildColorVersion, and NL3D::ITexture::release.

void NLMISC::CBitmap::resize sint32    nNewWidth,
sint32    nNewHeight,
TType    newType = DonTKnow
 

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.

Definition at line 1498 of file bitmap.cpp.

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

Referenced by blend, NL3D::CHLSColorTexture::buildColorVersion, NL3D::CTextureFont::CTextureFont, NL3D::CTextureMem::doGenerate, NL3D::CTextureGrouped::doGenerate, and NL3D::CTextureCross::doGenerate.

void NLMISC::CBitmap::resizeMipMap uint32    numMipMap,
sint32    nNewWidth,
sint32    nNewHeight
 

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

Definition at line 1518 of file bitmap.cpp.

References _Data, bitPerPixels, NLMISC::contReset, DXTC1, DXTC1Alpha, DXTC3, DXTC5, NLMISC::MAX_MIPMAP, nlassert, and PixelFormat.

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

bool NLMISC::CBitmap::rgbaToAlpha   [private]
 

Definition at line 671 of file bitmap.cpp.

References _Data, _Height, _MipMapCount, _Width, Alpha, NLMISC::contReset, PixelFormat, and size.

Referenced by convertToAlpha.

bool NLMISC::CBitmap::rgbaToAlphaLuminance   [private]
 

Definition at line 518 of file bitmap.cpp.

References _Data, _Height, _MipMapCount, _Width, AlphaLuminance, NLMISC::contReset, PixelFormat, and size.

Referenced by convertToAlphaLuminance.

bool NLMISC::CBitmap::rgbaToLuminance   [private]
 

Definition at line 600 of file bitmap.cpp.

References _Data, _Height, _MipMapCount, _Width, NLMISC::contReset, Luminance, PixelFormat, and size.

Referenced by convertToLuminance.

void NLMISC::CBitmap::rot90CCW  
 

Rotation of the bitmap of 90 degree in counter clockwise.

Definition at line 2714 of file bitmap.cpp.

References _Data, _Height, _MipMapCount, _Width, buildMipMaps, NLMISC::contReset, getHeight, getWidth, PixelFormat, releaseMipMaps, and RGBA.

void NLMISC::CBitmap::rot90CW  
 

Rotation of the bitmap of 90 degree in clockwise.

Definition at line 2679 of file bitmap.cpp.

References _Data, _Height, _MipMapCount, _Width, buildMipMaps, NLMISC::contReset, getHeight, getWidth, PixelFormat, releaseMipMaps, and RGBA.

void NLMISC::CBitmap::rotateCCW  
 

Rotate a bitmap in CCW mode.

See also:
releaseMipMaps().

Definition at line 2241 of file bitmap.cpp.

References _Data, _Height, _Width, Alpha, AlphaLuminance, Luminance, RGBA, and NLMISC::rotateCCW.

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 1539 of file bitmap.cpp.

References _MipMapCount, and uint8.

Referenced by NL3D::CHLSColorTexture::buildColorVersion.

void NLMISC::CBitmap::uncompress uint16    color,
NLMISC::CRGBA  
[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 1303 of file bitmap.cpp.

References NLMISC::CRGBA::A, NLMISC::CRGBA::B, NLMISC::CRGBA::G, NLMISC::CRGBA::R, and 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 616 of file bitmap.h.

References nlwarning.

bool NLMISC::CBitmap::writeTGA NLMISC::IStream   f,
uint32    d,
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
upsideDown  if true, the bitmap will be saved with the upside down
Returns:
true if succeed, false else

Definition at line 2086 of file bitmap.cpp.

References _Data, _Height, _Width, Alpha, depth, height, NLMISC::IStream::isReading, PixelFormat, r, RGBA, NLMISC::IStream::serial, width, x, and y.


Member Data Documentation

std::vector<uint8> NLMISC::CBitmap::_Data[MAX_MIPMAP] [protected]
 

Reimplemented in NL3D::CTextureMem.

Definition at line 89 of file bitmap.h.

Referenced by alphaLuminanceToAlpha, alphaLuminanceToLuminance, alphaLuminanceToRGBA, alphaToAlphaLuminance, alphaToRGBA, blend, blit, buildMipMaps, decompressDXT1, decompressDXT3, decompressDXT5, NL3D::CTextureCross::doGenerate, flipH, flipV, getPixels, luminanceToAlpha, luminanceToAlphaLuminance, luminanceToRGBA, makeDummy, readDDS, readTGA, NL3D::CTextureFont::rebuildLetter, releaseMipMaps, resample, reset, resizeMipMap, rgbaToAlpha, rgbaToAlphaLuminance, rgbaToLuminance, rot90CCW, rot90CW, rotateCCW, and writeTGA.

uint32 NLMISC::CBitmap::_Height [protected]
 

Definition at line 95 of file bitmap.h.

Referenced by alphaLuminanceToAlpha, alphaLuminanceToLuminance, alphaLuminanceToRGBA, alphaToAlphaLuminance, alphaToLuminance, alphaToRGBA, blend, blit, buildMipMaps, CBitmap, decompressDXT1, decompressDXT3, decompressDXT5, NL3D::CTextureFar::doGenerate, getHeight, getWidth, luminanceToAlpha, luminanceToAlphaLuminance, luminanceToRGBA, makeDummy, readDDS, readTGA, NL3D::CTextureFar::rebuildRectangle, resample, reset, resize, rgbaToAlpha, rgbaToAlphaLuminance, rgbaToLuminance, rot90CCW, rot90CW, rotateCCW, and writeTGA.

bool NLMISC::CBitmap::_LoadGrayscaleAsAlpha [protected]
 

Definition at line 93 of file bitmap.h.

Referenced by CBitmap, isGrayscaleAsAlpha, loadGrayscaleAsAlpha, and readTGA.

uint8 NLMISC::CBitmap::_MipMapCount [protected]
 

Definition at line 92 of file bitmap.h.

Referenced by alphaLuminanceToAlpha, alphaLuminanceToLuminance, alphaLuminanceToRGBA, alphaToAlphaLuminance, alphaToRGBA, buildMipMaps, CBitmap, decompressDXT1, decompressDXT3, decompressDXT5, flipH, flipV, getMipMapCount, luminanceToAlpha, luminanceToAlphaLuminance, luminanceToRGBA, makeDummy, readDDS, readTGA, releaseMipMaps, resample, reset, rgbaToAlpha, rgbaToAlphaLuminance, rgbaToLuminance, rot90CCW, rot90CW, and setMipMapCount.

uint32 NLMISC::CBitmap::_Width [protected]
 

Definition at line 94 of file bitmap.h.

Referenced by alphaLuminanceToAlpha, alphaLuminanceToLuminance, alphaLuminanceToRGBA, alphaToAlphaLuminance, alphaToLuminance, alphaToRGBA, blend, blit, buildMipMaps, CBitmap, decompressDXT1, decompressDXT3, decompressDXT5, NL3D::CTextureFar::doGenerate, getHeight, getWidth, luminanceToAlpha, luminanceToAlphaLuminance, luminanceToRGBA, makeDummy, readDDS, readTGA, NL3D::CTextureFar::rebuildRectangle, resample, reset, resize, rgbaToAlpha, rgbaToAlphaLuminance, rgbaToLuminance, rot90CCW, rot90CW, rotateCCW, and writeTGA.

const uint32 NLMISC::CBitmap::bitPerPixels [static]
 

Initial value:

{
        32,             
        8,              
        8,              
        16,             
        4,              
        4,              
        8,              
        8,              
        16              
}

Definition at line 68 of file bitmap.cpp.

Referenced by blit, and resizeMipMap.

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

Definition at line 81 of file bitmap.cpp.

Referenced by readDDS.

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

Definition at line 82 of file bitmap.cpp.

Referenced by readDDS.

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

Definition at line 83 of file bitmap.cpp.

Referenced by readDDS.

enum NLMISC::CBitmap::TType NLMISC::CBitmap::PixelFormat
 

Referenced by alphaLuminanceToAlpha, alphaLuminanceToLuminance, alphaLuminanceToRGBA, alphaToAlphaLuminance, alphaToLuminance, alphaToRGBA, blit, NL3D::CTextureFile::buildBitmapFromFile, buildMipMaps, CBitmap, convertToType, decompressDXT1, decompressDXT3, decompressDXT5, flipH, flipV, getColor, getPixelFormat, luminanceToAlpha, luminanceToAlphaLuminance, luminanceToRGBA, makeDummy, readDDS, readTGA, resample, reset, resize, resizeMipMap, rgbaToAlpha, rgbaToAlphaLuminance, rgbaToLuminance, rot90CCW, rot90CW, and writeTGA.


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