| 890 | } |
| 891 | |
| 892 | GBitmap *GFXTextureManager::loadUncompressedTexture(const Torque::Path &path, GFXTextureProfile *profile, U32 width, U32 height, bool genMips) |
| 893 | { |
| 894 | GBitmap* inBitmap = loadUncompressedTexture(path, &GFXTexturePersistentProfile); |
| 895 | |
| 896 | if (inBitmap == NULL) |
| 897 | { |
| 898 | Con::warnf("GFXTextureManager::loadUncompressedTexture unable to load texture: %s", path.getFullPath().c_str()); |
| 899 | return NULL; |
| 900 | } |
| 901 | |
| 902 | // Set the format so we don't have to handle which channels are where. |
| 903 | if (!inBitmap->setFormat(GFXFormatR8G8B8A8)) |
| 904 | { |
| 905 | Con::warnf("GFXTextureManager::loadUncompressedTexture unable to handle texture format: %s", path.getFullPath().c_str()); |
| 906 | return NULL; |
| 907 | } |
| 908 | |
| 909 | GBitmap* outBmp = new GBitmap(width, height, true, GFXFormatR8G8B8A8); |
| 910 | |
| 911 | U8* oBits = (U8*)outBmp->getWritableBits(); |
| 912 | for (S32 y = 0; y < width; y++) |
| 913 | { |
| 914 | for (S32 x = 0; x < height; x++) |
| 915 | { |
| 916 | ColorI texelColor = inBitmap->sampleTexel(x / F32(width), y / F32(height), true).toColorI(true); |
| 917 | |
| 918 | oBits[(y * width + x) * 4] = texelColor.red; |
| 919 | oBits[(y * width + x) * 4 + 1] = texelColor.green; |
| 920 | oBits[(y * width + x) * 4 + 2] = texelColor.blue; |
| 921 | oBits[(y * width + x) * 4 + 3] = texelColor.alpha; |
| 922 | } |
| 923 | } |
| 924 | |
| 925 | if (genMips) |
| 926 | outBmp->extrudeMipLevels(); |
| 927 | |
| 928 | return outBmp; |
| 929 | } |
| 930 | |
| 931 | GBitmap *GFXTextureManager::loadUncompressedTexture(const Torque::Path &path, GFXTextureProfile *profile) |
| 932 | { |
no test coverage detected