// Maps image colors to the color map protected void AnalyzePixels() { int len = m_Pixels.Length; int nPix = len / 3; m_IndexedPixels = new byte[nPix]; // Analyze image colors and create color map (original, expensive, Moments Recorder behaviour) if (m_FramesPerColorSample == 0) { nq = new NeuQuant(m_Pixels, len, (int)m_SampleInterval); m_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(m_Pixels[k++] & 0xff, m_Pixels[k++] & 0xff, m_Pixels[k++] & 0xff); m_UsedEntry[index] = true; m_IndexedPixels[i] = (byte)index; } m_Pixels = null; m_ColorDepth = 8; m_PaletteSize = 7; }
// Analyzes image colors and creates color map. protected void AnalyzePixels() { int len = m_Pixels.Length; int nPix = len / 3; m_IndexedPixels = new byte[nPix]; NeuQuant nq = new NeuQuant(m_Pixels, len, (int)m_SampleInterval); m_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(m_Pixels[k++] & 0xff, m_Pixels[k++] & 0xff, m_Pixels[k++] & 0xff); m_UsedEntry[index] = true; m_IndexedPixels[i] = (byte)index; } m_Pixels = null; m_ColorDepth = 8; m_PaletteSize = 7; }
// Analyzes image colors and creates color map. protected void AnalyzePixels() { int len = m_Pixels.Length; int nPix = len / 3; m_IndexedPixels = new byte[nPix]; bool reuseTab = false; if (m_PrevPixels != null) { var delta = 0; for (int i = 0; i < len; i += 3) { if (m_Pixels[i] != m_PrevPixels[i] || m_Pixels[i + 1] != m_PrevPixels[i + 1] || m_Pixels[i + 2] != m_PrevPixels[i + 2]) { delta++; } } var match = 100 - Mathf.Ceil(delta / nPix * 100); reuseTab = match >= 98; } if (!reuseTab) { nq = new NeuQuant(m_Pixels, len, (int)m_SampleInterval); m_ColorTab = nq.Process(); // Create reduced palette } if (m_PrevIndices == null) { m_PrevIndices = new int[nPix]; } // Map image pixels to new palette for (int i = 0; i < nPix; i++) { int index = 0; if (reuseTab && m_PrevPixels != null && m_PrevPixels[3 * i + 0] == m_Pixels[3 * i + 0] && m_PrevPixels[3 * i + 1] == m_Pixels[3 * i + 1] && m_PrevPixels[3 * i + 2] == m_Pixels[3 * i + 2]) { index = m_PrevIndices[i]; } else { index = nq.Map(m_Pixels[3 * i + 0] & 0xff, m_Pixels[3 * i + 1] & 0xff, m_Pixels[3 * i + 2] & 0xff); m_PrevIndices[i] = index; } m_UsedEntry[index] = true; m_IndexedPixels[i] = (byte)index; } this.m_PrevPixels = m_Pixels; m_Pixels = null; m_ColorDepth = 8; m_PaletteSize = 7; }
// Analyzes image colors and creates color map. protected void AnalyzePixels() { int len = m_Pixels.Length; int nPix = len / 3; m_IndexedPixels = new byte[nPix]; NeuQuant nq = new NeuQuant(m_Pixels, len, (int)m_SampleInterval); m_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(m_Pixels[k++] & 0xff, m_Pixels[k++] & 0xff, m_Pixels[k++] & 0xff); m_UsedEntry[index] = true; m_IndexedPixels[i] = (byte)index; } m_Pixels = null; m_ColorDepth = 8; m_PaletteSize = 7; }