private void ReadColorsInRunLengthListMode(int localColorPrecision, IBinaryReader reader) { var nColor = Nx * Ny; Colors = new CgmColor[nColor]; // run length list mode var c = 0; while (c < nColor) { var numColors = reader.ReadInt(); var color = reader.ReadColor(localColorPrecision); // don't directly fill the array with numColors in case we // encounter a erroneous CGM file, e.g. SCHEMA03.CGM that // returns an incorrect number of colors; only fill at most // the number of colors left in the array var maxIndex = System.Math.Min(numColors, nColor - c); for (var i = 0; i < maxIndex; i++) { Colors[c++] = color; } if (c > 0 && c % Nx == 0) { // align on word at the end of a line reader.AlignOnWord(); } } }
private void ReadColorsInPackedListMode(int localColorPrecision, IBinaryReader reader) { Colors = new CgmColor[Nx * Ny]; // packed list mode var i = 0; for (var row = 0; row < Ny; row++) { for (var col = 0; col < Nx; col++) { Colors[i++] = reader.ReadColor(localColorPrecision); } // align on word reader.AlignOnWord(); } }