當前位置: 首頁>>代碼示例>>C#>>正文


C# Image.Clear方法代碼示例

本文整理匯總了C#中System.Image.Clear方法的典型用法代碼示例。如果您正苦於以下問題:C# Image.Clear方法的具體用法?C# Image.Clear怎麽用?C# Image.Clear使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Image的用法示例。


在下文中一共展示了Image.Clear方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ReadFrameColors


//.........這裏部分代碼省略.........
                        // If so then we read lines at predetermined offsets.
                        // When an entire image height worth of offset lines has been read we consider this a pass.
                        // With each pass the number of offset lines changes and the starting line changes.
                        if (iY >= descriptor.Height)
                        {
                            iPass++;
                            switch (iPass)
                            {
                                case 1:
                                    iY = 4;
                                    break;
                                case 2:
                                    iY = 2;
                                    iInc = 4;
                                    break;
                                case 3:
                                    iY = 1;
                                    iInc = 2;
                                    break;
                            }
                        }

                        writeY = iY + descriptor.Top;

                        iY += iInc;
                    }
                    else
                    {
                        writeY = y;
                    }

                    for (int x = descriptor.Left; x < descriptor.Left + descriptor.Width; x++)
                    {
                        offset = writeY * imageWidth + x;

                        index = indices[i];

                        if (_graphicsControl == null ||
                            _graphicsControl.TransparencyFlag == false ||
                            _graphicsControl.TransparencyIndex != index)
                        {
                            _currentFrame[offset * 4 + 0] = colorTable[index * 3 + 0];
                            _currentFrame[offset * 4 + 1] = colorTable[index * 3 + 1];
                            _currentFrame[offset * 4 + 2] = colorTable[index * 3 + 2];
                            _currentFrame[offset * 4 + 3] = (byte)255;
                        }

                        i++;
                    }
                }

                byte[] pixels = new byte[imageWidth * imageHeight * 4];

                Array.Copy(_currentFrame, pixels, pixels.Length);
                _currentFrame = new byte[imageWidth * imageHeight * 4];
                Image frame = new Image(imageWidth, imageHeight);
                
                int indx = 0;
                byte r, g, b, a;
                for (uint y = 0; y < frame.Height; y++)
                {
                    for (uint x = 0; x < frame.Width; x++)
                    {
                        r = pixels[indx];
                        indx++;
                        g = pixels[indx];
                        indx++;
                        b = pixels[indx];
                        indx++;
                        a = pixels[indx];
                        indx++;
                        frame.SetPixel(x, y, new Pixel(r, g, b, a));
                    }
                }
                pixels = null;
                System.GC.Collect();
                _image.AddFrame(frame);


                if (_graphicsControl != null)
                {
                    if (_graphicsControl.DelayTime > 0)
                    {
                        _image.TimePerFrame = _graphicsControl.DelayTime;
                    }

                    if (_graphicsControl.DisposalMethod == DisposalMethod.RestoreToBackground)
                    {
                        Image im = new Image(imageWidth, imageHeight);
                        im.Clear(new Pixel(true));
                        _image.AddFrame(im);
                        _image.Loop = false;
                        
                    }
                    else if (_graphicsControl.DisposalMethod == DisposalMethod.RestoreToPrevious)
                    {
                        _image.Loop = true;
                    }
                }
            }
開發者ID:Orvid,項目名稱:Cosmos,代碼行數:101,代碼來源:GifSupport.cs

示例2: calculateSimilarityMap

        private static Image<Gray, short> calculateSimilarityMap(ITemplate template, LinearizedMaps maps, Rectangle searchArea)
        {
            Debug.Assert(searchArea.Right <= maps.ImageSize.Width &&
                         searchArea.Bottom <= maps.ImageSize.Height);
            Debug.Assert(template.Size.Width + searchArea.X < maps.ImageSize.Width &&
                         template.Size.Height + searchArea.Y < maps.ImageSize.Height);

            int width = searchArea.Width / maps.NeigborhoodSize;
            int height = searchArea.Height / maps.NeigborhoodSize;

            Image<Gray, short> similarityMap = new Image<Gray, short>(width, height, LinearizedMaps.MAP_STRIDE_ALLIGNMENT); //performance penalty (alloc, dealloc)!!!

            using (var buffer = new Image<Gray, byte>(width, height, LinearizedMaps.MAP_STRIDE_ALLIGNMENT)) //performance penalty (alloc, dealloc)!!!
            {
                int nAddsInBuffer = 0;

                foreach (var feature in template.Features)
                {
                    var position = new Point(feature.X + searchArea.X, feature.Y + searchArea.Y); //shifted position

                    Point mapPoint;
                    var neighbourMap = maps.GetMapElement(position, feature.AngleIndex, out mapPoint);

                    neighbourMap.AddTo(buffer, mapPoint);
                    nAddsInBuffer++;

                    if (nAddsInBuffer / GlobalParameters.MAX_SUPPORTED_NUM_OF_FEATURES_ADDDED_AS_BYTE != 0)
                    {
                        buffer.AddTo(similarityMap);
                        buffer.Clear();

                        nAddsInBuffer = 0;
                    }
                }

                bool finalAdd = (template.Features.Length % GlobalParameters.MAX_SUPPORTED_NUM_OF_FEATURES_ADDDED_AS_BYTE != 0) ? true : false;
                if (finalAdd)
                {
                    buffer.AddTo(similarityMap);
                }
            }

            return similarityMap;
        }
開發者ID:remingtonsteel,項目名稱:accord-net-extensions,代碼行數:44,代碼來源:Detector.cs


注:本文中的System.Image.Clear方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。