private void ReadPixels(string path) { var image = path.SourceFrom(); var pixelUtil = new PixelUtil(image); pixelUtil.LockBits(); //if (QuantizationType == ColorQuantizationType.Grayscale) //{ // var quantizer = new GrayscaleQuantizer { MaxColors = MaximumNumberColor }; // IndexedPixels = quantizer.Quantize(pixelUtil.Pixels); // ColorTable = quantizer.ColorTable; //} //else //{ var quantizer = new OctreeQuantizer { MaxColors = MaximumNumberColor }; IndexedPixels = quantizer.Quantize(pixelUtil.Pixels); ColorTable = quantizer.ColorTable; //} pixelUtil.UnlockBits(); }
private void ReadPixels(string path) { NonIndexedPixels = new List <Color>(); var image = path.SourceFrom(); var pixelUtil = new PixelUtil(image); pixelUtil.LockBits(); NonIndexedPixels.AddRange(pixelUtil.GetAllPixels()); pixelUtil.UnlockBits(); }
private void ReadPixels(string path) { var image = path.SourceFrom(); var pixelUtil = new PixelUtil(image); pixelUtil.LockBits(); CurrentTransparentColor = TransparentColor; //if (QuantizationType == ColorQuantizationType.Grayscale) //{ // var quantizer = new GrayscaleQuantizer { MaxColors = MaximumNumberColor }; // IndexedPixels = quantizer.Quantize(pixelUtil.Pixels); // ColorTable = quantizer.ColorTable; //} //else //{ var quantizer = new OctreeQuantizer { MaxColors = MaximumNumberColor, TransparentColor = !IsFirstFrame || UseGlobalColorTable ? CurrentTransparentColor : null }; IndexedPixels = quantizer.Quantize(pixelUtil.Pixels); ColorTable = quantizer.ColorTable; //} pixelUtil.UnlockBits(); if (quantizer.TransparentColor != null) { CurrentTransparentColor = quantizer.TransparentColor; } //I need to signal the other method that I won't need transparency. WillUseTransparency = !IsFirstFrame && CurrentTransparentColor.HasValue && ColorTable.Contains(CurrentTransparentColor.Value); }