public ImageLines(ImageInfo ImgInfo, ImageLine.ESampleType sampleType, bool unpackedMode, int rowOffset, int imageRows, int rowStep)
 {
     this.ImgInfo         = ImgInfo;
     channels             = ImgInfo.Channels;
     bitDepth             = ImgInfo.BitDepth;
     this.sampleType      = sampleType;
     this.SamplesUnpacked = unpackedMode || !ImgInfo.Packed;
     this.RowOffset       = rowOffset;
     this.ImageRows       = imageRows;
     this.RowStep         = rowStep;
     elementsPerRow       = unpackedMode ? ImgInfo.SamplesPerRow : ImgInfo.SamplesPerRowPacked;
     if (sampleType == ImageLine.ESampleType.INT)
     {
         Scanlines = new int[imageRows][];
         for (int i = 0; i < imageRows; i++)
         {
             Scanlines[i] = new int[elementsPerRow];
         }
         ScanlinesB = null;
     }
     else if (sampleType == ImageLine.ESampleType.BYTE)
     {
         ScanlinesB = new byte[imageRows][];
         for (int i = 0; i < imageRows; i++)
         {
             ScanlinesB[i] = new byte[elementsPerRow];
         }
         Scanlines = null;
     }
     else
     {
         throw new System.Exception("bad ImageLine initialization");
     }
 }
Esempio n. 2
0
        public ImageLines(ImageInfo ImgInfo, ImageLine.ESampleType sampleType, bool unpackedMode, int rowOffset, int nRows, int rowStep)
        {
            this.ImgInfo    = ImgInfo;
            channels        = ImgInfo.Channels;
            bitDepth        = ImgInfo.BitDepth;
            this.sampleType = sampleType;
            SamplesUnpacked = (unpackedMode || !ImgInfo.Packed);
            RowOffset       = rowOffset;
            Nrows           = nRows;
            RowStep         = rowStep;
            elementsPerRow  = (unpackedMode ? ImgInfo.SamplesPerRow : ImgInfo.SamplesPerRowPacked);
            switch (sampleType)
            {
            case ImageLine.ESampleType.INT:
            {
                Scanlines = new int[nRows][];
                for (int j = 0; j < nRows; j++)
                {
                    Scanlines[j] = new int[elementsPerRow];
                }
                ScanlinesB = null;
                break;
            }

            case ImageLine.ESampleType.BYTE:
            {
                ScanlinesB = new byte[nRows][];
                for (int i = 0; i < nRows; i++)
                {
                    ScanlinesB[i] = new byte[elementsPerRow];
                }
                Scanlines = null;
                break;
            }

            default:
                throw new PngjExceptionInternal("bad ImageLine initialization");
            }
        }
Esempio n. 3
0
        public ImageLines(ImageInfo ImgInfo, ImageLine.ESampleType sampleType, bool unpackedMode, int rowOffset, int nRows, int rowStep)
        {
            this.ImgInfo = ImgInfo ?? throw new System.ArgumentNullException(nameof(ImgInfo));

            Channels        = ImgInfo.Channels;
            BitDepth        = ImgInfo.BitDepth;
            SampleType      = sampleType;
            SamplesUnpacked = unpackedMode || !ImgInfo.Packed;
            RowOffset       = rowOffset;
            Nrows           = nRows;
            RowStep         = rowStep;
            ElementsPerRow  = unpackedMode ? ImgInfo.SamplesPerRow : ImgInfo.SamplesPerRowPacked;
            if (sampleType == ImageLine.ESampleType.INT)
            {
                Scanlines = new int[nRows][];
                for (var i = 0; i < nRows; i++)
                {
                    Scanlines[i] = new int[ElementsPerRow];
                }

                ScanlinesB = null;
            }
            else if (sampleType == ImageLine.ESampleType.BYTE)
            {
                ScanlinesB = new byte[nRows][];
                for (var i = 0; i < nRows; i++)
                {
                    ScanlinesB[i] = new byte[ElementsPerRow];
                }

                Scanlines = null;
            }
            else
            {
                throw new PngjInternalException("bad ImageLine initialization");
            }
        }