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


C# OxyColor.GetLength方法代码示例

本文整理汇总了C#中OxyPlot.OxyColor.GetLength方法的典型用法代码示例。如果您正苦于以下问题:C# OxyColor.GetLength方法的具体用法?C# OxyColor.GetLength怎么用?C# OxyColor.GetLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OxyPlot.OxyColor的用法示例。


在下文中一共展示了OxyColor.GetLength方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Encode

        /// <summary>
        /// Encodes the specified image data to png.
        /// </summary>
        /// <param name="pixels">
        /// The pixel data (bottom line first).
        /// </param>
        /// <param name="dpi">
        /// The image resolution in dots per inch.
        /// </param>
        /// <returns>
        /// The png image data.
        /// </returns>
        public static byte[] Encode(OxyColor[,] pixels, int dpi = 96)
        {
            int height = pixels.GetLength(0);
            int width = pixels.GetLength(1);
            var bytes = new byte[(width * height * 4) + height];

            int k = 0;
            for (int i = height - 1; i >= 0; i--)
            {
                bytes[k++] = 0; // Filter
                for (int j = 0; j < width; j++)
                {
                    bytes[k++] = pixels[i, j].R;
                    bytes[k++] = pixels[i, j].G;
                    bytes[k++] = pixels[i, j].B;
                    bytes[k++] = pixels[i, j].A;
                }
            }

            var w = new MemoryWriter();
            w.Write((byte)0x89);
            w.Write("PNG\r\n\x1a\n".ToCharArray());
            WriteChunk(w, "IHDR", CreateHeaderData(width, height));
            WriteChunk(w, "pHYs", CreatePhysicalDimensionsData(dpi, dpi));
            WriteChunk(w, "IDAT", CreateUncompressedBlocks(bytes));
            WriteChunk(w, "IEND", new byte[0]);
            return w.ToArray();
        }
开发者ID:jwolfm98,项目名称:HardwareMonitor,代码行数:40,代码来源:PngEncoder.cs

示例2: Encode

        /// <summary>
        /// Encodes the specified image data to png.
        /// </summary>
        /// <param name="pixels">The pixel data (bottom line first).</param>
        /// <returns>The png image data.</returns>
        public byte[] Encode(OxyColor[,] pixels)
        {
            int width = pixels.GetLength(0);
            int height = pixels.GetLength(1);

            var bytes = new byte[width * height * 4];
            int k = 0;
            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    bytes[k++] = pixels[x, y].B;
                    bytes[k++] = pixels[x, y].G;
                    bytes[k++] = pixels[x, y].R;
                    bytes[k++] = pixels[x, y].A;
                }
            }

            var ms = new MemoryStream();
            var w = new BinaryWriter(ms);

            const int OffBits = 14 + 40;
            var size = OffBits + bytes.Length;

            // Bitmap file header (14 bytes)
            w.Write((byte)'B');
            w.Write((byte)'M');
            w.Write((uint)size);
            w.Write((ushort)0);
            w.Write((ushort)0);
            w.Write((uint)OffBits);

            // Bitmap info header (40 bytes)
            WriteBitmapInfoHeader(w, width, height, 32, bytes.Length, this.options.DpiX, this.options.DpiY);

            // Bitmap info V4 header (108 bytes)
            //// WriteBitmapV4Header(w, width, height, 32, bytes.Length, this.options.DpiX, this.options.DpiY);

            // Pixel array (from bottom-left corner)
            w.Write(bytes);

            return ms.ToArray();
        }
开发者ID:Celderon,项目名称:oxyplot,代码行数:48,代码来源:BmpEncoder.cs

示例3: FromArgbX

        /// <summary>
        /// Creates an <see cref="OxyImage"/> from the specified <see cref="OxyColor"/> array.
        /// </summary>
        /// <param name="data">
        /// The pixel data, indexed as [row,column] (from bottom-left).
        /// </param>
        /// <param name="dpi">
        /// The resolution.
        /// </param>
        /// <returns>
        /// An <see cref="OxyImage"/>.
        /// </returns>
        /// <remarks>
        /// This method is creating a simple BitmapInfoHeader.
        /// </remarks>
        public static OxyImage FromArgbX(OxyColor[,] data, int dpi = 96)
        {
            int height = data.GetLength(0);
            int width = data.GetLength(1);
            var bytes = new byte[width * height * 4];
            int k = 0;
            for (int i = 0; i < height; i++)
            {
                for (int j = 0; j < width; j++)
                {
                    bytes[k++] = data[i, j].B;
                    bytes[k++] = data[i, j].G;
                    bytes[k++] = data[i, j].R;
                    bytes[k++] = data[i, j].A;
                }
            }

            return FromArgbX(width, height, bytes, dpi);
        }
开发者ID:jwolfm98,项目名称:HardwareMonitor,代码行数:34,代码来源:OxyImage.cs

示例4: Encode

        /// <summary>
        /// Encodes the specified image data to png.
        /// </summary>
        /// <param name="pixels">The pixel data indexed as [x,y] (bottom line first).</param>
        /// <returns>The png image data.</returns>
        public byte[] Encode(OxyColor[,] pixels)
        {
            int width = pixels.GetLength(0);
            int height = pixels.GetLength(1);
            var bytes = new byte[(width * height * 4) + height];

            int k = 0;
            for (int y = 0; y < height; y++)
            {
                bytes[k++] = 0; // Filter
                for (int x = 0; x < width; x++)
                {
                    bytes[k++] = pixels[x, y].R;
                    bytes[k++] = pixels[x, y].G;
                    bytes[k++] = pixels[x, y].B;
                    bytes[k++] = pixels[x, y].A;
                }
            }

            var w = new MemoryWriter();
            w.Write((byte)0x89);
            w.Write("PNG\r\n\x1a\n".ToCharArray());
            WriteChunk(w, "IHDR", CreateHeaderData(width, height));
            WriteChunk(w, "pHYs", CreatePhysicalDimensionsData(this.options.DpiX, this.options.DpiY));
            WriteChunk(w, "IDAT", CreateUncompressedBlocks(bytes));
            WriteChunk(w, "IEND", new byte[0]);
            return w.ToArray();
        }
开发者ID:Celderon,项目名称:oxyplot,代码行数:33,代码来源:PngEncoder.cs


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