当前位置: 首页>>代码示例>>C#>>正文


C# Pngcs.ImageInfo类代码示例

本文整理汇总了C#中Hjg.Pngcs.ImageInfo的典型用法代码示例。如果您正苦于以下问题:C# ImageInfo类的具体用法?C# ImageInfo怎么用?C# ImageInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ImageInfo类属于Hjg.Pngcs命名空间,在下文中一共展示了ImageInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ImageLine

 internal ImageLine( ImageInfo imgInfo, ESampleType stype, bool unpackedMode, int [] sci, byte [] scb )
 {
     this.ImgInfo = imgInfo;
     channels = imgInfo.Channels;
     this.bitDepth = imgInfo.BitDepth;
     this.FilterUsed = FilterType.FILTER_UNKNOWN;
     this.SampleType = stype;
     this.SamplesUnpacked = unpackedMode || !imgInfo.Packed;
     ElementsPerRow = this.SamplesUnpacked ? imgInfo.SamplesPerRow
         : imgInfo.SamplesPerRowPacked;
     if ( stype == ESampleType.INT )
     {
         Scanline = sci != null ? sci : new int [ ElementsPerRow ];
         ScanlineB = null;
         maxSampleVal = bitDepth == 16 ? 0xFFFF : GetMaskForPackedFormatsLs ( bitDepth );
     }
     else if ( stype == ESampleType.BYTE )
     {
         ScanlineB = scb != null ? scb : new byte [ ElementsPerRow ];
         Scanline = null;
         maxSampleVal = bitDepth == 16 ? 0xFF : GetMaskForPackedFormatsLs ( bitDepth );
     }
     else
         throw new PngjExceptionInternal ( "bad ImageLine initialization" );
     this.Rown = -1;
 }
开发者ID:Daramkun,项目名称:Misty,代码行数:26,代码来源:ImageLine.cs

示例2: generateNoiseLine

 public static ImageLine generateNoiseLine(ImageInfo imi)
 {
     // byte format!
     ImageLine line = new ImageLine(imi, ImageLine.ESampleType.BYTE, true);
     Random r = new Random();
     r.NextBytes(line.ScanlineB);
     return line;
 }
开发者ID:tommyettinger,项目名称:pngcs,代码行数:8,代码来源:TestsHelper.cs

示例3: Pack

 public static byte[] Pack( ImageInfo imgInfo, byte [] src, byte [] dst, bool scale )
 {
     int len0 = imgInfo.SamplesPerRowPacked;
     if ( dst == null || dst.Length < len0 )
         dst = new byte [ len0 ];
     if ( imgInfo.Packed )
         ImageLine.packInplaceByte ( imgInfo, src, dst, scale );
     else
         Array.Copy ( src, 0, dst, 0, len0 );
     return dst;
 }
开发者ID:Daramkun,项目名称:Misty,代码行数:11,代码来源:ImageLineHelper.cs

示例4: mirrorLineInt

 private static void mirrorLineInt(ImageInfo imgInfo, int[] line)
 {
     // unpacked line
     int channels = imgInfo.Channels;
     for (int c1 = 0, c2 = imgInfo.Cols - 1; c1 < c2; c1++, c2--) { // swap pixels (not samples!)
         for (int i = 0; i < channels; i++) {
             int aux = line[c1 * channels + i];
             line[c1 * channels + i] = line[c2 * channels + i];
             line[c2 * channels + i] = aux;
         }
     }
 }
开发者ID:facemao3,项目名称:pngcs,代码行数:12,代码来源:SampleTileImage.cs

示例5: PngReader

 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 );
 }
开发者ID:Daramkun,项目名称:Misty,代码行数:49,代码来源:PngReader.cs

示例6: preference

        private double[] preference = new double[] { 1.1, 1.1, 1.1, 1.1, 1.2 }; // a priori preference (NONE SUB UP AVERAGE PAETH)

        #endregion Fields

        #region Constructors

        internal FilterWriteStrategy(ImageInfo imgInfo, FilterType configuredType)
        {
            this.imgInfo = imgInfo;
            this.configuredType = configuredType;
            if (configuredType < 0) { // first guess
                if ((imgInfo.Rows < 8 && imgInfo.Cols < 8) || imgInfo.Indexed
                        || imgInfo.BitDepth < 8)
                    currentType = FilterType.FILTER_NONE;
                else
                    currentType = FilterType.FILTER_PAETH;
            } else {
                currentType = configuredType;
            }
            if (configuredType == FilterType.FILTER_AGGRESSIVE)
                discoverEachLines = COMPUTE_STATS_EVERY_N_LINES;
            if (configuredType == FilterType.FILTER_VERYAGGRESSIVE)
                discoverEachLines = 1;
        }
开发者ID:NoobsArePeople2,项目名称:pngcs,代码行数:24,代码来源:FilterWriteStrategy.cs

示例7: PngWriter

        public PngWriter( Stream outputStream, ImageInfo imgInfo,
				String filename )
        {
            this.filename = ( filename == null ) ? "" : filename;
            this.outputStream = outputStream;
            this.ImgInfo = imgInfo;
            this.CompLevel = 6;
            this.ShouldCloseStream = true;
            this.IdatMaxSize = 0;
            this.CompressionStrategy = EDeflateCompressStrategy.Filtered;
            rowb = new byte [ imgInfo.BytesPerRow + 1 ];
            rowbprev = new byte [ rowb.Length ];
            rowbfilter = new byte [ rowb.Length ];
            chunksList = new ChunksListForWrite ( ImgInfo );
            metadata = new PngMetadata ( chunksList );
            filterStrat = new FilterWriteStrategy ( ImgInfo, FilterType.FILTER_DEFAULT );
            unpackedMode = false;
            needsPack = unpackedMode && imgInfo.Packed;
        }
开发者ID:Daramkun,项目名称:Misty,代码行数:19,代码来源:PngWriter.cs

示例8: PngDeinterlacer

        private int rows, cols, dY, dX, oY, oX, oXsamples, dXsamples; // at current pass

        #endregion Fields

        #region Constructors

        internal PngDeinterlacer(ImageInfo iminfo)
        {
            this.imi = iminfo;
            pass = 0;
            if (imi.Packed) {
                packedValsPerPixel = 8 / imi.BitDepth;
                packedShift = imi.BitDepth;
                if (imi.BitDepth == 1)
                    packedMask = 0x80;
                else if (imi.BitDepth == 2)
                    packedMask = 0xc0;
                else
                    packedMask = 0xf0;
            } else {
                packedMask = packedShift = packedValsPerPixel = 1;// dont care
            }
            setPass(1);
            setRow(0);
        }
开发者ID:NoobsArePeople2,项目名称:pngcs,代码行数:25,代码来源:PngDeinterlacer.cs

示例9: Create

 public static void Create(string filename, int cols, int rows)
 {
     ImageInfo imi = new ImageInfo(cols, rows, 8, false); // 8 bits per channel, no alpha
     // open image for writing
     PngWriter png = FileHelper.CreatePngWriter(filename, imi, true);
     // add some optional metadata (chunks)
     png.GetMetadata().SetDpi(100.0);
     png.GetMetadata().SetTimeNow(0); // 0 seconds fron now = now
     png.GetMetadata().SetText(PngChunkTextVar.KEY_Title, "Just a text image");
     PngChunk chunk = png.GetMetadata().SetText("my key", "my text .. bla bla");
     chunk.Priority = true; // this chunk will be written as soon as possible
     ImageLine iline = new ImageLine(imi);
     for (int col = 0; col < imi.Cols; col++) { // this line will be written to all rows
         int r = 255;
         int g = 127;
         int b = 255 * col / imi.Cols;
         ImageLineHelper.SetPixel(iline , col, r, g, b); // orange-ish gradient
     }
     for (int row = 0; row < png.ImgInfo.Rows; row++) {
         png.WriteRow(iline, row);
     }
     png.End();
 }
开发者ID:NoobsArePeople2,项目名称:pngcs,代码行数:23,代码来源:SampleCreateOrange.cs

示例10: createWaves

 public static string createWaves(String suffix, double scale, ImageInfo imi)
 {
     string f = getTmpFile(suffix);
     // open image for writing to a output stream
     PngWriter png = FileHelper.CreatePngWriter(f, imi, true);
     png.GetMetadata().SetText("key1", "val1");
     ImageLine iline = new ImageLine(imi, ImageLine.ESampleType.BYTE, true);
     for (int row = 0; row < png.ImgInfo.Rows; row++) {
         for (int x = 0; x < imi.Cols; x++) {
             int r = (int)((Math.Sin((row + x) * 0.073 * scale) + 1) * 128);
             int g = (int)((Math.Sin((row + x * 0.22) * 0.08 * scale) + 1) * 128);
             int b = (int)((Math.Sin((row * 0.52 - x * 0.2) * 0.21 * scale) + 1) * 128);
             iline.ScanlineB[x * imi.Channels] = (byte)r;
             iline.ScanlineB[x * imi.Channels + 1] = (byte)g;
             iline.ScanlineB[x * imi.Channels + 2] = (byte)b;
             if (imi.Channels == 4)
                 iline.ScanlineB[x * imi.Channels + 3] = (byte)((b + g) / 2);
         }
         png.WriteRow(iline, row);
     }
     png.End();
     return f;
 }
开发者ID:tommyettinger,项目名称:pngcs,代码行数:23,代码来源:TestsHelper.cs

示例11: doit

        public static void doit(String orig)
        {
            string copy= TestsHelper.addSuffixToName(orig, "_tc");

            PngReader pngr = FileHelper.CreatePngReader(orig);
            if (!pngr.ImgInfo.Indexed)
                throw new Exception("Not indexed image");
            PngChunkPLTE plte = pngr.GetMetadata().GetPLTE();
            PngChunkTRNS trns = pngr.GetMetadata().GetTRNS(); // transparency metadata, can be null
            bool alpha = trns != null;
            ImageInfo im2 = new ImageInfo(pngr.ImgInfo.Cols, pngr.ImgInfo.Rows, 8, alpha);
            PngWriter pngw = FileHelper.CreatePngWriter(copy, im2, true);
            pngw.CopyChunksFirst(pngr, ChunkCopyBehaviour.COPY_ALL_SAFE);
            int[] buf = null;
            for (int row = 0; row < pngr.ImgInfo.Rows; row++) {
                ImageLine line = pngr.ReadRowInt(row);
                buf = ImageLineHelper.Palette2rgb(line, plte, trns, buf);
                pngw.WriteRowInt(buf, row);
            }
            pngw.CopyChunksLast(pngr, ChunkCopyBehaviour.COPY_ALL_SAFE);
            pngr.End();
            pngw.End();
            Console.WriteLine("True color: " + copy);
        }
开发者ID:NoobsArePeople2,项目名称:pngcs,代码行数:24,代码来源:SampleConvertToTrueCol.cs

示例12: PngChunkSBIT

 public PngChunkSBIT(ImageInfo info)
     : base(ID, info)
 {
 }
开发者ID:gitter-badger,项目名称:blimey,代码行数:4,代码来源:PngChunkSBIT.cs

示例13: PngChunkHIST

        private int[] hist = new int[0]; // should have same lenght as palette

        #endregion Fields

        #region Constructors

        public PngChunkHIST(ImageInfo info)
            : base(ID, info)
        {
        }
开发者ID:gitter-badger,项目名称:blimey,代码行数:10,代码来源:PngChunkHIST.cs

示例14: unpackInplaceInt

 internal static void unpackInplaceInt(ImageInfo iminfo, int[] src, int[] dst,
     bool Scale)
 {
     int bitDepth = iminfo.BitDepth;
     if (bitDepth >= 8)
         return; // nothing to do
     int mask0 = GetMaskForPackedFormatsLs(bitDepth);
     int scalefactor = 8 - bitDepth;
     int offset0 = 8 * iminfo.SamplesPerRowPacked - bitDepth * iminfo.SamplesPerRow;
     int mask, offset, v;
     if (offset0 != 8) {
         mask = mask0 << offset0;
         offset = offset0; // how many bits to shift the mask to the right to recover mask0
     } else {
         mask = mask0;
         offset = 0;
     }
     for (int j = iminfo.SamplesPerRow - 1, i = iminfo.SamplesPerRowPacked - 1; j >= 0; j--) {
         v = (src[i] & mask) >> offset;
         if (Scale)
             v <<= scalefactor;
         dst[j] = v;
         mask <<= bitDepth;
         offset += bitDepth;
         if (offset == 8) {
             mask = mask0;
             offset = 0;
             i--;
         }
     }
 }
开发者ID:NoobsArePeople2,项目名称:pngcs,代码行数:31,代码来源:ImageLine.cs

示例15: ImageLine

 /// <summary>
 /// Constructs an ImageLine
 /// </summary>
 /// <param name="imgInfo">Inmutable copy of PNG ImageInfo</param>
 /// <param name="stype">Storage for samples:INT (default) or BYTE</param>
 /// <param name="unpackedMode">If true and bitdepth less than 8, samples are unpacked. This has no effect if biddepth 8 or 16</param>
 public ImageLine(ImageInfo imgInfo, ESampleType stype, bool unpackedMode)
     : this(imgInfo, stype, unpackedMode, null, null)
 {
 }
开发者ID:NoobsArePeople2,项目名称:pngcs,代码行数:10,代码来源:ImageLine.cs


注:本文中的Hjg.Pngcs.ImageInfo类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。