74 {
75 uint* pData = stackalloc uint[16];
76 ARGBPixel* pBlock = (ARGBPixel*) pData;
77
78 bool hasAlpha = false;
79 bool isSingle = true;
80
81 ARGBPixel p;
82 ARGBPixel* sPtr = img + (imgX + imgY * imgW);
83 int index = 0;
84 for (int y = 0; y < 4; y++)
85 {
86 for (int x = 0; x < 4; x++)
87 {
88 p = sPtr[x + y * imgW];
89 pBlock[index++] = p;
90 if (p != pBlock[0])
91 {
92 isSingle = false;
93 }
94
95 if (p.A < 128)
96 {
97 hasAlpha = true;
98 }
99 }
100 }
101
102 if (isSingle)
103 {
105 }
106
107 if (!hasAlpha)
108 {
109 return compressDXT1(pBlock);
110 }
111
112
113
114
115 float* pointData = stackalloc float[48];
117
118
119
120 int num = extractColorBlockRGBA(pBlock, points);
121
122
124 findMinMaxColorsBox(points, num, &maxColor, &minColor);
125
126 selectDiagonal(points, num, &maxColor, &minColor);
127
128 insetBBox(&maxColor, &minColor);
129
130 ushort color0 = roundAndExpand(&maxColor);
131 ushort color1 = roundAndExpand(&minColor);
132
133 if (color0 < color1)
134 {
136 maxColor = minColor;
137 minColor = t;
139 }
140
142 block._root0._data = color1;
143 block._root1._data = color0;
144 block._lookup = computeIndices3(pBlock, &maxColor, &minColor);
145
146
147
148 return block;
149 }
static CMPRBlock optimalCompressDXT1a(ARGBPixel rgba)
Definition: NVDXT.cs:171
Definition: Vector3.cs:40
static void Swap(float *p1, float *p2)
Definition: VoidPtr.cs:175