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

ReadRowByte() public method

public ReadRowByte ( byte buffer, int nrow ) : byte[]
buffer byte
nrow int
return byte[]
        public byte[] ReadRowByte(byte[] buffer, int nrow)
        {
            if (buffer == null)
                buffer = new byte[unpackedMode ? ImgInfo.SamplesPerRow : ImgInfo.SamplesPerRowPacked];
            if (!interlaced) {
                if (nrow <= rowNum)
                    throw new PngjInputException("rows must be read in increasing order: " + nrow);
                int bytesread = 0;
                while (rowNum < nrow)
                    bytesread = ReadRowRaw(rowNum + 1); // read rows, perhaps skipping if necessary
                decodeLastReadRowToByte(buffer, bytesread);
            } else { // interlaced
                if (deinterlacer.getImageByte() == null)
                    deinterlacer.setImageByte(ReadRowsByte().ScanlinesB); // read all image and store it in deinterlacer
                Array.Copy(deinterlacer.getImageByte()[nrow], 0, buffer, 0, unpackedMode ? ImgInfo.SamplesPerRow
                        : ImgInfo.SamplesPerRowPacked);
            }
            return buffer;
        }

Same methods

PngReader::ReadRowByte ( int nrow ) : Hjg.Pngcs.ImageLine

Usage Example

コード例 #1
0
    bool ReadImage( PngReader _png )
    {
        /*
        ImageLine line = pngr.ReadRowInt( y );
        int[] scanline = line.Scanline;

        string l = "";
        for( int x=0; x<scanline.Length; x++ )
        {
            int ci = scanline[ x ];
            l += ci.ToString() + ",";
        }

        Debug.Log ("line " + y + ": " + l );
        */

        int x,y;
        for( y=0; y<m_height; y++ )
        {
            ImageLine line = _png.ReadRowByte( y );
            //byte[] lineBytes = _png.ReadRowByte( y );
            byte[] lineBytes = line.ScanlineB;// GetScanlineInt();

            for( x=0; x<m_width; x++ )
            {
                byte src_c = lineBytes[ x ];
                byte remapped_c = src_c;
                if( m_config.m_colorRemapSourceToDest.ContainsKey( (int)src_c ))
                    remapped_c = (byte)m_config.m_colorRemapSourceToDest[ src_c ];
                m_colorUsed[ remapped_c ] = true;

                int dst_i = (y*m_width)+x;
                m_image[ dst_i ] = remapped_c;
            }
        }

        return true;
    }