ckfinder/_source/Connector/OctreeQuantizer.cs
(开头部分) 13KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
/*
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.
This is sample code and is freely distributable.
*/
using System;
using System.Collections;
using System.Drawing;
using System.Drawing.Imaging;
namespace ImageManipulation
{
/// <summary>
/// Quantize using an Octree
/// </summary>
public class OctreeQuantizer : Quantizer
{
/// <summary>
/// Construct the octree quantizer
/// </summary>
/// <remarks>
/// The Octree quantizer is a two pass algorithm. The initial pass sets up the octree,
/// the second pass quantizes a color based on the nodes in the tree
/// </remarks>
/// <param name="maxColors">The maximum number of colors to return</param>
/// <param name="maxColorBits">The number of significant bits</param>
public OctreeQuantizer ( int maxColors , int maxColorBits ) : base ( false )
{
if ( maxColors > 255 )
throw new ArgumentOutOfRangeException ( "maxColors" , maxColors , "The number of colors should be less than 256" ) ;
if ( ( maxColorBits < 1 ) | ( maxColorBits > 8 ) )
throw new ArgumentOutOfRangeException ( "maxColorBits" , maxColorBits , "This should be between 1 and 8" ) ;
// Construct the octree
_octree = new Octree ( maxColorBits ) ;
_maxColors = maxColors ;
}
/// <summary>
/// Process the pixel in the first pass of the algorithm
/// </summary>
/// <param name="pixel">The pixel to quantize</param>
/// <remarks>
/// This function need only be overridden if your quantize algorithm needs two passes,
/// such as an Octree quantizer.
/// </remarks>
protected override void InitialQuantizePixel ( Color32 pixel )
{
// Add the color to the octree
_octree.AddColor ( pixel ) ;
}
/// <summary>
/// Override this to process the pixel in the second pass of the algorithm
/// </summary>
后面还有 428 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。