MCPcopy Create free account
hub / github.com/DentonW/DevIL / ReadMipmaps

Function ReadMipmaps

DevIL/src-IL/src/il_dds.cpp:836–980  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

834
835
836ILboolean ReadMipmaps(ILuint CompFormat)
837{
838 ILuint i, CompFactor=0;
839 ILubyte Bpp, Channels, Bpc;
840 ILimage *StartImage, *TempImage;
841 ILuint LastLinear;
842 ILuint minW, minH;
843
844 ILboolean isCompressed = IL_FALSE;
845
846 Bpp = iCompFormatToBpp(CompFormat);
847 Channels = iCompFormatToChannelCount(CompFormat);
848 Bpc = iCompFormatToBpc(CompFormat);
849 if (CompFormat == PF_LUMINANCE && Head.RGBBitCount == 16 && Head.RBitMask == 0xFFFF) { //HACK
850 Bpc = 2; Bpp = 2;
851 }
852
853 //This doesn't work for images which first mipmap (= the image
854 //itself) has width or height < 4
855 //if (Head.Flags1 & DDS_LINEARSIZE) {
856 // CompFactor = (Width * Height * Depth * Bpp) / Head.LinearSize;
857 //}
858 switch (CompFormat)
859 {
860 case PF_DXT1:
861 // This is officially 6, we have 8 here because DXT1 may contain alpha.
862 CompFactor = 8;
863 break;
864 case PF_DXT2:
865 case PF_DXT3:
866 case PF_DXT4:
867 case PF_DXT5:
868 CompFactor = 4;
869 break;
870 case PF_RXGB:
871 case PF_3DC:
872 // This is officially 4 for 3dc, but that's bullshit :) There's no
873 // alpha data in 3dc images.
874 CompFactor = 3;
875 break;
876
877 case PF_ATI1N:
878 CompFactor = 2;
879 break;
880 default:
881 CompFactor = 1;
882 }
883
884 StartImage = Image;
885
886 if (!(Head.Flags1 & DDS_MIPMAPCOUNT) || Head.MipMapCount == 0) {
887 //some .dds-files have their mipmap flag set,
888 //but a mipmapcount of 0. Because mipMapCount is an uint, 0 - 1 gives
889 //overflow - don't let this happen:
890 Head.MipMapCount = 1;
891 }
892
893 LastLinear = Head.LinearSize;

Callers 2

iLoadDdsCubemapInternalFunction · 0.85
iLoadDdsInternalFunction · 0.85

Calls 5

iCompFormatToBppFunction · 0.85
iCompFormatToBpcFunction · 0.85
ReadDataFunction · 0.85
DdsDecompressFunction · 0.85

Tested by

no test coverage detected