예제 #1
0
        private readonly bool ReadOnly; // readonly

        #endregion Fields

        #region Constructors

        internal PngMetadata(ChunksList chunks)
        {
            this.chunkList = chunks;
            if (chunks is ChunksListForWrite) {
                this.ReadOnly = false;
            } else {
                this.ReadOnly = true;
            }
        }
예제 #2
0
        private readonly bool ReadOnly; // readonly

        internal PngMetadata(ChunksList chunks)
        {
            this.chunkList = chunks;
            if (chunks is ChunksListForWrite)
            {
                this.ReadOnly = false;
            }
            else
            {
                this.ReadOnly = true;
            }
        }
예제 #3
0
파일: PngReader.cs 프로젝트: Daramkun/Misty
 public PngReader( Stream inputStream, String filename )
 {
     this.filename = ( filename == null ) ? "" : filename;
     this.inputStream = inputStream;
     this.chunksList = new ChunksList ( null );
     this.metadata = new PngMetadata ( chunksList );
     this.offset = 0;
     this.CurrentChunkGroup = -1;
     this.ShouldCloseStream = true;
     this.MaxBytesMetadata = 5 * 1024 * 1024;
     this.MaxTotalBytesRead = 200 * 1024 * 1024;
     this.SkipChunkMaxSize = 2 * 1024 * 1024;
     this.SkipChunkIds = new string [] { "fdAT" };
     this.ChunkLoadBehaviour = Hjg.Pngcs.Chunks.ChunkLoadBehaviour.LOAD_CHUNK_ALWAYS;
     byte [] pngid = new byte [ 8 ];
     PngHelperInternal.ReadBytes ( inputStream, pngid, 0, pngid.Length );
     offset += pngid.Length;
     if ( !PngCsUtils.arraysEqual ( pngid, PngHelperInternal.PNG_ID_SIGNATURE ) )
         throw new PngjInputException ( "Bad PNG signature" );
     CurrentChunkGroup = ChunksList.CHUNK_GROUP_0_IDHR;
     int clen = PngHelperInternal.ReadInt4 ( inputStream );
     offset += 4;
     if ( clen != 13 )
         throw new Exception ( "IDHR chunk len != 13 ?? " + clen );
     byte [] chunkid = new byte [ 4 ];
     PngHelperInternal.ReadBytes ( inputStream, chunkid, 0, 4 );
     if ( !PngCsUtils.arraysEqual4 ( chunkid, ChunkHelper.b_IHDR ) )
         throw new PngjInputException ( "IHDR not found as first chunk??? ["
                 + ChunkHelper.ToString ( chunkid ) + "]" );
     offset += 4;
     PngChunkIHDR ihdr = ( PngChunkIHDR ) ReadChunk ( chunkid, clen, false );
     bool alpha = ( ihdr.Colormodel & 0x04 ) != 0;
     bool palette = ( ihdr.Colormodel & 0x01 ) != 0;
     bool grayscale = ( ihdr.Colormodel == 0 || ihdr.Colormodel == 4 );
     ImgInfo = new ImageInfo ( ihdr.Cols, ihdr.Rows, ihdr.Bitspc, alpha, grayscale, palette );
     rowb = new byte [ ImgInfo.BytesPerRow + 1 ];
     rowbprev = new byte [ rowb.Length ];
     rowbfilter = new byte [ rowb.Length ];
     interlaced = ihdr.Interlaced == 1;
     deinterlacer = interlaced ? new PngDeinterlacer ( ImgInfo ) : null;
     if ( ihdr.Filmeth != 0 || ihdr.Compmeth != 0 || ( ihdr.Interlaced & 0xFFFE ) != 0 )
         throw new PngjInputException ( "compmethod or filtermethod or interlaced unrecognized" );
     if ( ihdr.Colormodel < 0 || ihdr.Colormodel > 6 || ihdr.Colormodel == 1
             || ihdr.Colormodel == 5 )
         throw new PngjInputException ( "Invalid colormodel " + ihdr.Colormodel );
     if ( ihdr.Bitspc != 1 && ihdr.Bitspc != 2 && ihdr.Bitspc != 4 && ihdr.Bitspc != 8
             && ihdr.Bitspc != 16 )
         throw new PngjInputException ( "Invalid bit depth " + ihdr.Bitspc );
 }
예제 #4
0
        private readonly bool ReadOnly; // readonly

        internal PngMetadata(ChunksList chunks)
        {
            chunkList = chunks;
            ReadOnly  = !(chunks is ChunksListForWrite);
        }
예제 #5
0
 public List <PngChunk> GetQueuedById(string id, string innerid)
 {
     return(ChunksList.GetXById(queuedChunks, id, innerid));
 }