Engines/FlatRedBallXNA/FlatRedBall/IO/PngLoader.cs
/// <summary>
/// Reads data from the given IDAT chunk and appends it to the List imageData.
/// </summary>
/// <param name="idat">A Chunk containing a compressed section of the image.</param>
/// <param name="imageData">A List of bytes to hold the entire compressed image.</param>
Reads data from the given IDAT chunk and appends it to the List imageData.
Reads data from the given IDAT chunk and appends it to the List imageData .
private static void ReadImageData(Chunk idat, ref byte[] imageData, ref int numberOfBytesRead)
        {
            while (idat.Length > imageData.Length - numberOfBytesRead)
            {
                byte[] newArray = new byte[idat.Length + imageData.Length];
                try
                {
                    Array.Copy(imageData, newArray, imageData.Length);
                }
                catch (Exception )
                {
                }
                imageData = newArray;
            }
            for (int i = 0; i < idat.Length; ++i)
            {
                imageData[numberOfBytesRead] = (byte)idat.ChunkData.ReadByte();
                numberOfBytesRead++;
            }
            if (idat.ChunkData.Position != idat.ChunkData.Length)
            {
                throw new Exception(
                    String.Format(
                    "Length of data in IDAT doesn't match the length provided by the chunk. " +
                    "Bytes read: {0} " +
                    "Bytes expected: {1}.",
                    (uint)idat.ChunkData.Position, idat.Length));
            }
        }
private static void ReadImageData ( Chunk idat , ref byte [ ] imageData , ref int numberOfBytesRead ) { while ( idat . Length > imageData . Length - numberOfBytesRead ) { byte [ ] newArray = new byte [ idat . Length + imageData . Length ] ; try { Array . Copy ( imageData , newArray , imageData . Length ) ; } catch ( Exception ) { } imageData = newArray ; } for ( int i = 0 ; i < idat . Length ; ++ i ) { imageData [ numberOfBytesRead ] = ( byte ) idat . ChunkData . ReadByte ( ) ; numberOfBytesRead ++ ; } if ( idat . ChunkData . Position != idat . ChunkData . Length ) { throw new Exception ( String . Format ( " " + " " + " " , ( uint ) idat . ChunkData . Position , idat . Length ) ) ; } }
Reads data from the given IDAT chunk and appends it to the List imageData.
Reads data from the given IDAT chunk and appends it to the List imageData .
//TODO: May consider using CRC here //Check that the proper number of bytes were read.
idat
Chunk
A Chunk containing a compressed section of the image.
A Chunk containing a compressed section of the image .
byte[]
ref
int
ref
imageData
A List of bytes to hold the entire compressed image.
A List of bytes to hold the entire compressed image .