MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / createPaddedBitmap

Method createPaddedBitmap

Engine/source/gfx/bitmap/gBitmap.cpp:1014–1054  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1012}
1013
1014GBitmap* GBitmap::createPaddedBitmap() const
1015{
1016 if (isPow2(getWidth()) && isPow2(getHeight()))
1017 return NULL;
1018
1019 AssertFatal(getNumMipLevels() == 1,
1020 "Cannot have non-pow2 bitmap with miplevels");
1021
1022 U32 width = getWidth();
1023 U32 height = getHeight();
1024
1025 U32 newWidth = getNextPow2(getWidth());
1026 U32 newHeight = getNextPow2(getHeight());
1027
1028 GBitmap* pReturn = new GBitmap(newWidth, newHeight, false, getFormat());
1029
1030 for (U32 i = 0; i < height; i++)
1031 {
1032 U8* pDest = (U8*)pReturn->getAddress(0, i);
1033 const U8* pSrc = (const U8*)getAddress(0, i);
1034
1035 dMemcpy(pDest, pSrc, width * mBytesPerPixel);
1036
1037 pDest += width * mBytesPerPixel;
1038 // set the src pixel to the last pixel in the row
1039 const U8 *pSrcPixel = pDest - mBytesPerPixel;
1040
1041 for(U32 j = width; j < newWidth; j++)
1042 for(U32 k = 0; k < mBytesPerPixel; k++)
1043 *pDest++ = pSrcPixel[k];
1044 }
1045
1046 for(U32 i = height; i < newHeight; i++)
1047 {
1048 U8* pDest = (U8*)pReturn->getAddress(0, i);
1049 U8* pSrc = (U8*)pReturn->getAddress(0, height-1);
1050 dMemcpy(pDest, pSrc, newWidth * mBytesPerPixel);
1051 }
1052
1053 return pReturn;
1054}
1055
1056GBitmap* GBitmap::createPow2Bitmap() const
1057{

Callers

nothing calls this directly

Calls 6

isPow2Function · 0.85
getWidthFunction · 0.85
getNextPow2Function · 0.85
getAddressMethod · 0.80
getHeightFunction · 0.50
dMemcpyFunction · 0.50

Tested by

no test coverage detected