// /// <summary> // /// Tests the encoder with 1,000,000 random pixel values. // /// </summary> // [Test] // public void Test1000000Pixels() // { // ReportStart(); // RandomFill( 1000000 ); // ReportEnd(); // } #endregion #region private RandomFill method /// <summary> /// Fills _ip with random values /// </summary> /// <param name="count"> /// Number of values to add /// </param> private void RandomFill(int count) { Random r = new Random(); for (int blockiness = 1; blockiness < 20; blockiness++) { _ip = new IndexedPixels(); byte[] bytes = new byte[count]; r.NextBytes(bytes); byte lastByte = 0; foreach (byte b in bytes) { // Add a new value to the collection only if we throw a 1 int diceThrow = r.Next(1, blockiness); if (diceThrow == 1) { _ip.Add(b); lastByte = b; } else { // otherwise add the previous value again // (this more accurately simulates colour distribution in // an actual image) _ip.Add(lastByte); } } TestIt(); } }
public void DefaultConstructor() { ReportStart(); byte[] bytes = new byte[] { 24, 39, 2 }; // Test the constructor _ip = new IndexedPixels(); // Test the Add method foreach (byte b in bytes) { _ip.Add(b); } Assert.AreEqual(bytes.Length, _ip.Count); // Test the get accessor of the indexer for (int i = 0; i < bytes.Length; i++) { Assert.AreEqual(bytes[i], _ip[i]); } // Test the set accessor of the indexer _ip[1] = 246; Assert.AreEqual(246, _ip[1]); ReportEnd(); }
/// <summary> /// Gets the indices of the colours of each of the supplied pixels /// within the colour table. /// </summary> /// <param name="pixelColours"> /// A collection of the colours for which to get the indices in the /// colour table. /// </param> /// <returns> /// A collection of the indices of the colours of each of the supplied /// pixels within the colour table. /// </returns> private IndexedPixels GetIndexedPixels(Color[] pixelColours) { IndexedPixels indexedPixels = new IndexedPixels(); // Take a copy of the distinct colours to make the IndexOf method // available string copyDistinctColoursCounterText = "Copying distinct colours"; AddCounter(copyDistinctColoursCounterText, _distinctColours.Count); Collection <Color> distinctColours = new Collection <Color>(); foreach (Color c in _distinctColours.Keys) { MyProgressCounters[copyDistinctColoursCounterText].Value++; distinctColours.Add(c); } RemoveCounter(copyDistinctColoursCounterText); int indexInColourTable; int red; int green; int blue; int numberOfPixels = pixelColours.Length; string indexingPixelsCounterText = "Mapping colours to indices in colour table"; AddCounter(indexingPixelsCounterText, numberOfPixels); for (int i = 0; i < numberOfPixels; i++) { MyProgressCounters[indexingPixelsCounterText].Value = i; red = pixelColours[i].R; green = pixelColours[i].G; blue = pixelColours[i].B; // Get the index in the colour table of the colour of this pixel if (_distinctColours.Count > 256) { indexInColourTable = _nq.Map(red, green, blue); } else { indexInColourTable = distinctColours.IndexOf(pixelColours[i]); } indexedPixels.Add((byte)indexInColourTable); } RemoveCounter(indexingPixelsCounterText); return(indexedPixels); }
public void CapacityConstructorAdd() { ReportStart(); _ip = new IndexedPixels(3); try { _ip.Add(1); } catch (NotSupportedException ex) { string message = "You cannot add pixels to this instance because it was " + "instantiated with a fixed size."; StringAssert.Contains(message, ex.Message); ReportEnd(); throw; } }
/// <summary> /// Converts the supplied image to a collection of pixel indices using /// the supplied colour table. /// Only used when the QuantizerType is set to UseSuppliedPalette /// </summary> /// <param name="act">The active colour table</param> /// <param name="image">The image</param> /// <returns></returns> private IndexedPixels MakeIndexedPixels(ColourTable act, Image image) { //AddCounter( counterText, pixelCount ); Bitmap bitmap = (Bitmap)image; IndexedPixels ip = new IndexedPixels(); for (int y = 0; y < image.Height; y++) { for (int x = 0; x < image.Width; x++) { Color c = bitmap.GetPixel(x, y); int index = FindClosest(c, act); ip.Add((byte)index); //MyProgressCounters[counterText].Value = ip.Count; } } //RemoveCounter( counterText ); return(ip); }
public void BlockTerminatorTest() { ReportStart(); byte[] bytes = new byte[] { 0x08, // LZW minimum code size 0x05, // block size = 5 // 5 bytes of LZW encoded data follows 0x00, 0x51, 0xFC, 0x1B, 0x28, 0x06, // block size = 6 // 6 bytes of LZW encoded data follows 0x70, 0xA0, 0xC1, 0x83, 0x01, 0x01, 0x00, // block terminator - end of table based image data }; MemoryStream s = new MemoryStream(); s.Write( bytes, 0, bytes.Length ); s.Seek( 0, SeekOrigin.Begin ); int pixelCount = WikipediaExample.FrameSize.Width * WikipediaExample.FrameSize.Height; _tbid = new TableBasedImageData( s, pixelCount ); Assert.AreEqual( ErrorState.Ok, _tbid.ConsolidatedState ); Assert.AreEqual( 15, _tbid.Pixels.Count ); Assert.AreEqual( ErrorState.Ok, _tbid.ConsolidatedState ); Assert.AreEqual( 8, _tbid.LzwMinimumCodeSize ); Assert.AreEqual( 9, _tbid.InitialCodeSize ); Assert.AreEqual( Math.Pow( 2, 8 ), _tbid.ClearCode ); Assert.AreEqual( Math.Pow( 2, 8 ) + 1, _tbid.EndOfInformation ); IndexedPixels expectedIndices = new IndexedPixels(); expectedIndices.Add( 40 ); // first pixel is black - index 0 in colour table expectedIndices.Add( 255 ); // 2nd pixel is white - index 255 in colour table expectedIndices.Add( 255 ); // 3rd pixel expectedIndices.Add( 255 ); // 4th pixel expectedIndices.Add( 40 ); // 5th pixel expectedIndices.Add( 255 ); // 6th pixel expectedIndices.Add( 255 ); // 7th pixel expectedIndices.Add( 255 ); // 8th pixel expectedIndices.Add( 255 ); // 9th pixel expectedIndices.Add( 255 ); // 10th pixel expectedIndices.Add( 255 ); // 11th pixel expectedIndices.Add( 255 ); // 12th pixel expectedIndices.Add( 255 ); // 13th pixel expectedIndices.Add( 255 ); // 14th pixel expectedIndices.Add( 255 ); // 15th pixel for( int i = 0; i < 15; i++ ) { Assert.AreEqual( expectedIndices[i], _tbid.Pixels[i], "pixel " + i ); } ReportEnd(); }
private void MissingPixels( bool xmlDebugging ) { byte[] bytes = WikipediaExample.ImageDataBytes; MemoryStream s = new MemoryStream(); s.Write( bytes, 0, bytes.Length ); s.Seek( 0, SeekOrigin.Begin ); // The stream contains 15 pixels, this image size implies 18 pixels _tbid = new TableBasedImageData( s, 18, xmlDebugging ); Assert.AreEqual( 18, _tbid.Pixels.Count ); Assert.AreEqual( ErrorState.TooFewPixelsInImageData, _tbid.ConsolidatedState ); Assert.AreEqual( 8, _tbid.LzwMinimumCodeSize ); Assert.AreEqual( 9, _tbid.InitialCodeSize ); Assert.AreEqual( Math.Pow( 2, 8 ), _tbid.ClearCode ); Assert.AreEqual( Math.Pow( 2, 8 ) + 1, _tbid.EndOfInformation ); IndexedPixels expectedIndices = new IndexedPixels(); expectedIndices.Add( 0 ); // first pixel is black - index 0 in colour table expectedIndices.Add( 1 ); // 2nd pixel is white - index 1 in colour table expectedIndices.Add( 1 ); // 3rd pixel expectedIndices.Add( 1 ); // 4th pixel expectedIndices.Add( 0 ); // 5th pixel expectedIndices.Add( 1 ); // 6th pixel expectedIndices.Add( 1 ); // 7th pixel expectedIndices.Add( 1 ); // 8th pixel expectedIndices.Add( 1 ); // 9th pixel expectedIndices.Add( 1 ); // 10th pixel expectedIndices.Add( 1 ); // 11th pixel expectedIndices.Add( 1 ); // 12th pixel expectedIndices.Add( 1 ); // 13th pixel expectedIndices.Add( 1 ); // 14th pixel expectedIndices.Add( 1 ); // 15th pixel expectedIndices.Add( 0 ); // 16th pixel expectedIndices.Add( 0 ); // 17th pixel expectedIndices.Add( 0 ); // 18th pixel for( int i = 0; i < 18; i++ ) { Assert.AreEqual( expectedIndices[i], _tbid.Pixels[i], "pixel " + i ); } }
private void DataBlockTooShort( bool xmlDebugging ) { byte[] bytes = new byte[] { 0x08, // LZW minimum code size 0x0b, // block size = 11 // 11 bytes of LZW encoded data follows (actually there's only 10 for this test) 0x00, 0x51, 0xFC, 0x1B, 0x28, 0x70, 0xA0, 0xC1, 0x83, 0x01, //0x01, // 0x00 // block terminator }; MemoryStream s = new MemoryStream(); s.Write( bytes, 0, bytes.Length ); s.Seek( 0, SeekOrigin.Begin ); int pixelCount = WikipediaExample.FrameSize.Width * WikipediaExample.FrameSize.Height; _tbid = new TableBasedImageData( s, pixelCount, xmlDebugging ); Assert.AreEqual( 15, _tbid.Pixels.Count ); Assert.AreEqual( ErrorState.DataBlockTooShort | ErrorState.TooFewPixelsInImageData, _tbid.ConsolidatedState ); Assert.AreEqual( 8, _tbid.LzwMinimumCodeSize ); Assert.AreEqual( 9, _tbid.InitialCodeSize ); Assert.AreEqual( Math.Pow( 2, 8 ), _tbid.ClearCode ); Assert.AreEqual( Math.Pow( 2, 8 ) + 1, _tbid.EndOfInformation ); IndexedPixels expectedIndices = new IndexedPixels(); expectedIndices.Add( 0 ); // first pixel expectedIndices.Add( 0 ); // 2nd pixel expectedIndices.Add( 0 ); // 3rd pixel expectedIndices.Add( 0 ); // 4th pixel expectedIndices.Add( 0 ); // 5th pixel expectedIndices.Add( 0 ); // 6th pixel expectedIndices.Add( 0 ); // 7th pixel expectedIndices.Add( 0 ); // 8th pixel expectedIndices.Add( 0 ); // 9th pixel expectedIndices.Add( 0 ); // 10th pixel expectedIndices.Add( 0 ); // 11th pixel expectedIndices.Add( 0 ); // 12th pixel expectedIndices.Add( 0 ); // 13th pixel expectedIndices.Add( 0 ); // 14th pixel expectedIndices.Add( 0 ); // 15th pixel for( int i = 0; i < 15; i++ ) { Assert.AreEqual( expectedIndices[i], _tbid.Pixels[i], "pixel " + i ); } if( xmlDebugging ) { Assert.AreEqual( ExpectedDebugXml, _tbid.DebugXml ); } }
private void CodeNotInDictionary( bool xmlDebugging ) { byte[] bytes = WikipediaExample.ImageDataBytes; bytes[4] = 0xFF; // put an unexpected code into the stream MemoryStream s = new MemoryStream(); s.Write( bytes, 0, bytes.Length ); s.Seek( 0, SeekOrigin.Begin ); int pixelCount = WikipediaExample.FrameSize.Width * WikipediaExample.FrameSize.Height; _tbid = new TableBasedImageData( s, pixelCount, xmlDebugging ); Assert.IsTrue( _tbid.TestState( ErrorState.CodeNotInDictionary ) ); Assert.AreEqual( 15, _tbid.Pixels.Count ); Assert.AreEqual( 8, _tbid.LzwMinimumCodeSize ); Assert.AreEqual( 9, _tbid.InitialCodeSize ); Assert.AreEqual( Math.Pow( 2, 8 ), _tbid.ClearCode ); Assert.AreEqual( Math.Pow( 2, 8 ) + 1, _tbid.EndOfInformation ); IndexedPixels expectedIndices = new IndexedPixels(); // Check all the pixels have been zero-filled expectedIndices.Add( 0 ); // first pixel expectedIndices.Add( 0 ); // 2nd pixel expectedIndices.Add( 0 ); // 3rd pixel expectedIndices.Add( 0 ); // 4th pixel expectedIndices.Add( 0 ); // 5th pixel expectedIndices.Add( 0 ); // 6th pixel expectedIndices.Add( 0 ); // 7th pixel expectedIndices.Add( 0 ); // 8th pixel expectedIndices.Add( 0 ); // 9th pixel expectedIndices.Add( 0 ); // 10th pixel expectedIndices.Add( 0 ); // 11th pixel expectedIndices.Add( 0 ); // 12th pixel expectedIndices.Add( 0 ); // 13th pixel expectedIndices.Add( 0 ); // 14th pixel expectedIndices.Add( 0 ); // 15th pixel for( int i = 0; i < 15; i++ ) { Assert.AreEqual( expectedIndices[i], _tbid.Pixels[i], "pixel " + i ); } if( xmlDebugging ) { Assert.AreEqual( ExpectedDebugXml, _tbid.DebugXml ); } }
/// <summary> /// Fills _ip with random values /// </summary> /// <param name="count"> /// Number of values to add /// </param> private void RandomFill( int count ) { Random r = new Random(); for( int blockiness = 1; blockiness < 20; blockiness++ ) { _ip = new IndexedPixels(); byte[] bytes = new byte[count]; r.NextBytes( bytes ); byte lastByte = 0; foreach( byte b in bytes ) { // Add a new value to the collection only if we throw a 1 int diceThrow = r.Next( 1, blockiness ); if( diceThrow == 1 ) { _ip.Add( b ); lastByte = b; } else { // otherwise add the previous value again // (this more accurately simulates colour distribution in // an actual image) _ip.Add( lastByte ); } } TestIt(); } }
private void DataBlockTooShort(bool xmlDebugging) { byte[] bytes = new byte[] { 0x08, // LZW minimum code size 0x0b, // block size = 11 // 11 bytes of LZW encoded data follows (actually there's only 10 for this test) 0x00, 0x51, 0xFC, 0x1B, 0x28, 0x70, 0xA0, 0xC1, 0x83, 0x01, //0x01, // 0x00 // block terminator }; MemoryStream s = new MemoryStream(); s.Write(bytes, 0, bytes.Length); s.Seek(0, SeekOrigin.Begin); int pixelCount = WikipediaExample.FrameSize.Width * WikipediaExample.FrameSize.Height; _tbid = new TableBasedImageData(s, pixelCount, xmlDebugging); Assert.AreEqual(15, _tbid.Pixels.Count); Assert.AreEqual(ErrorState.DataBlockTooShort | ErrorState.TooFewPixelsInImageData, _tbid.ConsolidatedState); Assert.AreEqual(8, _tbid.LzwMinimumCodeSize); Assert.AreEqual(9, _tbid.InitialCodeSize); Assert.AreEqual(Math.Pow(2, 8), _tbid.ClearCode); Assert.AreEqual(Math.Pow(2, 8) + 1, _tbid.EndOfInformation); IndexedPixels expectedIndices = new IndexedPixels(); expectedIndices.Add(0); // first pixel expectedIndices.Add(0); // 2nd pixel expectedIndices.Add(0); // 3rd pixel expectedIndices.Add(0); // 4th pixel expectedIndices.Add(0); // 5th pixel expectedIndices.Add(0); // 6th pixel expectedIndices.Add(0); // 7th pixel expectedIndices.Add(0); // 8th pixel expectedIndices.Add(0); // 9th pixel expectedIndices.Add(0); // 10th pixel expectedIndices.Add(0); // 11th pixel expectedIndices.Add(0); // 12th pixel expectedIndices.Add(0); // 13th pixel expectedIndices.Add(0); // 14th pixel expectedIndices.Add(0); // 15th pixel for (int i = 0; i < 15; i++) { Assert.AreEqual(expectedIndices[i], _tbid.Pixels[i], "pixel " + i); } if (xmlDebugging) { Assert.AreEqual(ExpectedDebugXml, _tbid.DebugXml); } }
private void CodeNotInDictionary(bool xmlDebugging) { byte[] bytes = WikipediaExample.ImageDataBytes; bytes[4] = 0xFF; // put an unexpected code into the stream MemoryStream s = new MemoryStream(); s.Write(bytes, 0, bytes.Length); s.Seek(0, SeekOrigin.Begin); int pixelCount = WikipediaExample.FrameSize.Width * WikipediaExample.FrameSize.Height; _tbid = new TableBasedImageData(s, pixelCount, xmlDebugging); Assert.IsTrue(_tbid.TestState(ErrorState.CodeNotInDictionary)); Assert.AreEqual(15, _tbid.Pixels.Count); Assert.AreEqual(8, _tbid.LzwMinimumCodeSize); Assert.AreEqual(9, _tbid.InitialCodeSize); Assert.AreEqual(Math.Pow(2, 8), _tbid.ClearCode); Assert.AreEqual(Math.Pow(2, 8) + 1, _tbid.EndOfInformation); IndexedPixels expectedIndices = new IndexedPixels(); // Check all the pixels have been zero-filled expectedIndices.Add(0); // first pixel expectedIndices.Add(0); // 2nd pixel expectedIndices.Add(0); // 3rd pixel expectedIndices.Add(0); // 4th pixel expectedIndices.Add(0); // 5th pixel expectedIndices.Add(0); // 6th pixel expectedIndices.Add(0); // 7th pixel expectedIndices.Add(0); // 8th pixel expectedIndices.Add(0); // 9th pixel expectedIndices.Add(0); // 10th pixel expectedIndices.Add(0); // 11th pixel expectedIndices.Add(0); // 12th pixel expectedIndices.Add(0); // 13th pixel expectedIndices.Add(0); // 14th pixel expectedIndices.Add(0); // 15th pixel for (int i = 0; i < 15; i++) { Assert.AreEqual(expectedIndices[i], _tbid.Pixels[i], "pixel " + i); } if (xmlDebugging) { Assert.AreEqual(ExpectedDebugXml, _tbid.DebugXml); } }
private void MissingPixels(bool xmlDebugging) { byte[] bytes = WikipediaExample.ImageDataBytes; MemoryStream s = new MemoryStream(); s.Write(bytes, 0, bytes.Length); s.Seek(0, SeekOrigin.Begin); // The stream contains 15 pixels, this image size implies 18 pixels _tbid = new TableBasedImageData(s, 18, xmlDebugging); Assert.AreEqual(18, _tbid.Pixels.Count); Assert.AreEqual(ErrorState.TooFewPixelsInImageData, _tbid.ConsolidatedState); Assert.AreEqual(8, _tbid.LzwMinimumCodeSize); Assert.AreEqual(9, _tbid.InitialCodeSize); Assert.AreEqual(Math.Pow(2, 8), _tbid.ClearCode); Assert.AreEqual(Math.Pow(2, 8) + 1, _tbid.EndOfInformation); IndexedPixels expectedIndices = new IndexedPixels(); expectedIndices.Add(0); // first pixel is black - index 0 in colour table expectedIndices.Add(1); // 2nd pixel is white - index 1 in colour table expectedIndices.Add(1); // 3rd pixel expectedIndices.Add(1); // 4th pixel expectedIndices.Add(0); // 5th pixel expectedIndices.Add(1); // 6th pixel expectedIndices.Add(1); // 7th pixel expectedIndices.Add(1); // 8th pixel expectedIndices.Add(1); // 9th pixel expectedIndices.Add(1); // 10th pixel expectedIndices.Add(1); // 11th pixel expectedIndices.Add(1); // 12th pixel expectedIndices.Add(1); // 13th pixel expectedIndices.Add(1); // 14th pixel expectedIndices.Add(1); // 15th pixel expectedIndices.Add(0); // 16th pixel expectedIndices.Add(0); // 17th pixel expectedIndices.Add(0); // 18th pixel for (int i = 0; i < 18; i++) { Assert.AreEqual(expectedIndices[i], _tbid.Pixels[i], "pixel " + i); } }
public void BlockTerminatorTest() { ReportStart(); byte[] bytes = new byte[] { 0x08, // LZW minimum code size 0x05, // block size = 5 // 5 bytes of LZW encoded data follows 0x00, 0x51, 0xFC, 0x1B, 0x28, 0x06, // block size = 6 // 6 bytes of LZW encoded data follows 0x70, 0xA0, 0xC1, 0x83, 0x01, 0x01, 0x00, // block terminator - end of table based image data }; MemoryStream s = new MemoryStream(); s.Write(bytes, 0, bytes.Length); s.Seek(0, SeekOrigin.Begin); int pixelCount = WikipediaExample.FrameSize.Width * WikipediaExample.FrameSize.Height; _tbid = new TableBasedImageData(s, pixelCount); Assert.AreEqual(ErrorState.Ok, _tbid.ConsolidatedState); Assert.AreEqual(15, _tbid.Pixels.Count); Assert.AreEqual(ErrorState.Ok, _tbid.ConsolidatedState); Assert.AreEqual(8, _tbid.LzwMinimumCodeSize); Assert.AreEqual(9, _tbid.InitialCodeSize); Assert.AreEqual(Math.Pow(2, 8), _tbid.ClearCode); Assert.AreEqual(Math.Pow(2, 8) + 1, _tbid.EndOfInformation); IndexedPixels expectedIndices = new IndexedPixels(); expectedIndices.Add(40); // first pixel is black - index 0 in colour table expectedIndices.Add(255); // 2nd pixel is white - index 255 in colour table expectedIndices.Add(255); // 3rd pixel expectedIndices.Add(255); // 4th pixel expectedIndices.Add(40); // 5th pixel expectedIndices.Add(255); // 6th pixel expectedIndices.Add(255); // 7th pixel expectedIndices.Add(255); // 8th pixel expectedIndices.Add(255); // 9th pixel expectedIndices.Add(255); // 10th pixel expectedIndices.Add(255); // 11th pixel expectedIndices.Add(255); // 12th pixel expectedIndices.Add(255); // 13th pixel expectedIndices.Add(255); // 14th pixel expectedIndices.Add(255); // 15th pixel for (int i = 0; i < 15; i++) { Assert.AreEqual(expectedIndices[i], _tbid.Pixels[i], "pixel " + i); } ReportEnd(); }
public void Test1Pixel1() { ReportStart(); _ip.Add(0); TestIt(); ReportEnd(); }
/// <summary> /// Gets the indices of the colours of each of the supplied pixels /// within the colour table. /// </summary> /// <param name="pixelColours"> /// A collection of the colours for which to get the indices in the /// colour table. /// </param> /// <returns> /// A collection of the indices of the colours of each of the supplied /// pixels within the colour table. /// </returns> private IndexedPixels GetIndexedPixels( Color[] pixelColours ) { IndexedPixels indexedPixels = new IndexedPixels(); // Take a copy of the distinct colours to make the IndexOf method // available string copyDistinctColoursCounterText = "Copying distinct colours"; AddCounter( copyDistinctColoursCounterText, _distinctColours.Count ); Collection<Color> distinctColours = new Collection<Color>(); foreach( Color c in _distinctColours.Keys ) { MyProgressCounters[copyDistinctColoursCounterText].Value++; distinctColours.Add( c ); } RemoveCounter( copyDistinctColoursCounterText ); int indexInColourTable; int red; int green; int blue; int numberOfPixels = pixelColours.Length; string indexingPixelsCounterText = "Mapping colours to indices in colour table"; AddCounter( indexingPixelsCounterText, numberOfPixels ); for( int i = 0; i < numberOfPixels; i++ ) { MyProgressCounters[indexingPixelsCounterText].Value = i; red = pixelColours[i].R; green = pixelColours[i].G; blue = pixelColours[i].B; // Get the index in the colour table of the colour of this pixel if( _distinctColours.Count > 256 ) { indexInColourTable = _nq.Map( red, green, blue ); } else { indexInColourTable = distinctColours.IndexOf( pixelColours[i] ); } indexedPixels.Add( (byte) indexInColourTable ); } RemoveCounter( indexingPixelsCounterText ); return indexedPixels; }
/// <summary> /// Converts the supplied image to a collection of pixel indices using /// the supplied colour table. /// Only used when the QuantizerType is set to UseSuppliedPalette /// </summary> /// <param name="act">The active colour table</param> /// <param name="image">The image</param> /// <returns></returns> private IndexedPixels MakeIndexedPixels( ColourTable act, Image image ) { int pixelCount = image.Height * image.Width; string counterText = "Getting indices in colour table"; AddCounter( counterText, pixelCount ); Bitmap bitmap = (Bitmap) image; IndexedPixels ip = new IndexedPixels(); for( int y = 0; y < image.Height; y++ ) { for( int x = 0; x < image.Width; x++ ) { Color c = bitmap.GetPixel( x, y ); int index = FindClosest( c, act ); ip.Add( (byte) index ); MyProgressCounters[counterText].Value = ip.Count; } } RemoveCounter( counterText ); return ip; }