Hjg.Pngcs.PngReader.ReadRow C# (CSharp) Method

ReadRow() public method

reads the row using ImageLine as buffer
public ReadRow ( int nrow ) : Hjg.Pngcs.ImageLine
nrow int row number - just as a check
return Hjg.Pngcs.ImageLine
        public ImageLine ReadRow(int nrow)
        {
            return imgLine == null || imgLine.SampleType != ImageLine.ESampleType.BYTE ? ReadRowInt(nrow) : ReadRowByte(nrow);
        }

Same methods

PngReader::ReadRow ( int buffer, int nrow ) : int[]

Usage Example

Ejemplo n.º 1
0
        public static string[,] buildMatrix(Dictionary<Color, string> dictionary, PngReader reader)
        {
            ImageInfo info = reader.ImgInfo;
            var matrix = new string[info.Cols, info.Rows];

            for (int i = 0; i < info.Rows; i++) {
            ImageLine line = reader.ReadRow(i);
            int[] lineInts = line.Scanline;

            for (int j = 0, col = 0; j < lineInts.Length; j += info.Channels, col++) {
                int red = lineInts[j];
                int green = lineInts[j + 1];
                int blue = lineInts[j + 2];
                int alpha = 255;

                if (info.Channels == 4) {
                    alpha = lineInts[j + 3];
                }

                Color color = new Color(red / 255f, green / 255f, blue / 255f, alpha / 255f);
                string val;
                if (dictionary.TryGetValue(color, out val)) {
                    matrix[col, i] = val;
                }
            }
            }

            return matrix;
        }
All Usage Examples Of Hjg.Pngcs.PngReader::ReadRow