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

Public Member Functions

 HSVPixel (ushort h, byte s, byte v)
 

Static Public Member Functions

static operator HSVPixel (ARGBPixel p)
 
static operator ARGBPixel (HSVPixel pixel)
 
static operator Color (HSVPixel p)
 
static operator HSVPixel (Color c)
 

Public Attributes

ushort H
 
byte S
 
byte V
 

Constructor & Destructor Documentation

◆ HSVPixel()

BrawlLib.Imaging.HSVPixel.HSVPixel ( ushort  h,
byte  s,
byte  v 
)
inline
219 {
220 H = h;
221 S = s;
222 V = v;
223 }
ushort H
Definition: PixelTypes.cs:215
byte V
Definition: PixelTypes.cs:216
byte S
Definition: PixelTypes.cs:216

Member Function Documentation

◆ operator ARGBPixel()

static BrawlLib.Imaging.HSVPixel.operator ARGBPixel ( HSVPixel  pixel)
inlineexplicitstatic
269 {
270 ARGBPixel newPixel;
271
272 byte v = (byte) (pixel.V * 255 / 100);
273 if (pixel.S == 0)
274 {
275 newPixel = new ARGBPixel(255, v, v, v);
276 }
277 else
278 {
279 int h = pixel.H / 60 % 6;
280 float f = pixel.H / 60.0f - pixel.H / 60;
281
282 byte p = (byte) (pixel.V * (100 - pixel.S) * 255 / 10000);
283 byte q = (byte) (pixel.V * (100 - (int) (f * pixel.S)) * 255 / 10000);
284 byte t = (byte) (pixel.V * (100 - (int) ((1.0f - f) * pixel.S)) * 255 / 10000);
285
286 switch (h)
287 {
288 case 0:
289 newPixel = new ARGBPixel(255, v, t, p);
290 break;
291 case 1:
292 newPixel = new ARGBPixel(255, q, v, p);
293 break;
294 case 2:
295 newPixel = new ARGBPixel(255, p, v, t);
296 break;
297 case 3:
298 newPixel = new ARGBPixel(255, p, q, v);
299 break;
300 case 4:
301 newPixel = new ARGBPixel(255, t, p, v);
302 break;
303 default:
304 newPixel = new ARGBPixel(255, v, p, q);
305 break;
306 }
307 }
308
309 return newPixel;
310 }

◆ operator Color()

static BrawlLib.Imaging.HSVPixel.operator Color ( HSVPixel  p)
inlineexplicitstatic
313 {
314 ARGBPixel np = (ARGBPixel) p;
315 return Color.FromArgb(*(int*) &np);
316 }

◆ operator HSVPixel() [1/2]

static BrawlLib.Imaging.HSVPixel.operator HSVPixel ( ARGBPixel  p)
inlineexplicitstatic
226 {
227 HSVPixel outp;
228
229 int min = Math.Min(Math.Min(p.R, p.G), p.B);
230 int max = Math.Max(Math.Max(p.R, p.G), p.B);
231 int diff = max - min;
232
233 if (diff == 0)
234 {
235 outp.H = 0;
236 outp.S = 0;
237 }
238 else
239 {
240 if (max == p.R)
241 {
242 outp.H = (ushort) ((60 * ((float) (p.G - p.B) / diff) + 360) % 360);
243 }
244 else if (max == p.G)
245 {
246 outp.H = (ushort) (60 * ((float) (p.B - p.R) / diff) + 120);
247 }
248 else
249 {
250 outp.H = (ushort) (60 * ((float) (p.R - p.G) / diff) + 240);
251 }
252
253 if (max == 0)
254 {
255 outp.S = 0;
256 }
257 else
258 {
259 outp.S = (byte) (diff * 100 / max);
260 }
261 }
262
263 outp.V = (byte) (max * 100 / 255);
264
265 return outp;
266 }
HSVPixel(ushort h, byte s, byte v)
Definition: PixelTypes.cs:218

◆ operator HSVPixel() [2/2]

static BrawlLib.Imaging.HSVPixel.operator HSVPixel ( Color  c)
inlineexplicitstatic
319 {
320 return (HSVPixel) (ARGBPixel) c;
321 }

Member Data Documentation

◆ H

ushort BrawlLib.Imaging.HSVPixel.H

◆ S

byte BrawlLib.Imaging.HSVPixel.S

◆ V

byte BrawlLib.Imaging.HSVPixel.V

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