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


C# Utils.SetProgress方法代码示例

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


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

示例1: EncodeImageBufferToJpg

        /// <summary>
        /// Encodes a provided ImageBuffer[,,] to a JPG Image.
        /// </summary>
        /// <param name="ImageBuffer">The ImageBuffer containing the pixel data.</param>
        /// <param name="originalDimension">Dimension of the original image. This value is written to the image header.</param>
        /// <param name="actualDimension">Dimension on which the Encoder works. As the Encoder works in 8*8 blocks, if the image size is not divisible by 8 the remaining blocks are set to '0' (in this implementation)</param>
        /// <param name="OutputStream">Stream to which the JPEG data is to be written.</param>
        /// <param name="Quantizer_Quality">Required quantizer quality; Default: 50 , Lower value higher quality.</param>
        /// <param name="progress">Interface for updating Progress.</param>
        /// <param name="currentOperation">Interface for updating CurrentOperation.</param>
        public void EncodeImageBufferToJpg(Byte[, ,] ImageBuffer, Point originalDimension, Point actualDimension, BinaryWriter OutputStream, float Quantizer_Quality, Utils.IProgress progress, Utils.ICurrentOperation currentOperation)
        {
            Width = actualDimension.X;
            Height = actualDimension.Y;

            Bitmap_RGB_Buffer = ImageBuffer;

            UInt16 xpos, ypos;

            if (currentOperation != null)
                currentOperation.SetOperation(Utils.CurrentOperation.InitializingTables);
            Tables.InitializeAllTables(Quantizer_Quality,_luminance_table,_chromiance_table);

            if (currentOperation != null)
                currentOperation.SetOperation(Utils.CurrentOperation.WritingJPEGHeader);
            JpegHeader.WriteJpegHeader(OutputStream, new Point(originalDimension.X, originalDimension.Y));

            Int16 prev_DC_Y = 0;
            Int16 prev_DC_Cb = 0;
            Int16 prev_DC_Cr = 0;

            if (currentOperation != null)
                currentOperation.SetOperation(Utils.CurrentOperation.EncodeImageBufferToJpg);

            for (ypos = 0; ypos < Height; ypos += 8)
            {
                if (progress != null)
                    progress.SetProgress(Height * Width, Width * ypos );

                for (xpos = 0; xpos < Width; xpos += 8)
                {
                    Update_Global_Pixel_8_8_Data(xpos, ypos);

                    // Process Y Channel
                    Int16[] DCT_Quant_Y = Do_FDCT_Quantization_And_ZigZag(Y_Data, Tables.FDCT_Y_Quantization_Table);
                    DoHuffmanEncoding(DCT_Quant_Y, ref prev_DC_Y, Tables.Y_DC_Huffman_Table, Tables.Y_AC_Huffman_Table, OutputStream);

                    // Process Cb Channel
                    Int16[] DCT_Quant_Cb = Do_FDCT_Quantization_And_ZigZag(Cb_Data, Tables.FDCT_CbCr_Quantization_Table);
                    DoHuffmanEncoding(DCT_Quant_Cb, ref prev_DC_Cb, Tables.Cb_DC_Huffman_Table, Tables.Cb_AC_Huffman_Table, OutputStream);

                    // Process Cr Channel
                    Int16[] DCT_Quant_Cr = Do_FDCT_Quantization_And_ZigZag(Cr_Data, Tables.FDCT_CbCr_Quantization_Table);
                    DoHuffmanEncoding(DCT_Quant_Cr, ref prev_DC_Cr, Tables.Cb_DC_Huffman_Table, Tables.Cb_AC_Huffman_Table, OutputStream);
                }
            }
            Utils.WriteHex(OutputStream, 0xFFD9); //Write End of Image Marker

            if (currentOperation != null)
                currentOperation.SetOperation(Utils.CurrentOperation.Ready);
        }
开发者ID:b9chris,项目名称:ArpanJpegEncoder,代码行数:61,代码来源:BaseJPEGEncoder.cs

示例2: Get_Channel_Data

        /// <summary>
        /// Generates Y, Cb, Cr, R, G and B values from given RGB_Buffer
        /// </summary>
        /// <param name="RGB_Buffer">The input RGB_Buffer.</param>
        /// <param name="drawInGrayscale">Draw in grayscale.</param>
        /// <param name="width">Width of the image.</param>
        /// <param name="height">Height of the image.</param>
        /// <param name="channel">Enum specifying the channel type required.</param>
        /// <param name="progress">Interface for updating progress.</param>
        /// <param name="operation">Interface for updating current operation.</param>
        /// <returns>3D array of the specified channel type.</returns>
        public static byte[,,] Get_Channel_Data(byte[, ,] RGB_Buffer,bool drawInGrayscale, int width, int height, ChannelType channel, Utils.IProgress progress, Utils.ICurrentOperation operation)
        {
            operation.SetOperation(Utils.CurrentOperation.GetChannelData);

            int fullProgress = width * height;
            byte[, ,] outData = new byte[width, height, 3];

            switch (channel)
            {
                case ChannelType.R:

                    if (drawInGrayscale)
                    {
                        for (int i = 0; i < width; i++)
                        {
                            progress.SetProgress(fullProgress, height * i);
                            for (int j = 0; j < height; j++)
                            {
                                outData[i, j, 0] = RGB_Buffer[i, j, 0];
                                outData[i, j, 1] = RGB_Buffer[i, j, 0];
                                outData[i, j, 2] = RGB_Buffer[i, j, 0];
                            }
                        }
                    }
                    else
                    {
                        for (int i = 0; i < width; i++)
                        {
                            progress.SetProgress(fullProgress, height * i);
                            for (int j = 0; j < height; j++)
                            {
                                outData[i, j, 0] = RGB_Buffer[i, j, 0];
                            }
                        }
                    }
                    break;

                case ChannelType.G:

                    if (drawInGrayscale)
                    {
                        for (int i = 0; i < width; i++)
                        {
                            progress.SetProgress(fullProgress, height * i);
                            for (int j = 0; j < height; j++)
                            {
                                outData[i, j, 0] = RGB_Buffer[i, j, 1];
                                outData[i, j, 1] = RGB_Buffer[i, j, 1];
                                outData[i, j, 2] = RGB_Buffer[i, j, 1];
                            }
                        }
                    }
                    else
                    {
                        for (int i = 0; i < width; i++)
                        {
                            progress.SetProgress(fullProgress, height * i);
                            for (int j = 0; j < height; j++)
                            {
                                outData[i, j, 1] = RGB_Buffer[i, j, 1];
                            }
                        }
                    }
                    break;

                case ChannelType.B:

                    if (drawInGrayscale)
                    {
                        for (int i = 0; i < width; i++)
                        {
                            progress.SetProgress(fullProgress, height * i);
                            for (int j = 0; j < height; j++)
                            {
                                outData[i, j, 0] = RGB_Buffer[i, j, 2];
                                outData[i, j, 1] = RGB_Buffer[i, j, 2];
                                outData[i, j, 2] = RGB_Buffer[i, j, 2];
                            }
                        }
                    }
                    else
                    {
                        for (int i = 0; i < width; i++)
                        {
                            progress.SetProgress(fullProgress, height * i);
                            for (int j = 0; j < height; j++)
                            {
                                outData[i, j, 2] = RGB_Buffer[i, j, 2];
                            }
//.........这里部分代码省略.........
开发者ID:b9chris,项目名称:ArpanJpegEncoder,代码行数:101,代码来源:Imaging.cs


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