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

Function Compress

DevIL/src-IL/src/il_dds-save.cpp:629–915  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

627
628
629ILuint Compress(ILimage *Image, ILenum DXTCFormat)
630{
631 ILushort *Data, Block[16], ex0, ex1, *Runner16, t0, t1;
632 ILuint x, y, z, i, BitMask, DXTCSize;//, Rms1, Rms2;
633 ILubyte *Alpha, AlphaBlock[16], AlphaBitMask[6], /*AlphaOut[16],*/ a0, a1;
634 ILboolean HasAlpha;
635 ILuint Count = 0;
636 ILubyte *Data3Dc, *Runner8, *ByteData, *BlockData;
637
638 if (DXTCFormat == IL_3DC) {
639 Data3Dc = CompressTo88(Image);
640 if (Data3Dc == NULL)
641 return 0;
642
643 Runner8 = Data3Dc;
644
645 for (z = 0; z < Image->Depth; z++) {
646 for (y = 0; y < Image->Height; y += 4) {
647 for (x = 0; x < Image->Width; x += 4) {
648 Get3DcBlock(AlphaBlock, Runner8, Image, x, y, 0);
649 ChooseAlphaEndpoints(AlphaBlock, &a0, &a1);
650 GenAlphaBitMask(a0, a1, AlphaBlock, AlphaBitMask, NULL);
651 iputc(a0);
652 iputc(a1);
653 iwrite(AlphaBitMask, 1, 6);
654
655 Get3DcBlock(AlphaBlock, Runner8, Image, x, y, 1);
656 ChooseAlphaEndpoints(AlphaBlock, &a0, &a1);
657 GenAlphaBitMask(a0, a1, AlphaBlock, AlphaBitMask, NULL);
658 iputc(a0);
659 iputc(a1);
660 iwrite(AlphaBitMask, 1, 6);
661
662 Count += 16;
663 }
664 }
665 Runner8 += Image->Width * Image->Height * 2;
666 }
667 ifree(Data3Dc);
668 }
669
670 else if (DXTCFormat == IL_ATI1N)
671 {
672 ILimage *TempImage;
673
674 if (Image->Bpp != 1) {
675 TempImage = iConvertImage(iCurImage, IL_LUMINANCE, IL_UNSIGNED_BYTE);
676 if (TempImage == NULL)
677 return 0;
678 }
679 else {
680 TempImage = Image;
681 }
682
683 Runner8 = TempImage->Data;
684
685 for (z = 0; z < Image->Depth; z++) {
686 for (y = 0; y < Image->Height; y += 4) {

Callers 2

iSaveDdsInternalFunction · 0.85
ILAPIENTRY ilGetDXTCDataFunction · 0.85

Calls 15

CompressTo88Function · 0.85
Get3DcBlockFunction · 0.85
ChooseAlphaEndpointsFunction · 0.85
GenAlphaBitMaskFunction · 0.85
GetAlphaBlockFunction · 0.85
ilCloseImageFunction · 0.85
ilNVidiaCompressDXTFileFunction · 0.85
CompressTo565Function · 0.85
CompressToRXGBFunction · 0.85
GetBlockFunction · 0.85
ChooseEndpointsFunction · 0.85
CorrectEndDXT1Function · 0.85

Tested by

no test coverage detected