Esempio n. 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AvifReader"/> class.
        /// </summary>
        /// <param name="parser">The parser.</param>
        /// <exception cref="ArgumentNullException"><paramref name="input"/> is null.</exception>
        public AvifReader(Stream input, bool leaveOpen, IByteArrayPool arrayPool)
        {
            if (input is null)
            {
                ExceptionUtil.ThrowArgumentNullException(nameof(input));
            }

            // The parser is initialized first because it will throw an exception
            // if the AVIF file is invalid or not supported.
            this.parser        = new AvifParser(input, leaveOpen, arrayPool);
            this.primaryItemId = this.parser.GetPrimaryItemId();
            this.alphaItemId   = this.parser.GetAlphaItemId(this.primaryItemId);
            this.colorInfoBox  = this.parser.TryGetColorInfoBox(this.primaryItemId);
            this.parser.GetTransformationProperties(this.primaryItemId,
                                                    out this.cleanApertureBox,
                                                    out this.imageRotateBox,
                                                    out this.imageMirrorBox);
            this.colorGridInfo = this.parser.TryGetImageGridInfo(this.primaryItemId);
            if (this.alphaItemId != 0)
            {
                this.alphaGridInfo = this.parser.TryGetImageGridInfo(this.alphaItemId);
            }
            else
            {
                this.alphaGridInfo = null;
            }
        }
Esempio n. 2
0
 public AvifWriter(IReadOnlyList <CompressedAV1Image> colorImages,
                   IReadOnlyList <CompressedAV1Image> alphaImages,
                   AvifMetadata metadata,
                   ImageGridMetadata imageGridMetadata,
                   YUVChromaSubsampling chromaSubsampling,
                   ColorInformationBox colorInformationBox,
                   ProgressEventHandler progressEventHandler,
                   uint progressDone,
                   uint progressTotal,
                   IByteArrayPool arrayPool)
 {
     this.state                 = new AvifWriterState(colorImages, alphaImages, imageGridMetadata, metadata, arrayPool);
     this.arrayPool             = arrayPool;
     this.colorImageIsGrayscale = chromaSubsampling == YUVChromaSubsampling.Subsampling400;
     this.colorInformationBox   = colorInformationBox;
     this.progressCallback      = progressEventHandler;
     this.progressDone          = progressDone;
     this.progressTotal         = progressTotal;
     this.fileTypeBox           = new FileTypeBox(chromaSubsampling);
     this.metaBox               = new MetaBox(this.state.PrimaryItemId,
                                              this.state.Items.Count,
                                              this.state.MediaDataBoxContentSize > uint.MaxValue,
                                              this.state.ItemDataBox);
     PopulateMetaBox();
 }