/** * Analyzes image colors and creates color map. */ protected void AnalyzePixels() { int len = pixels.Length; int nPix = len / 3; indexedPixels = new byte[nPix]; NeuQuant nq = new NeuQuant(pixels, len, sample); // initialize quantizer colorTab = nq.Process(); // create reduced palette //for (int i = 0; i < colorTab.Length; i++) //{ // if (colorTab[i] == 0) // { // colorTab[i] = 255; // } //} // convert map from BGR to RGB //for (int i = 0; i < colorTab.Length; i += 3) //{ // byte temp = colorTab[i]; // colorTab[i] = colorTab[i + 2]; // colorTab[i + 2] = temp; // usedEntry[i / 3] = false; //} for (int i = 0; i < colorTab.Length; i += 3) { usedEntry[i / 3] = false; } // map image pixels to new palette int k = 0; for (int i = 0; i < nPix; i++) { int index = nq.Map(pixels[k++] & 0xff, pixels[k++] & 0xff, pixels[k++] & 0xff); usedEntry[index] = true; indexedPixels[i] = (byte)index; } pixels = null; colorDepth = 8; palSize = 7; // get closest match to transparent color if specified if (transparent != Color.FromArgb(255, 0, 0, 0)) { transIndex = FindClosest(transparent);//255 } }
public void ConstructorNullArgument() { try { _nq = new NeuQuant(null, 10); } catch (ArgumentNullException ex) { Assert.AreEqual("thePicture", ex.ParamName); throw; } }
// Analyzes image colors and creates color map. private void AnalyzePixels() { int len = _pixels.Length; int nPix = len / 3; _indexedPixels = new byte[nPix]; NeuQuant nq = new NeuQuant(_pixels, len, (int)_sampleInterval); _colorTab = nq.Process(); // Create reduced palette // Map image pixels to new palette int k = 0; for (int i = 0; i < nPix; i++) { int index = nq.Map(_pixels[k++] & 0xff, _pixels[k++] & 0xff, _pixels[k++] & 0xff); _usedEntry[index] = true; _indexedPixels[i] = (byte)index; } _pixels = null; _colorDepth = 8; _paletteSize = 7; }
/** * Analyzes image colors and creates color map. */ protected void AnalyzePixels() { int len = this.pixels.Length; int nPix = len / 3; this.indexedPixels = new byte[nPix]; NeuQuant nq = new NeuQuant(this.pixels, len, this.sample); // initialize quantizer this.colorTab = nq.Process(); // create reduced palette // convert map from BGR to RGB // for (int i = 0; i < colorTab.Length; i += 3) // { // byte temp = colorTab[i]; // colorTab[i] = colorTab[i + 2]; // colorTab[i + 2] = temp; // usedEntry[i / 3] = false; // } // map image pixels to new palette int k = 0; for (int i = 0; i < nPix; i++) { int index = nq.Map(this.pixels[k++] & 0xff, this.pixels[k++] & 0xff, this.pixels[k++] & 0xff); this.usedEntry[index] = true; this.indexedPixels[i] = (byte) index; } this.pixels = null; this.colorDepth = 8; this.palSize = 7; // get closest match to transparent color if specified if (this.transparent != Color.Empty) { this.transIndex = this.FindClosest(this.transparent); } }
/** * Analyzes image colors and creates color map. */ private void AnalyzePixels() { int len = _pixels.Length; int nPix = len/3; _indexedPixels = new byte[nPix]; NeuQuant nq = new NeuQuant(_pixels, len, _sample); // initialize quantizer _colorTab = nq.Process(); // create reduced palette // map image pixels to new palette int k = 0; for (int i = 0; i < nPix; i++) { int index = nq.Map(_pixels[k++] & 0xff, _pixels[k++] & 0xff, _pixels[k++] & 0xff); _usedEntry[index] = true; _indexedPixels[i] = (byte)index; } _pixels = null; _colorDepth = 8; _palSize = 7; // get closest match to transparent color if specified if (_transparent != Color.Empty) _transIndex = FindClosest(_transparent); }
protected void AnalyzePixels() { int len = this.pixels.Length; int nPix = len / 3; this.indexedPixels = new byte[nPix]; NeuQuant nq = new NeuQuant(this.pixels, len, this.sample); // initialize quantizer this.colorTab = nq.Process(); // create reduced palette int k = 0; for (int i = 0; i < nPix; i++) { int index = nq.Map(this.pixels[k++] & 0xff, this.pixels[k++] & 0xff, this.pixels[k++] & 0xff); this.usedEntry[index] = true; this.indexedPixels[i] = (byte) index; } this.pixels = null; this.colorDepth = 8; this.palSize = 7; // get closest match to transparent color if specified if (this.transparent != Color.Empty) { this.transIndex = this.FindClosest(this.transparent); } }