Class which encapsulates each node in the tree
More...
Class which encapsulates each node in the tree
Definition at line 367 of file OctreeQuantizer.cs.
ImageResizer.Plugins.PrettyGifs.OctreeQuantizer.Octree.OctreeNode.OctreeNode |
( |
int |
level, |
|
|
int |
colorBits, |
|
|
Octree |
octree |
|
) |
| |
|
inline |
Construct the node
- Parameters
-
level | The level in the tree = 0 - 7 |
colorBits | The number of significant color bits in the image |
octree | The tree to which this node belongs |
Definition at line 375 of file OctreeQuantizer.cs.
378 _leaf = ( level == colorBits ) ;
380 _red = _green = _blue = 0 ;
387 _nextReducible = null ;
393 _nextReducible = octree.ReducibleNodes[level] ;
394 octree.ReducibleNodes[level] = this ;
OctreeNode(int level, int colorBits, Octree octree)
Construct the node
void ImageResizer.Plugins.PrettyGifs.OctreeQuantizer.Octree.OctreeNode.AddColor |
( |
Color32 |
pixel, |
|
|
int |
colorBits, |
|
|
int |
level, |
|
|
Octree |
octree |
|
) |
| |
|
inline |
Add a color into the tree
- Parameters
-
pixel | The color |
colorBits | The number of significant color bits |
level | The level in the tree |
octree | The tree to which this node belongs |
Definition at line 406 of file OctreeQuantizer.cs.
413 octree.TrackPrevious ( this ) ;
418 int shift = 7 - level ;
419 int index = ( ( pixel.Red & mask[level] ) >> ( shift - 2 ) ) |
420 ( ( pixel.Green & mask[level] ) >> ( shift - 1 ) ) |
421 ( ( pixel.Blue & mask[level] ) >> ( shift ) ) ;
428 child =
new OctreeNode ( level + 1 , colorBits , octree ) ;
429 _children[index] = child ;
433 child.AddColor ( pixel , colorBits , level + 1 , octree ) ;
void Increment(Color32 pixel)
Increment the pixel count and add to the color information
OctreeNode(int level, int colorBits, Octree octree)
Construct the node
void ImageResizer.Plugins.PrettyGifs.OctreeQuantizer.Octree.OctreeNode.ConstructPalette |
( |
ArrayList |
palette, |
|
|
ref int |
paletteIndex |
|
) |
| |
|
inline |
Traverse the tree, building up the color palette
- Parameters
-
palette | The palette |
paletteIndex | The current palette index |
Definition at line 490 of file OctreeQuantizer.cs.
495 _paletteIndex = paletteIndex++ ;
498 palette.Add ( Color.FromArgb ( _red / _pixelCount , _green / _pixelCount , _blue / _pixelCount ) ) ;
503 for (
int index = 0 ; index < 8 ; index++ )
505 if ( null != _children[index] )
506 _children[index].ConstructPalette ( palette , ref paletteIndex ) ;
OctreeNode ImageResizer.Plugins.PrettyGifs.OctreeQuantizer.Octree.OctreeNode.FindClosestMatch |
( |
Color32 |
pixel | ) |
|
|
inline |
Added may 19-09. Should help with dithering.
- Parameters
-
- Returns
Definition at line 544 of file OctreeQuantizer.cs.
546 if (_leaf)
return this;
548 long min = long.MaxValue;
551 for (
int i = 0; i < _children.Length; i++)
553 if (null != _children[i])
555 long distance = sqr((
long)pixel.Red - _children[i]._red) +
556 sqr((
long)pixel.Green - _children[i]._green) +
557 sqr((
long)pixel.Blue - _children[i]._blue);
562 closest = _children[i];
OctreeNode(int level, int colorBits, Octree octree)
Construct the node
int ImageResizer.Plugins.PrettyGifs.OctreeQuantizer.Octree.OctreeNode.GetPaletteIndex |
( |
Color32 |
pixel, |
|
|
int |
level |
|
) |
| |
|
inline |
Return the palette index for the passed color
Definition at line 514 of file OctreeQuantizer.cs.
516 int paletteIndex = _paletteIndex ;
520 int shift = 7 - level ;
521 int index = ( ( pixel.Red & mask[level] ) >> ( shift - 2 ) ) |
522 ( ( pixel.Green & mask[level] ) >> ( shift - 1 ) ) |
523 ( ( pixel.Blue & mask[level] ) >> ( shift ) ) ;
525 if (null != _children[index])
526 paletteIndex = _children[index].GetPaletteIndex(pixel, level + 1);
533 if (n != null) paletteIndex = n._paletteIndex;
537 return paletteIndex ;
OctreeNode(int level, int colorBits, Octree octree)
Construct the node
OctreeNode FindClosestMatch(Color32 pixel)
Added may 19-09. Should help with dithering.
void ImageResizer.Plugins.PrettyGifs.OctreeQuantizer.Octree.OctreeNode.Increment |
( |
Color32 |
pixel | ) |
|
|
inline |
Increment the pixel count and add to the color information
Definition at line 578 of file OctreeQuantizer.cs.
582 _green += pixel.Green ;
583 _blue += pixel.Blue ;
int ImageResizer.Plugins.PrettyGifs.OctreeQuantizer.Octree.OctreeNode.Reduce |
( |
| ) |
|
|
inline |
Reduce this node by removing all of its children
- Returns
- The number of leaves removed
Definition at line 459 of file OctreeQuantizer.cs.
461 _red = _green = _blue = 0 ;
465 for (
int index = 0 ; index < 8 ; index++ )
467 if ( null != _children[index] )
469 _red += _children[index]._red ;
470 _green += _children[index]._green ;
471 _blue += _children[index]._blue ;
472 _pixelCount += _children[index]._pixelCount ;
474 _children[index] = null ;
482 return ( children - 1 ) ;
OctreeNode [] ImageResizer.Plugins.PrettyGifs.OctreeQuantizer.Octree.OctreeNode.Children |
|
get |
OctreeNode ImageResizer.Plugins.PrettyGifs.OctreeQuantizer.Octree.OctreeNode.NextReducible |
|
getset |
The documentation for this class was generated from the following file: