Engines/FlatRedBallXNA/FlatRedBall/IO/PngLoader.cs
/// <summary>
/// Processes the IHDR chunk by reading and storing all of its information in a HeaderInfo struct.
/// </summary>
/// <param name="chunks">A List containing all of the Chunks for this .png image</param>
/// <returns>A HeaderInfo struct containing all of the information of this images IHDR chunk</returns>
Processes the IHDR chunk by reading and storing all of its information in a HeaderInfo struct.
Processes the IHDR chunk by reading and storing all of its information in a HeaderInfo struct .
private static HeaderInfo ReadHeader(ref List<Chunk> chunks)
        {
            Chunk ihdr = chunks[0];
            if (ihdr.Type != ChunkTypes.IHDR)
                throw new ArgumentException(String.Format(
                    "List of chunks contains no chunk for header information, or it is not first in the list."));
            else
                chunks.RemoveAt(0);
            HeaderInfo header;
            Stream stream = ihdr.ChunkData;
            header.Width = FormUint(ref stream);                    
            header.Height = FormUint(ref stream);                  
            header.BitDepth = (byte)stream.ReadByte();              
            header.ColorType = (byte)stream.ReadByte();             
            header.CompressionMethod = (byte)stream.ReadByte();    
            header.FilterMethod = (byte)stream.ReadByte();         
            header.InterlaceMethod = (byte)stream.ReadByte();      
            stream.Close();
            return header;
        }
private static HeaderInfo ReadHeader ( ref List < Chunk > chunks ) { Chunk ihdr = chunks [ 0 ] ; if ( ihdr . Type != ChunkTypes . IHDR ) throw new ArgumentException ( String . Format ( " " ) ) ; else chunks . RemoveAt ( 0 ) ; HeaderInfo header ; Stream stream = ihdr . ChunkData ; header . Width = FormUint ( ref stream ) ; header . Height = FormUint ( ref stream ) ; header . BitDepth = ( byte ) stream . ReadByte ( ) ; header . ColorType = ( byte ) stream . ReadByte ( ) ; header . CompressionMethod = ( byte ) stream . ReadByte ( ) ; header . FilterMethod = ( byte ) stream . ReadByte ( ) ; header . InterlaceMethod = ( byte ) stream . ReadByte ( ) ; stream . Close ( ) ; return header ; }
Processes the IHDR chunk by reading and storing all of its information in a HeaderInfo struct.
Processes the IHDR chunk by reading and storing all of its information in a HeaderInfo struct .
//IHDR is required to be the first chunk in a .png image. Check the //type of the first Chunk in List chunks and make sure that it's //IHDR. //If so, remove it from the list //Read each field of data from IHDR's ChunkData Stream //System.Diagnostics.Trace.WriteLine(String.Format("Width:{0}",header.Width)); // System.Diagnostics.Trace.WriteLine(String.Format("Height:{0}",header.Height)); //System.Diagnostics.Trace.WriteLine(String.Format("BitDepth:{0}",header.BitDepth)); //System.Diagnostics.Trace.WriteLine(String.Format("ColorType:{0}",header.ColorType)); // System.Diagnostics.Trace.WriteLine(String.Format("Compression:{0}",header.CompressionMethod)); // System.Diagnostics.Trace.WriteLine(String.Format("Filter:{0}",header.FilterMethod)); // System.Diagnostics.Trace.WriteLine(String.Format("Interlace:{0}",header.InterlaceMethod)); /*  if (header.InterlaceMethod != 0)
                throw new ArgumentException(string.Format(
                    "FlatRedBall does not currently support interlaced .png images."));
            */ //Close the Stream
A HeaderInfo struct containing all of the information of this images IHDR chunk
A HeaderInfo struct containing all of the information of this images IHDR chunk
List<Chunk>
ref
chunks
A List containing all of the Chunks for this .png image
A List containing all of the Chunks for this . png image