src/BigGustave/PngBuilder.cs
/// <summary>
/// Attempt to improve compressability of the raw data by using adaptive filtering.
/// </summary>
Attempt to improve compressability of the raw data by using adaptive filtering.
Attempt to improve compressability of the raw data by using adaptive filtering .
private void AttemptCompressionOfRawData(byte[] rawData, SaveOptions options)
        {
            if (!options.AttemptCompression)
            {
                return;
            }
            var bytesPerScanline = 1 + (bytesPerPixel * width);
            var scanlineCount = rawData.Length / bytesPerScanline;
            var scanData = new byte[bytesPerScanline - 1];
            for (var scanlineRowIndex = 0; scanlineRowIndex < scanlineCount; scanlineRowIndex++)
            {
                var sourceIndex = (scanlineRowIndex * bytesPerScanline) + 1;
                Array.Copy(rawData, sourceIndex, scanData, 0, bytesPerScanline - 1);
                var noneFilterSum = 0;
                for (int i = 0; i < scanData.Length; i++)
                {
                    noneFilterSum += scanData[i];
                }
                var leftFilterSum = 0;
                for (int i = 0; i < scanData.Length; i++)
                {
                }
            }
        }
private void AttemptCompressionOfRawData ( byte [ ] rawData , SaveOptions options ) { if ( ! options . AttemptCompression ) { return ; } var bytesPerScanline = 1 + ( bytesPerPixel * width ) ; var scanlineCount = rawData . Length / bytesPerScanline ; var scanData = new byte [ bytesPerScanline - 1 ] ; for ( var scanlineRowIndex = 0 ; scanlineRowIndex < scanlineCount ; scanlineRowIndex ++ ) { var sourceIndex = ( scanlineRowIndex * bytesPerScanline ) + 1 ; Array . Copy ( rawData , sourceIndex , scanData , 0 , bytesPerScanline - 1 ) ; var noneFilterSum = 0 ; for ( int i = 0 ; i < scanData . Length ; i ++ ) { noneFilterSum += scanData [ i ] ; } var leftFilterSum = 0 ; for ( int i = 0 ; i < scanData . Length ; i ++ ) { } } }
Attempt to improve compressability of the raw data by using adaptive filtering.
Attempt to improve compressability of the raw data by using adaptive filtering .
/* 
                 * A heuristic approach is to use adaptive filtering as follows: 
                 *    independently for each row, apply all five filters and select the filter that produces the smallest sum of absolute values per row. 
                 */
rawData
byte[]
options
SaveOptions