• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Image.ImageBuffer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: AForgeCamera

        public AForgeCamera(string preferedCameraName = null, int preferedWidth = 640, int preferedHeight = 480, DownSample downSampleVideo = DownSample.None)
        {
            this.downSampleVideo = downSampleVideo;

            if (preferedCameraName != null)
            {
                FilterInfoCollection videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
                foreach (FilterInfo info in videoDevices)
                {
                    if (info.Name.Contains(preferedCameraName))
                    {
                        videoCaptureDevice = new VideoCaptureDevice(info.MonikerString);
                        videoCaptureDevice.DesiredFrameSize = new Size(preferedWidth, preferedHeight);
                        break;
                    }
                }
            }

            if (videoCaptureDevice == null)
            {
                VideoCaptureDeviceForm form = new VideoCaptureDeviceForm();
                if (form.ShowDialog(null) == DialogResult.OK)
                {
                    // create video source
                    videoCaptureDevice = form.VideoDevice;
                }
            }

            if (videoCaptureDevice != null)
            {
                //videoCaptureDevice.DesiredFrameRate = 5;
                //videoCaptureDevice.ProvideSnapshots = true;
                //videoCaptureDevice.DesiredSnapshotSize = new Size(preferedWidth, preferedHeight);
                //videoCaptureDevice.SnapshotFrame += new NewFrameEventHandler(videoCaptureDevice_SnapshotFrame);

                asyncCopiedVideoImage = new ImageBuffer(videoCaptureDevice.DesiredFrameSize.Width, videoCaptureDevice.DesiredFrameSize.Height, 32, new BlenderBGRA());
                if (downSampleVideo == DownSample.HalfSize)
                {
                    imageForExternalUse = new ImageBuffer(videoCaptureDevice.DesiredFrameSize.Width / 2, videoCaptureDevice.DesiredFrameSize.Height / 2, 32, new BlenderBGRA());
                }
                else
                {
                    imageForExternalUse = new ImageBuffer(videoCaptureDevice.DesiredFrameSize.Width, videoCaptureDevice.DesiredFrameSize.Height, 32, new BlenderBGRA());
                }
                videoCaptureDevice.Start();
                videoCaptureDevice.NewFrame += new NewFrameEventHandler(source_NewFrame);
            }
        }
开发者ID:glocklueng,项目名称:agg-sharp,代码行数:48,代码来源:AForgeCamera.cs


示例2: LibraryThumbnailWidget

        public LibraryThumbnailWidget(PrintItemWrapper item, string noThumbnailFileName, string buildingThumbnailFileName, Vector2 size)
        {
            this.PrintItem = item;

            // Set Display Attributes
            this.Margin = new BorderDouble(0);
            this.Padding = new BorderDouble(5);
            this.Width = size.x;
            this.Height = size.y;
            this.MinimumSize = size;
            this.BackgroundColor = normalBackgroundColor;
            this.Cursor = Cursors.Hand;

            // set background images
            if (noThumbnailImage.Width == 0)
            {
                ImageBMPIO.LoadImageData(this.GetImageLocation(noThumbnailFileName), noThumbnailImage);
                ImageBMPIO.LoadImageData(this.GetImageLocation(buildingThumbnailFileName), buildingThumbnailImage);
            }
            this.image = new ImageBuffer(buildingThumbnailImage);

            // Add Handlers
            this.Click += new ButtonEventHandler(onMouseClick);
            this.MouseEnterBounds += new EventHandler(onEnter);
            this.MouseLeaveBounds += new EventHandler(onExit);
            ActiveTheme.Instance.ThemeChanged.RegisterEvent(onThemeChanged, ref unregisterEvents);

            CreateThumNailThreadIfNeeded();
        }
开发者ID:rubenkar,项目名称:MatterControl,代码行数:29,代码来源:PrintLibraryListItem.cs


示例3: CreateOptionsMenu

        GuiWidget CreateOptionsMenu()
        {
            ImageBuffer gearImage = new ImageBuffer();
            string imagePathAndFile = Path.Combine(ApplicationDataStorage.Instance.ApplicationStaticDataPath, "gear_icon.png");
            ImageBMPIO.LoadImageData(imagePathAndFile, gearImage);

            FlowLayoutWidget leftToRight = new FlowLayoutWidget();
            leftToRight.Margin = new BorderDouble(5, 0);
            string optionsString = new LocalizedString("Options").Translated;
            TextWidget optionsText = new TextWidget(optionsString, textColor: RGBA_Bytes.White);
            optionsText.VAnchor = Agg.UI.VAnchor.ParentCenter;
            optionsText.Margin = new BorderDouble(0, 0, 3, 0);
            leftToRight.AddChild(optionsText);
            GuiWidget gearWidget = new ImageWidget(gearImage);
            gearWidget.VAnchor = Agg.UI.VAnchor.ParentCenter;
            leftToRight.AddChild(gearWidget);
            leftToRight.HAnchor = HAnchor.FitToChildren;
            leftToRight.VAnchor = VAnchor.FitToChildren;

            Menu optionMenu = new Menu(leftToRight);
            optionMenu.OpenOffset = new Vector2(-2, -10);
            optionMenu.VAnchor = Agg.UI.VAnchor.ParentCenter;
            optionMenu.MenuItems.Add(new MenuItem(new ThemeColorSelectorWidget()));

            return optionMenu;
        }
开发者ID:rubenkar,项目名称:MatterControl,代码行数:26,代码来源:PrinterActionRow.cs


示例4: OutputImage

		private void OutputImage(ImageBuffer imageToOutput, string fileName)
		{
			if (saveImagesForDebug)
			{
				ImageTgaIO.Save(imageToOutput, fileName);
			}
		}
开发者ID:eriser,项目名称:agg-sharp,代码行数:7,代码来源:FlowLayoutTests.cs


示例5: ContainsTests

		public void ContainsTests()
		{
			// look for 24 bit
			{
				ImageBuffer imageToSearch = new ImageBuffer(150, 150, 24, new BlenderBGR());
				imageToSearch.NewGraphics2D().Circle(new Vector2(100, 100), 3, RGBA_Bytes.Red);
				ImageBuffer circleToFind = new ImageBuffer(10, 10, 24, new BlenderBGR());
				circleToFind.NewGraphics2D().Circle(new Vector2(5, 5), 3, RGBA_Bytes.Red);
				Assert.IsTrue(imageToSearch.Contains(circleToFind), "We should be able to find the circle.");

				ImageBuffer squareToFind = new ImageBuffer(10, 10, 24, new BlenderBGR());
				squareToFind.NewGraphics2D().FillRectangle(4, 4, 8, 8, RGBA_Bytes.Red);
				Assert.IsTrue(!imageToSearch.Contains(squareToFind), "We should be not find a square.");
			}

			// look for 32 bit
			{
				ImageBuffer imageToSearch = new ImageBuffer(150, 150, 32, new BlenderBGRA());
				imageToSearch.NewGraphics2D().Circle(new Vector2(100, 100), 3, RGBA_Bytes.Red);
				ImageBuffer circleToFind = new ImageBuffer(10, 10, 32, new BlenderBGRA());
				circleToFind.NewGraphics2D().Circle(new Vector2(5, 5), 3, RGBA_Bytes.Red);
				Assert.IsTrue(imageToSearch.Contains(circleToFind), "We should be able to find the circle.");

				ImageBuffer squareToFind = new ImageBuffer(10, 10, 32, new BlenderBGRA());
				squareToFind.NewGraphics2D().FillRectangle(4, 4, 8, 8, RGBA_Bytes.Red);
				Assert.IsTrue(!imageToSearch.Contains(squareToFind), "We should be not find a square.");
			}
		}
开发者ID:glocklueng,项目名称:agg-sharp,代码行数:28,代码来源:ImageTests.cs


示例6: DoubleBufferTests

		public void DoubleBufferTests()
		{
			{
				bool textWidgetDoubleBufferDefault = TextWidget.DoubleBufferDefault;

				// the text widget is double buffered
				TextWidget.DoubleBufferDefault = true;
				ImageBuffer doubleBufferImage = new ImageBuffer(65, 50, 24, new BlenderBGR());
				Button doubleBufferButton = new Button("testing", 0, 0);
				doubleBufferButton.OnDraw(doubleBufferImage.NewGraphics2D());
				SaveImage(doubleBufferImage, "z control.tga");

				// make sure the frame comparison function works.
				{
					ImageBuffer doubleBufferImageCopy = new ImageBuffer(doubleBufferImage, new BlenderBGR());
					Assert.IsTrue(doubleBufferImage == doubleBufferImageCopy);
				}

				// the text widget is not double buffered
				TextWidget.DoubleBufferDefault = false;
				ImageBuffer notDoubleBufferImage = new ImageBuffer(65, 50, 24, new BlenderBGR());
				Button notDoubleBufferButton = new Button("testing", 0, 0);
				notDoubleBufferButton.OnDraw(notDoubleBufferImage.NewGraphics2D());
				SaveImage(notDoubleBufferImage, "z test.tga");

				Assert.IsTrue(doubleBufferImage == notDoubleBufferImage);

				TextWidget.DoubleBufferDefault = textWidgetDoubleBufferDefault;
			}
		}
开发者ID:glocklueng,项目名称:agg-sharp,代码行数:30,代码来源:BackBufferTests.cs


示例7: SaveImage

		private void SaveImage(ImageBuffer image, string dest)
		{
			if (saveImagesForDebug)
			{
				ImageTgaIO.Save(image, dest);
			}
		}
开发者ID:glocklueng,项目名称:agg-sharp,代码行数:7,代码来源:BackBufferTests.cs


示例8: DoYBlur

        public static void DoYBlur(ImageBuffer sourceDest)
        {
            if (sourceDest.BitDepth != 8)
            {
                throw new NotImplementedException("We only work with 8 bit at the moment.");
            }

            int height = sourceDest.Height;
            int width = sourceDest.Width;
            byte[] buffer = sourceDest.GetBuffer();
            int strideInBytes = sourceDest.StrideInBytes();
            byte[] cache = new byte[height];

            for (int x = 0; x < width; x++)
            {
                int offset = x;
                for (int y = 0; y < height; y++)
                {
                    cache[y] = buffer[offset];
                    offset += strideInBytes;
                }

                offset = x;
                for (int y = 1; y < height - 1; y++)
                {
                    int newValue = (cache[y - 1] + cache[y] * 2 + cache[y + 1] + 2) / 4; // the + 2 is so that we will round correctly
                    buffer[offset] = (byte)newValue;
                    offset += strideInBytes;
                }
            }
        }
开发者ID:jeske,项目名称:agg-sharp,代码行数:31,代码来源:Blur.cs


示例9: DoXBlur

        internal static void DoXBlur(ImageBuffer sourceDest)
        {
            if (sourceDest.BitDepth != 8)
            {
                throw new NotImplementedException("We only work with 8 bit at the moment.");
            }

            int height = sourceDest.Height;
            int width = sourceDest.Width;
            byte[] buffer = sourceDest.GetBuffer();
            byte[] cache = new byte[width];

            for (int y = 0; y < height; y++)
            {
                int offset = sourceDest.GetBufferOffsetY(y);
                for (int x = 0; x < width; x++)
                {
                    cache[x] = buffer[offset + x];
                }

                for (int x = 1; x < width - 1; x++)
                {
                    int newValue = (cache[x - 1] + cache[x] * 2 + cache[x + 1] + 2) / 4; // the + 2 is so that we will round correctly
                    buffer[offset + x] = (byte)newValue;
                }
            }
        }
开发者ID:jeske,项目名称:agg-sharp,代码行数:27,代码来源:Blur.cs


示例10: LoadImage

 ImageBuffer LoadImage(string imageName)
 {
     string path = Path.Combine(ApplicationDataStorage.Instance.ApplicationStaticDataPath, imageName);
     ImageBuffer buffer = new ImageBuffer(10, 10, 32, new BlenderBGRA());
     ImageBMPIO.LoadImageData(path, buffer);
     return buffer;
 }
开发者ID:rubenkar,项目名称:MatterControl,代码行数:7,代码来源:PluginChooserWindow.cs


示例11: TextureMaterial

		public TextureMaterial(ImageBuffer texture, double reflection, double transparency, double gloss, double density)
		{
			this.Reflection = reflection;
			this.Transparency = transparency;
			this.Gloss = gloss;
			this.Density = density;
			this.Texture = texture;
		}
开发者ID:glocklueng,项目名称:agg-sharp,代码行数:8,代码来源:TextureMaterial.cs


示例12: CreateWhiteToColor

		public static ImageBuffer CreateWhiteToColor(ImageBuffer normalImage, RGBA_Bytes color)
		{
			ImageBuffer destImage = new ImageBuffer(normalImage.Width, normalImage.Height, 32, new BlenderBGRA());

			DoWhiteToColor(destImage, normalImage, color);

			return destImage;
		}
开发者ID:glocklueng,项目名称:agg-sharp,代码行数:8,代码来源:WhiteToColor.cs


示例13: OnDraw

        public override void OnDraw(Graphics2D graphics2D)
        {
            ImageBuffer widgetsSubImage = ImageBuffer.NewSubImageReference(graphics2D.DestImage, graphics2D.GetClippingRect());

            IImageByte backBuffer = widgetsSubImage;
            
            GammaLookUpTable gamma = new GammaLookUpTable(m_gamma.Value);
            IRecieveBlenderByte NormalBlender = new BlenderBGRA();
            IRecieveBlenderByte GammaBlender = new BlenderGammaBGRA(gamma);
            ImageBuffer rasterNormal = new ImageBuffer();
            rasterNormal.Attach(backBuffer, NormalBlender);
            ImageBuffer rasterGamma = new ImageBuffer();
            rasterGamma.Attach(backBuffer, GammaBlender);
            ImageClippingProxy clippingProxyNormal = new ImageClippingProxy(rasterNormal);
            ImageClippingProxy clippingProxyGamma = new ImageClippingProxy(rasterGamma);

            clippingProxyNormal.clear(m_white_on_black.Checked ? new RGBA_Floats(0, 0, 0) : new RGBA_Floats(1, 1, 1));

            ScanlineRasterizer ras = new ScanlineRasterizer();
            ScanlineCachePacked8 sl = new ScanlineCachePacked8();

            VertexSource.Ellipse e = new VertexSource.Ellipse();

            // TODO: If you drag the control circles below the bottom of the window we get an exception.  This does not happen in AGG.
            // It needs to be debugged.  Turning on clipping fixes it.  But standard agg works without clipping.  Could be a bigger problem than this.
            //ras.clip_box(0, 0, width(), height());

            // Render two "control" circles
            e.init(m_x[0], m_y[0], 3, 3, 16);
            ras.add_path(e);
            ScanlineRenderer scanlineRenderer = new ScanlineRenderer();
            scanlineRenderer.render_scanlines_aa_solid(clippingProxyNormal, ras, sl, new RGBA_Bytes(127, 127, 127));
            e.init(m_x[1], m_y[1], 3, 3, 16);
            ras.add_path(e);
            scanlineRenderer.render_scanlines_aa_solid(clippingProxyNormal, ras, sl, new RGBA_Bytes(127, 127, 127));

            double d = m_offset.Value;

            // Creating a rounded rectangle
            VertexSource.RoundedRect r = new VertexSource.RoundedRect(m_x[0] + d, m_y[0] + d, m_x[1] + d, m_y[1] + d, m_radius.Value);
            r.normalize_radius();

            // Drawing as an outline
            if (!m_DrawAsOutlineCheckBox.Checked)
            {
                Stroke p = new Stroke(r);
                p.width(1.0);
                ras.add_path(p);
            }
            else
            {
                ras.add_path(r);
            }

            scanlineRenderer.render_scanlines_aa_solid(clippingProxyGamma, ras, sl, m_white_on_black.Checked ? new RGBA_Bytes(255, 255, 255) : new RGBA_Bytes(0, 0, 0));

            base.OnDraw(graphics2D);
        }
开发者ID:jeske,项目名称:agg-sharp,代码行数:58,代码来源:rounded_rect.cs


示例14: LoadImage

		private ImageBuffer LoadImage(string imageName)
		{
			string path = Path.Combine("Icons", imageName);
			ImageBuffer buffer = new ImageBuffer(10, 10, 32, new BlenderBGRA());

			StaticData.Instance.LoadImage(path, buffer);

			return buffer;
		}
开发者ID:fuding,项目名称:MatterControl,代码行数:9,代码来源:PluginChooserWindow.cs


示例15: InternalImageGraphics2D

			internal InternalImageGraphics2D(ImageBuffer owner)
				: base()
			{
				ScanlineRasterizer rasterizer = new ScanlineRasterizer();
				ImageClippingProxy imageClippingProxy = new ImageClippingProxy(owner);

				Initialize(imageClippingProxy, rasterizer);
				ScanlineCache = new ScanlineCachePacked8();
			}
开发者ID:glocklueng,项目名称:agg-sharp,代码行数:9,代码来源:ImageBuffer.cs


示例16: DoErode3x3MinValue

		public static void DoErode3x3MinValue(ImageBuffer source, ImageBuffer dest)
		{
			if (source.BitDepth != 32 || dest.BitDepth != 32)
			{
				throw new NotImplementedException("We only work with 32 bit at the moment.");
			}

			if (source.Width != dest.Width || source.Height != dest.Height)
			{
				throw new NotImplementedException("Source and Dest have to be the same size");
			}

			int height = source.Height;
			int width = source.Width;
			int sourceStrideInBytes = source.StrideInBytes();
			int destStrideInBytes = dest.StrideInBytes();
			byte[] sourceBuffer = source.GetBuffer();
			byte[] destBuffer = dest.GetBuffer();

			// This can be made much faster by holding the buffer pointer and offsets better // LBB 2013 06 09
			for (int testY = 1; testY < height - 1; testY++)
			{
				for (int testX = 1; testX < width - 1; testX++)
				{
					RGBA_Bytes minColor = RGBA_Bytes.White;
					int sourceOffset = source.GetBufferOffsetXY(testX, testY - 1);

					// x-1, y-1
					//minColor = MinColor(sourceBuffer, minColor, sourceOffset - 4);
					// x0, y-1
					minColor = MinColor(sourceBuffer, minColor, sourceOffset + 0);
					// x1, y-1
					//minColor = MinColor(sourceBuffer, minColor, sourceOffset + 4);

					// x-1, y0
					minColor = MinColor(sourceBuffer, minColor, sourceOffset + sourceStrideInBytes - 4);
					// x0, y0
					minColor = MinColor(sourceBuffer, minColor, sourceOffset + sourceStrideInBytes + 0);
					// x+1, y0
					minColor = MinColor(sourceBuffer, minColor, sourceOffset + sourceStrideInBytes + 4);

					// x-1, y+1
					//minColor = MinColor(sourceBuffer, minColor, sourceOffset + sourceStrideInBytes * 2 - 4);
					// x0, y+1
					minColor = MinColor(sourceBuffer, minColor, sourceOffset + sourceStrideInBytes * 2 + 0);
					// x+1, y+1
					//minColor = MinColor(sourceBuffer, minColor, sourceOffset + sourceStrideInBytes * 2 + 4);

					int destOffset = dest.GetBufferOffsetXY(testX, testY);
					destBuffer[destOffset + 2] = minColor.red;
					destBuffer[destOffset + 1] = minColor.green;
					destBuffer[destOffset + 0] = minColor.blue;
					destBuffer[destOffset + 3] = 255;
				}
			}
		}
开发者ID:CNCBrasil,项目名称:agg-sharp,代码行数:56,代码来源:Erode.cs


示例17: TextImageWidget

		public TextImageWidget(string label, RGBA_Bytes fillColor, RGBA_Bytes borderColor, RGBA_Bytes textColor, double borderWidth, BorderDouble margin, ImageBuffer image = null, double fontSize = 12, FlowDirection flowDirection = FlowDirection.LeftToRight, double height = 40, double width = 0, bool centerText = false, double imageSpacing = 0)
			: base()
		{
			this.image = image;
			this.fillColor = fillColor;
			this.borderColor = borderColor;
			this.borderWidth = borderWidth;
			this.Margin = new BorderDouble(0);
			this.Padding = new BorderDouble(0);

			TextWidget textWidget = new TextWidget(label, pointSize: fontSize);
			ImageWidget imageWidget;

			FlowLayoutWidget container = new FlowLayoutWidget(flowDirection);

			if (centerText)
			{
				// make sure the contents are centered
				GuiWidget leftSpace = new GuiWidget(0, 1);
				leftSpace.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
				container.AddChild(leftSpace);
			}

			if (image != null && image.Width > 0)
			{
				imageWidget = new ImageWidget(image);
				imageWidget.VAnchor = VAnchor.ParentCenter;
				imageWidget.Margin = new BorderDouble(right: imageSpacing);
				container.AddChild(imageWidget);
			}

			if (label != "")
			{
				textWidget.VAnchor = VAnchor.ParentCenter;
				textWidget.TextColor = textColor;
				textWidget.Padding = new BorderDouble(3, 0);
				container.AddChild(textWidget);
			}

			if (centerText)
			{
				GuiWidget rightSpace = new GuiWidget(0, 1);
				rightSpace.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
				container.AddChild(rightSpace);

				container.HAnchor = Agg.UI.HAnchor.ParentLeftRight | Agg.UI.HAnchor.FitToChildren;
			}
			container.VAnchor = Agg.UI.VAnchor.ParentCenter;

			container.MinimumSize = new Vector2(width, height);
			container.Margin = margin;
			this.AddChild(container);
			HAnchor = HAnchor.ParentLeftRight | HAnchor.FitToChildren;
			VAnchor = VAnchor.ParentCenter | Agg.UI.VAnchor.FitToChildren;
		}
开发者ID:broettge,项目名称:MatterControl,代码行数:55,代码来源:TextImageButtonFactory.cs


示例18: generate_alpha_mask

        unsafe void generate_alpha_mask(int cx, int cy)
        {
            alphaByteArray = new byte[cx * cy];
            {
#if USE_CLIPPING_ALPHA_MASK
                alphaMaskImageBuffer.AttachBuffer(alphaByteArray, 20 * cx + 20, cx - 40, cy - 40, cx, 8, 1);
#else
                alphaMaskImageBuffer.attach(alphaByteArray, (int)cx, (int)cy, cx, 1);
#endif

                ImageBuffer image = new ImageBuffer();
                image.Attach(alphaMaskImageBuffer, new blender_gray(1), 1, 0, 8);
                ImageClippingProxy clippingProxy = new ImageClippingProxy(image);
                ScanlineCachePacked8 sl = new ScanlineCachePacked8();

                clippingProxy.clear(new RGBA_Floats(0));

                VertexSource.Ellipse ellipseForMask = new MatterHackers.Agg.VertexSource.Ellipse();

                System.Random randGenerator = new Random(1432);

                ScanlineRenderer scanlineRenderer = new ScanlineRenderer();
                int i;
                int num = (int)numMasksSlider.Value;
                for (i = 0; i < num; i++)
                {
                    if (i == num - 1)
                    {
                        ellipseForMask.init(Width / 2, Height / 2, 110, 110, 100);
                        rasterizer.add_path(ellipseForMask);
                        scanlineRenderer.render_scanlines_aa_solid(clippingProxy, rasterizer, sl, new RGBA_Bytes(0, 0, 0, 255));

                        ellipseForMask.init(ellipseForMask.originX, ellipseForMask.originY, ellipseForMask.radiusX - 10, ellipseForMask.radiusY - 10, 100);
                        rasterizer.add_path(ellipseForMask);
                        scanlineRenderer.render_scanlines_aa_solid(clippingProxy, rasterizer, sl, new RGBA_Bytes(255, 0, 0, 255));
                    }
                    else
                    {
                        ellipseForMask.init(randGenerator.Next() % cx,
                                 randGenerator.Next() % cy,
                                 randGenerator.Next() % 100 + 20,
                                 randGenerator.Next() % 100 + 20,
                                 100);
                        // set the color to draw into the alpha channel.
                        // there is not very much reason to set the alpha as you will get the amount of 
                        // transparency based on the color you draw.  (you might want some type of different edeg effect but it will be minor).
                        rasterizer.add_path(ellipseForMask);
                        scanlineRenderer.render_scanlines_aa_solid(clippingProxy, rasterizer, sl, new RGBA_Bytes((int)((float)i / (float)num * 255), 0, 0, 255));
                    }

                }
                
                alphaMaskImageBuffer.DettachBuffer();
            }
        }
开发者ID:jeske,项目名称:agg-sharp,代码行数:55,代码来源:alpha_mask2.cs


示例19: DoDilate3x3MaxValue

        public static void DoDilate3x3MaxValue(ImageBuffer source, ImageBuffer dest)
        {
            if (source.BitDepth != 32 || dest.BitDepth != 32)
            {
                throw new NotImplementedException("We only work with 32 bit at the moment.");
            }

            if (source.Width != dest.Width || source.Height != dest.Height)
            {
                throw new NotImplementedException("Source and Dest have to be the same size");
            }

            int height = source.Height;
            int width = source.Width;
            int sourceStrideInBytes = source.StrideInBytes();
            int destStrideInBytes = dest.StrideInBytes();
            byte[] sourceBuffer = source.GetBuffer();
            byte[] destBuffer = dest.GetBuffer();

            for (int testY = 1; testY < height - 1; testY++)
            {
                for (int testX = 1; testX < width - 1; testX++)
                {
                    RGBA_Bytes maxColor = RGBA_Bytes.Black;
                    int sourceOffset = source.GetBufferOffsetXY(testX, testY -1);

                    // x-1, y-1
                    //maxColor = MaxColor(sourceBuffer, maxColor, sourceOffset - 4);
                    // x0, y-1
                    maxColor = MaxColor(sourceBuffer, maxColor, sourceOffset + 0);
                    // x1, y-1
                    //maxColor = MaxColor(sourceBuffer, maxColor, sourceOffset + 4);

                    // x-1, y0
                    maxColor = MaxColor(sourceBuffer, maxColor, sourceOffset + sourceStrideInBytes - 4);
                    // x0, y0
                    maxColor = MaxColor(sourceBuffer, maxColor, sourceOffset + sourceStrideInBytes + 0);
                    // x+1, y0
                    maxColor = MaxColor(sourceBuffer, maxColor, sourceOffset + sourceStrideInBytes + 4);

                    // x-1, y+1
                    //maxColor = MaxColor(sourceBuffer, maxColor, sourceOffset + sourceStrideInBytes * 2 - 4);
                    // x0, y+1
                    maxColor = MaxColor(sourceBuffer, maxColor, sourceOffset + sourceStrideInBytes * 2 + 0);
                    // x+1, y+1
                    //maxColor = MaxColor(sourceBuffer, maxColor, sourceOffset + sourceStrideInBytes * 2 + 4);

                    int destOffset = dest.GetBufferOffsetXY(testX, testY);
                    destBuffer[destOffset + 2] = maxColor.red;
                    destBuffer[destOffset + 1] = maxColor.green;
                    destBuffer[destOffset + 0] = maxColor.blue;
                    destBuffer[destOffset + 3] = 255;
                }
            }
        }
开发者ID:jeske,项目名称:agg-sharp,代码行数:55,代码来源:Dilate.cs


示例20: blur

		public blur()
		{
			m_rbuf2 = new ImageBuffer();
			m_shape_bounds = new RectangleDouble();
			m_method = new RadioButtonGroup(new Vector2(10.0, 10.0), new Vector2(130.0, 60.0));
			m_radius = new Slider(new Vector2(130 + 10.0, 10.0 + 4.0), new Vector2(290, 8.0));
			m_shadow_ctrl = new PolygonEditWidget(4);
			m_channel_r = new CheckBox(10.0, 80.0, "Red");
			m_channel_g = new CheckBox(10.0, 95.0, "Green");
			m_channel_b = new CheckBox(10.0, 110.0, "Blue");
			m_FlattenCurves = new CheckBox(10, 315, "Convert And Flatten Curves");
			m_FlattenCurves.Checked = true;

			AddChild(m_method);
			m_method.AddRadioButton("Stack Blur");
			m_method.AddRadioButton("Recursive Blur");
			m_method.AddRadioButton("Channels");
			m_method.SelectedIndex = 1;

			AddChild(m_radius);
			m_radius.SetRange(0.0, 40.0);
			m_radius.Value = 15.0;
			m_radius.Text = "Blur Radius={0:F2}";

			AddChild(m_shadow_ctrl);

			AddChild(m_channel_r);
			AddChild(m_channel_g);
			AddChild(m_channel_b);
			AddChild(m_FlattenCurves);
			m_channel_g.Checked = true;

			m_sl = new ScanlineCachePacked8();

			StyledTypeFace typeFaceForLargeA = new StyledTypeFace(LiberationSansFont.Instance, 300, flatenCurves: false);
			m_path = typeFaceForLargeA.GetGlyphForCharacter('a');

			Affine shape_mtx = Affine.NewIdentity();
			shape_mtx *= Affine.NewTranslation(150, 100);
			m_path = new VertexSourceApplyTransform(m_path, shape_mtx);
			m_shape = new FlattenCurves(m_path);

			bounding_rect.bounding_rect_single(m_shape, 0, ref m_shape_bounds);

			m_shadow_ctrl.SetXN(0, m_shape_bounds.Left);
			m_shadow_ctrl.SetYN(0, m_shape_bounds.Bottom);
			m_shadow_ctrl.SetXN(1, m_shape_bounds.Right);
			m_shadow_ctrl.SetYN(1, m_shape_bounds.Bottom);
			m_shadow_ctrl.SetXN(2, m_shape_bounds.Right);
			m_shadow_ctrl.SetYN(2, m_shape_bounds.Top);
			m_shadow_ctrl.SetXN(3, m_shape_bounds.Left);
			m_shadow_ctrl.SetYN(3, m_shape_bounds.Top);
			m_shadow_ctrl.line_color(new RGBA_Floats(0, 0.3, 0.5, 0.3));
		}
开发者ID:glocklueng,项目名称:agg-sharp,代码行数:54,代码来源:blur.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# UI.Button类代码示例发布时间:2022-05-26
下一篇:
C# Agg.RectangleDouble类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap