| 1054 | } |
| 1055 | |
| 1056 | GBitmap* GBitmap::createPow2Bitmap() const |
| 1057 | { |
| 1058 | if (isPow2(getWidth()) && isPow2(getHeight())) |
| 1059 | return NULL; |
| 1060 | |
| 1061 | AssertFatal(getNumMipLevels() == 1, |
| 1062 | "Cannot have non-pow2 bitmap with miplevels"); |
| 1063 | |
| 1064 | U32 width = getWidth(); |
| 1065 | U32 height = getHeight(); |
| 1066 | |
| 1067 | U32 newWidth = getNextPow2(getWidth()); |
| 1068 | U32 newHeight = getNextPow2(getHeight()); |
| 1069 | |
| 1070 | GBitmap* pReturn = new GBitmap(newWidth, newHeight, false, getFormat()); |
| 1071 | |
| 1072 | U8* pDest = (U8*)pReturn->getAddress(0, 0); |
| 1073 | const U8* pSrc = (const U8*)getAddress(0, 0); |
| 1074 | |
| 1075 | F32 yCoeff = (F32) height / (F32) newHeight; |
| 1076 | F32 xCoeff = (F32) width / (F32) newWidth; |
| 1077 | |
| 1078 | F32 currY = 0.0f; |
| 1079 | for (U32 y = 0; y < newHeight; y++) |
| 1080 | { |
| 1081 | F32 currX = 0.0f; |
| 1082 | //U32 yDestOffset = (pReturn->mWidth * pReturn->mBytesPerPixel) * y; |
| 1083 | //U32 xDestOffset = 0; |
| 1084 | //U32 ySourceOffset = (U32)((mWidth * mBytesPerPixel) * currY); |
| 1085 | //F32 xSourceOffset = 0.0f; |
| 1086 | for (U32 x = 0; x < newWidth; x++) |
| 1087 | { |
| 1088 | pDest = (U8*) pReturn->getAddress(x, y); |
| 1089 | pSrc = (U8*) getAddress((S32)currX, (S32)currY); |
| 1090 | for (U32 p = 0; p < pReturn->mBytesPerPixel; p++) |
| 1091 | { |
| 1092 | pDest[p] = pSrc[p]; |
| 1093 | } |
| 1094 | currX += xCoeff; |
| 1095 | } |
| 1096 | currY += yCoeff; |
| 1097 | } |
| 1098 | |
| 1099 | return pReturn; |
| 1100 | } |
| 1101 | |
| 1102 | void GBitmap::copyChannel( U32 index, GBitmap *outBitmap ) const |
| 1103 | { |
nothing calls this directly
no test coverage detected