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

Function ilDxtcDataToSurface

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

* This assumes DxtcData, DxtcFormat, width, height, and depth are valid */

Source from the content-addressed store, hash-verified

1944 * This assumes DxtcData, DxtcFormat, width, height, and depth are valid
1945 */
1946ILAPI ILboolean ILAPIENTRY ilDxtcDataToSurface()
1947{
1948 ILuint CompFormat;
1949
1950 if (iCurImage == NULL || iCurImage->DxtcData == NULL) {
1951 ilSetError(IL_INVALID_PARAM);
1952 return IL_FALSE;
1953 }
1954
1955 if (!(iCurImage->DxtcFormat == IL_DXT1 || iCurImage->DxtcFormat == IL_DXT3
1956 || iCurImage->DxtcFormat == IL_DXT5)) {
1957 ilSetError(IL_INVALID_PARAM); //TODO
1958 return IL_FALSE;
1959 }
1960
1961 //@TODO: is this right for all dxt formats? works for
1962 // DXT1, 3, 5
1963 iCurImage->Bpp = 4;
1964 iCurImage->Bpc = 1;
1965 iCurImage->Bps = iCurImage->Width*iCurImage->Bpp*iCurImage->Bpc;
1966 iCurImage->SizeOfPlane = iCurImage->Height*iCurImage->Bps;
1967 iCurImage->Format = IL_RGBA;
1968 iCurImage->Type = IL_UNSIGNED_BYTE;
1969
1970 if (iCurImage->SizeOfData != iCurImage->SizeOfPlane*iCurImage->Depth) {
1971 iCurImage->SizeOfData = iCurImage->Depth*iCurImage->SizeOfPlane;
1972 if (iCurImage->Data != NULL)
1973 ifree(iCurImage->Data);
1974 iCurImage->Data = NULL;
1975 }
1976
1977 if (iCurImage->Data == NULL) {
1978 iCurImage->Data = (ILubyte*)ialloc(iCurImage->SizeOfData);
1979 }
1980
1981 Image = iCurImage;
1982 Width = iCurImage->Width;
1983 Height = iCurImage->Height;
1984 Depth = iCurImage->Depth;
1985 switch(iCurImage->DxtcFormat)
1986 {
1987 case IL_DXT1: CompFormat = PF_DXT1; break;
1988 case IL_DXT3: CompFormat = PF_DXT3; break;
1989 case IL_DXT5: CompFormat = PF_DXT5; break;
1990 }
1991 CompData = iCurImage->DxtcData;
1992 DdsDecompress(CompFormat); //globals suck...fix this
1993
1994 //@TODO: origin should be set in Decompress()...
1995 iCurImage->Origin = IL_ORIGIN_UPPER_LEFT;
1996 return ilFixCur();
1997}
1998
1999
2000ILAPI ILboolean ILAPIENTRY ilDxtcDataToImage()

Callers 1

ilDxtcDataToImageFunction · 0.85

Calls 3

ilSetErrorFunction · 0.85
DdsDecompressFunction · 0.85
ilFixCurFunction · 0.85

Tested by

no test coverage detected