GBitmap
Engine/source/gfx/bitmap/gBitmap.h
Classes:
Public Static Attributes
Private Attributes
bool
mMipLevelOffsets [c_maxMipLevels]
Private Static Attributes
Public Static Functions
load(const Torque::Path & path)
Load the given bitmap file.
bool
sFindFile(const Torque::Path & path, Torque::Path * outPath)
Find the first file matching the registered extensions skipping the original.
bool
sFindFiles(const Torque::Path & path, Vector< Torque::Path > * outFoundPaths)
Given a path to a file, try all known extensions.
sFindRegInfo(const String & extension)
Returns a space separated string of all registered extensions.
sRegisterFormat(const Registration & reg)
Protected Static Functions
_load(const Torque::Path & path)
_search(const Torque::Path & path)
Public Functions
GBitmap()
~GBitmap()
bool
In general you will want to use this function if there is not a good spot in the bitmap loader(s) to check the alpha value of the pixels.
chopTopMips(U32 mipsToChop)
bool
copyChannel(U32 index, GBitmap * outBitmap)
Copies a color channel by index into the first channel of the output bitmap.
extrudeMipLevels(bool clearBorders)
getChanelValueAt(U32 x, U32 y, U32 chan)
bool
Use these functions to set and get the mHasTransparency value This is used to indicate that this bitmap has pixels that have an alpha value less than 255 (used by the auto-Material mapper)
getSurfaceSize(const U32 mipLevel)
U8 *
getWritableBits(const U32 in_mipLevel)
bool
readBitmap(const String & bmType, Stream & ioStream)
Read a bitmap from a stream.
sampleTexel(F32 u, F32 v, bool retAlpha)
setHasTransparency(bool hasTransparency)
bool
writeBitmap(const String & bmType, Stream & ioStream, U32 compressionLevel)
Write a bitmap to a stream.
Detailed Description
Public Types
Constants
Enumerator
- c_maxMipLevels = 13
The maximum mipmap levels we support.
The current value lets us support up to 4096 x 4096 images.
TextureOp
Enumerator
- Add
- Subtract
Public Static Attributes
Vector< Registration > sRegistrations
Private Attributes
U8 * mBits
U32 mByteSize
U32 mBytesPerPixel
bool mHasTransparency
U32 mHeight
GFXFormat mInternalFormat
U32 mMipLevelOffsets [c_maxMipLevels]
U32 mNumMipLevels
U32 mWidth
Private Static Attributes
const U32 csFileVersion
Public Static Functions
load(const Torque::Path & path)
Load the given bitmap file.
It will try known file extensions if one is not specified. If all else fails it will look up the folder hierarchy for a match.
Important: Don't do something like this...
GBitmap* bitmap; // WRONG TYPE! bitmap = GBitmap::load( filename );
Resources are reference-counted and the smart pointer conversion will release the bitmap and thus render the resulting bitmap pointer invalid! The right way is like this:
Resource<GBitmap> bitmap; // Correct! bitmap = GBitmap::load( filename );
sFindFile(const Torque::Path & path, Torque::Path * outPath)
Find the first file matching the registered extensions skipping the original.
sFindFiles(const Torque::Path & path, Vector< Torque::Path > * outFoundPaths)
Given a path to a file, try all known extensions.
If the file exists on disk, fill in path with the correct extension and return true. Otherwise, return false.
sFindRegInfo(const String & extension)
sGetExtensionList()
Returns a space separated string of all registered extensions.
sRegisterFormat(const Registration & reg)
Protected Static Functions
_load(const Torque::Path & path)
_search(const Torque::Path & path)
Public Functions
GBitmap()
GBitmap(const GBitmap & )
GBitmap(const U32 in_width, const U32 in_height, const bool in_extrudeMipLevels, const GFXFormat in_format)
GBitmap(const U32 in_width, const U32 in_height, const U8 * data)
~GBitmap()
allocateBitmap(const U32 in_width, const U32 in_height, const bool in_extrudeMipLevels, const GFXFormat in_format)
allocateBitmapWithMips(const U32 in_width, const U32 in_height, const U32 in_numMips, const GFXFormat in_format)
checkForTransparency()
In general you will want to use this function if there is not a good spot in the bitmap loader(s) to check the alpha value of the pixels.
This function uses the texture format to loop over the bitmap bits and to check for alpha values less than 255
chopTopMips(U32 mipsToChop)
combine(const GBitmap * bitmapA, const GBitmap * bitmapB, const TextureOp combineOp)
This method will combine bitmapA and bitmapB using the operation specified by combineOp.
The result will be stored in the bitmap that this method is called on. The size of the resulting bitmap will be the larger of A and B. The format of the resulting bitmap will be the format of A or B, whichever has a larger byte size.
note:There are some restrictions on ops and formats that will probably change based on how we use this function.
copyChannel(U32 index, GBitmap * outBitmap)
Copies a color channel by index into the first channel of the output bitmap.
The output bitmap must be the same dimensions as the source.
copyRect(const GBitmap * in, const RectI & srcRect, const Point2I & dstPoint, const U32 srcMipLevel, const U32 dstMipLevel)
createPaddedBitmap()
createPow2Bitmap()
deleteImage()
extrudeMipLevels(bool clearBorders)
extrudeMipLevelsDetail()
fill(const ColorI & rColor)
Fills the first mip level of the bitmap with the specified color.
fillWhite()
An optimized version of fill().
getAddress(const S32 in_x, const S32 in_y, const U32 mipLevel)
getAddress(const S32 in_x, const S32 in_y, const U32 mipLevel)
getBits(const U32 in_mipLevel)
getByteSize()
getBytesPerPixel()
getChanelValueAt(U32 x, U32 y, U32 chan)
getColor(const U32 x, const U32 y, ColorI & rColor)
getDepth(const U32 in_mipLevel)
getFormat()
getHasTransparency()
Use these functions to set and get the mHasTransparency value This is used to indicate that this bitmap has pixels that have an alpha value less than 255 (used by the auto-Material mapper)
getHeight(const U32 in_mipLevel)
getNumMipLevels()
getSurfaceSize(const U32 mipLevel)
getWidth(const U32 in_mipLevel)
getWritableBits(const U32 in_mipLevel)
read(Stream & io_rStream)
readBitmap(const String & bmType, Stream & ioStream)
Read a bitmap from a stream.
Parameters:
bmType | This is a file extension to describe the type of the data [i.e. "png" for PNG file, etc] |
ioStream | The stream to read from |
readMNG(Stream & io_rStream)
sampleTexel(F32 u, F32 v, bool retAlpha)
setColor(const U32 x, const U32 y, const ColorI & rColor)
setFormat(GFXFormat fmt)
setHasTransparency(bool hasTransparency)
swizzle(const Swizzle< T, mapLength > * s)
write(Stream & io_rStream)
writeBitmap(const String & bmType, Stream & ioStream, U32 compressionLevel)
Write a bitmap to a stream.
Parameters:
bmType | This is a file extension to describe the type of the data [i.e. "png" for PNG file, etc] |
ioStream | The stream to read from |
compressionLevel | Image format-specific compression level. If set to U32_MAX, we use the default compression defined when the format was registered. |
writeMNG(Stream & io_rStream)