BrawlCrate v0.41
Wii File Editor
Loading...
Searching...
No Matches
Static Public Member Functions | Static Public Attributes | List of all members
BrawlLib.Imaging.NVDXT Class Reference

Static Public Member Functions

static CMPRBlock compressDXT1a (ARGBPixel *img, int imgX, int imgY, int imgW, int imgH)
 
static CMPRBlock optimalCompressDXT1a (ARGBPixel rgba)
 

Static Public Attributes

static readonly byte[,] OMatch5
 
static readonly byte[,] OMatch6
 

Member Function Documentation

◆ compressDXT1a()

static CMPRBlock BrawlLib.Imaging.NVDXT.compressDXT1a ( ARGBPixel img,
int  imgX,
int  imgY,
int  imgW,
int  imgH 
)
inlinestatic
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 {
104 return optimalCompressDXT1a(sPtr[0]);
105 }
106
107 if (!hasAlpha)
108 {
109 return compressDXT1(pBlock);
110 }
111
112 // @@ Handle single RGB, with varying alpha? We need tables for single color compressor in 3 color mode.
113 //else if (rgba.isSingleColorNoAlpha()) { ... }
114
115 float* pointData = stackalloc float[48];
116 Vector3* points = (Vector3*) pointData;
117
118 // read block
119 //Vector3 block[16];
120 int num = extractColorBlockRGBA(pBlock, points);
121
122 // find min and max colors
123 Vector3 maxColor, minColor;
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 {
135 Vector3 t = maxColor;
136 maxColor = minColor;
137 minColor = t;
138 VoidPtr.Swap(&color0, &color1);
139 }
140
141 CMPRBlock block = new CMPRBlock();
142 block._root0._data = color1;
143 block._root1._data = color0;
144 block._lookup = computeIndices3(pBlock, &maxColor, &minColor);
145
146 // optimizeEndPoints(block, dxtBlock);
147
148 return block;
149 }
static CMPRBlock optimalCompressDXT1a(ARGBPixel rgba)
Definition: NVDXT.cs:171
Definition: Vector3.cs:40
Definition: VoidPtr.cs:9
static void Swap(float *p1, float *p2)
Definition: VoidPtr.cs:175
Definition: CMPR.cs:184

◆ optimalCompressDXT1a()

static CMPRBlock BrawlLib.Imaging.NVDXT.optimalCompressDXT1a ( ARGBPixel  rgba)
inlinestatic
172 {
173 if (rgba.A < 128)
174 {
175 CMPRBlock block = new CMPRBlock();
176 block._root0._data = 0;
177 block._root1._data = 0;
178 block._lookup = 0xFFFFFFFF;
179 return block;
180 }
181
182 return optimalCompressDXT1(rgba);
183 }

Member Data Documentation

◆ OMatch5

readonly byte [,] BrawlLib.Imaging.NVDXT.OMatch5
static

◆ OMatch6

readonly byte [,] BrawlLib.Imaging.NVDXT.OMatch6
static

The documentation for this class was generated from the following file: