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


C# MagickImage.Alpha方法代码示例

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


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

示例1: Test_Clip

    private static void Test_Clip(bool inside, QuantumType value)
    {
      using (MagickImage image = new MagickImage(Files.InvitationTif))
      {
        image.Alpha(AlphaOption.Transparent);
        image.Clip("Pad A", inside);
        image.Alpha(AlphaOption.Opaque);

        using (MagickImage mask = image.WriteMask)
        {
          Assert.IsNotNull(mask);
          Assert.AreEqual(false, mask.HasAlpha);

          using (PixelCollection pixels = mask.GetPixels())
          {
            MagickColor pixelA = pixels.GetPixel(0, 0).ToColor();
            MagickColor pixelB = pixels.GetPixel(mask.Width - 1, mask.Height - 1).ToColor();

            Assert.AreEqual(pixelA, pixelB);
            Assert.AreEqual(value, pixelA.R);
            Assert.AreEqual(value, pixelA.G);
            Assert.AreEqual(value, pixelA.B);

            MagickColor pixelC = pixels.GetPixel(mask.Width / 2, mask.Height / 2).ToColor();
            Assert.AreEqual(Quantum.Max - value, pixelC.R);
            Assert.AreEqual(Quantum.Max - value, pixelC.G);
            Assert.AreEqual(Quantum.Max - value, pixelC.B);
          }
        }
      }
    }
开发者ID:dlemstra,项目名称:Magick.NET,代码行数:31,代码来源:MagickImageTests.cs

示例2: Test_Alpha_Endian

    public void Test_Alpha_Endian()
    {
      TiffWriteDefines defines = new TiffWriteDefines()
      {
        Alpha = TiffAlpha.Associated,
        Endian = Endian.MSB,
      };

      using (MagickImage input = new MagickImage(Files.Builtin.Logo))
      {
        input.Settings.SetDefines(defines);
        input.Alpha(AlphaOption.Set);

        using (MagickImage output = WriteTiff(input))
        {
          Assert.AreEqual("associated", output.GetAttribute("tiff:alpha"));
          Assert.AreEqual("msb", output.GetAttribute("tiff:endian"));
        }
      }
    }
开发者ID:dlemstra,项目名称:Magick.NET,代码行数:20,代码来源:TiffWriteDefinesTests.cs

示例3: ExecuteAlpha

 private void ExecuteAlpha(XmlElement element, MagickImage image)
 {
   AlphaOption option_ = Variables.GetValue<AlphaOption>(element, "option");
   image.Alpha(option_);
 }
开发者ID:dlemstra,项目名称:Magick.NET,代码行数:5,代码来源:MagickImage.cs

示例4: DrawTreeCluster

        private void DrawTreeCluster(MagickImage overlay, DrawableFixture fixture)
        {
            //MainForm.Log(string.Format("Image: {0} ({1}) ...", fixture.Name, fixture.TreeCluster.Tree), MainForm.LogLevel.notice);
            string fileName = System.IO.Path.GetFileNameWithoutExtension(fixture.TreeCluster.Tree);
            string defaultTree = "elm1";

            // Load model image
            if (!m_modelImages.ContainsKey(fileName))
            {
                string treeImageFile = string.Format("{0}\\data\\prerendered\\trees\\{1}.png", System.Windows.Forms.Application.StartupPath, fileName);
                if (System.IO.File.Exists(treeImageFile))
                {
                    MagickImage modelImage = new MagickImage(treeImageFile);
                    modelImage.Blur();
                    m_modelImages.Add(fileName, modelImage);
                }
                else
                {
                    MainForm.Log(string.Format("Can not find image for tree {0} ({1}), using default tree", fixture.TreeCluster.Tree, fixture.NifName), MainForm.LogLevel.warning);
                    m_modelImages.Add(fileName, m_modelImages[defaultTree]);
                }
            }

            if (m_modelImages.ContainsKey(fileName) && m_modelImages[fileName] != null)
            {
                // Get the width of the orginal tree shape
                NifRow tree = FixturesLoader.NifRows.Where(n => n.Filename.ToLower() == fixture.TreeCluster.Tree.ToLower()).FirstOrDefault();
                if (tree == null) return;

                System.Drawing.SizeF treeSize = tree.GetSize(0, 0);

                int dimensions = ((fixture.CanvasWidth > fixture.CanvasHeight) ? fixture.CanvasWidth : fixture.CanvasHeight) + 10;
                int extendedWidth = dimensions - fixture.CanvasWidth;
                int extendedHeight = dimensions - fixture.CanvasHeight;

                using (MagickImage treeCluster = new MagickImage(MagickColor.Transparent, dimensions, dimensions))
                {
                    double centerX = treeCluster.Width / 2d;
                    double centerY = treeCluster.Height / 2d;

                    foreach (SharpDX.Vector3 treeInstance in fixture.TreeCluster.TreeInstances)
                    {
                        using (MagickImage treeImage = m_modelImages[fileName].Clone())
                        {
                            double scaleWidthToTreeImage = treeSize.Width / treeImage.Width;
                            double scaleHeightToTreeImage = treeSize.Height / treeImage.Height;
                            int width = Convert.ToInt32(treeImage.Width * scaleWidthToTreeImage * fixture.Scale);
                            int height = Convert.ToInt32(treeImage.Height * scaleHeightToTreeImage * fixture.Scale);
                            treeImage.Resize(width, height);

                            int x = Convert.ToInt32(centerX - width / 2d - zoneConfiguration.ZoneCoordinateToMapCoordinate(treeInstance.X) * (fixture.FixtureRow.Scale / 100));
                            int y = Convert.ToInt32(centerY - height / 2d - zoneConfiguration.ZoneCoordinateToMapCoordinate(treeInstance.Y) * (fixture.FixtureRow.Scale / 100));
                            treeCluster.Composite(treeImage, x, y, CompositeOperator.SrcOver);
                        }
                    }

                    treeCluster.Rotate((360d * fixture.FixtureRow.AxisZ3D - fixture.FixtureRow.A) * -1);

                    using (MagickImage modelCanvas = new MagickImage(MagickColor.Transparent, fixture.CanvasWidth, fixture.CanvasHeight))
                    {
                        foreach (DrawableElement drawableElement in fixture.DrawableElements)
                        {
                            modelCanvas.FillColor = new MagickColor(
                                Convert.ToUInt16(128 * 256 * drawableElement.lightning),
                                Convert.ToUInt16(128 * 256 * drawableElement.lightning),
                                Convert.ToUInt16(128 * 256 * drawableElement.lightning)
                            );

                            DrawablePolygon polyDraw = new DrawablePolygon(drawableElement.coordinates);
                            modelCanvas.Draw(polyDraw);
                        }

                        modelCanvas.Composite(treeCluster, Gravity.Center, CompositeOperator.DstIn);
                        treeCluster.Composite(modelCanvas, Gravity.Center, CompositeOperator.Overlay);
                        //treeCluster.Composite(modelCanvas, Gravity.Center, CompositeOperator.SrcOver);
                    }

                    if (fixture.RendererConf.HasShadow)
                    {
                        treeCluster.BorderColor = MagickColor.Transparent;
                        treeCluster.Border(1);
                        treeCluster.Shadow(
                            fixture.RendererConf.ShadowOffsetX,
                            fixture.RendererConf.ShadowOffsetY,
                            fixture.RendererConf.ShadowSize,
                            new Percentage(100 - fixture.RendererConf.ShadowTransparency),
                            fixture.RendererConf.ShadowColor
                        );
                    }

                    if (fixture.RendererConf.Transparency != 0)
                    {
                        treeCluster.Alpha(AlphaOption.Set);

                        double divideValue = 100.0 / (100.0 - fixture.RendererConf.Transparency);
                        treeCluster.Evaluate(Channels.Alpha, EvaluateOperator.Divide, divideValue);
                    }

                    overlay.Composite(treeCluster, Convert.ToInt32(fixture.CanvasX - extendedWidth/2), Convert.ToInt32(fixture.CanvasY - extendedHeight/2), CompositeOperator.SrcOver);
                }
//.........这里部分代码省略.........
开发者ID:Merec,项目名称:DAoC-MapCreator,代码行数:101,代码来源:MapFixtures.cs

示例5: DrawTree

        private void DrawTree(MagickImage overlay, DrawableFixture fixture)
        {
            System.Drawing.Color testColor = System.Drawing.ColorTranslator.FromHtml("#5e683a");

            using (MagickImage pattern = new MagickImage(MagickColor.Transparent, fixture.CanvasWidth, fixture.CanvasHeight))
            {
                using (MagickImage patternTexture = new MagickImage(string.Format("{0}\\data\\textures\\{1}.png", System.Windows.Forms.Application.StartupPath, "leaves_mask")))
                {
                    patternTexture.Resize(fixture.CanvasWidth / 2, fixture.CanvasHeight / 2);
                    pattern.Texture(patternTexture);

                    Random rnd = new Random();
                    pattern.Rotate(rnd.Next(0, 360));

                    using (MagickImage modelCanvas = new MagickImage(MagickColor.Transparent, fixture.CanvasWidth, fixture.CanvasHeight))
                    {
                        foreach (DrawableElement drawableElement in fixture.DrawableElements)
                        {
                            DrawablePolygon polyDraw = new DrawablePolygon(drawableElement.coordinates);

                            // A Shaded model without lightning is not shaded... but just we add this just be flexible
                            if (fixture.RendererConf.HasLight)
                            {
                                float r, g, b, light;

                                light = (float)drawableElement.lightning * 2f;
                                r = fixture.Tree.AverageColor.R * light;
                                g = fixture.Tree.AverageColor.G * light;
                                b = fixture.Tree.AverageColor.B * light;

                                modelCanvas.FillColor = new MagickColor(
                                    Convert.ToUInt16(r * 255),
                                    Convert.ToUInt16(g * 255),
                                    Convert.ToUInt16(b * 255)
                                );
                            }
                            else
                            {
                                modelCanvas.FillColor = fixture.RendererConf.Color;
                            }

                            modelCanvas.Draw(polyDraw);
                        }

                        // Add leaves pattern
                        pattern.Composite(modelCanvas, Gravity.Center, CompositeOperator.DstIn);
                        modelCanvas.Composite(pattern, Gravity.Center, CompositeOperator.CopyAlpha);

                        if (fixture.RendererConf.HasShadow)
                        {
                            modelCanvas.BorderColor = MagickColor.Transparent;
                            modelCanvas.Border((int)fixture.RendererConf.ShadowSize);
                            modelCanvas.Shadow(
                                fixture.RendererConf.ShadowOffsetX,
                                fixture.RendererConf.ShadowOffsetY,
                                fixture.RendererConf.ShadowSize,
                                new Percentage(100 - fixture.RendererConf.ShadowTransparency),
                                fixture.RendererConf.ShadowColor
                            );

                            // Update the canvas position to match the new border
                            fixture.CanvasX -= fixture.RendererConf.ShadowSize;
                            fixture.CanvasY -= fixture.RendererConf.ShadowSize;
                        }

                        if (fixture.RendererConf.Transparency != 0)
                        {
                            modelCanvas.Alpha(AlphaOption.Set);

                            double divideValue = 100.0 / (100.0 - fixture.RendererConf.Transparency);
                            modelCanvas.Evaluate(Channels.Alpha, EvaluateOperator.Divide, divideValue);
                        }

                        overlay.Composite(modelCanvas, Convert.ToInt32(fixture.CanvasX), Convert.ToInt32(fixture.CanvasY), CompositeOperator.SrcOver);
                    }
                }
            }
        }
开发者ID:Merec,项目名称:DAoC-MapCreator,代码行数:78,代码来源:MapFixtures.cs

示例6: DrawShaded

        private void DrawShaded(MagickImage overlay, DrawableFixture fixture)
        {
            //MainForm.Log(string.Format("Shaded: {0} ({1}) ...", fixture.Name, fixture.NifName), MainForm.LogLevel.notice);

            using (MagickImage modelCanvas = new MagickImage(MagickColor.Transparent, fixture.CanvasWidth, fixture.CanvasHeight))
            {
                foreach (DrawableElement drawableElement in fixture.DrawableElements)
                {
                    DrawablePolygon polyDraw = new DrawablePolygon(drawableElement.coordinates);

                    // A Shaded model without lightning is not shaded... but just we add this just be flexible
                    if (fixture.RendererConf.HasLight)
                    {
                        modelCanvas.FillColor = new MagickColor(
                            Convert.ToUInt16(drawableElement.lightning * fixture.RendererConf.Color.R),
                            Convert.ToUInt16(drawableElement.lightning * fixture.RendererConf.Color.G),
                            Convert.ToUInt16(drawableElement.lightning * fixture.RendererConf.Color.B)
                        );
                    }
                    else
                    {
                        modelCanvas.FillColor = fixture.RendererConf.Color;
                    }

                    modelCanvas.Draw(polyDraw);

                }

                if (fixture.RendererConf.HasShadow)
                {
                    modelCanvas.BorderColor = MagickColor.Transparent;
                    modelCanvas.Border((int)fixture.RendererConf.ShadowSize);
                    modelCanvas.Shadow(
                        fixture.RendererConf.ShadowOffsetX,
                        fixture.RendererConf.ShadowOffsetY,
                        fixture.RendererConf.ShadowSize,
                        new Percentage(100 - fixture.RendererConf.ShadowTransparency),
                        fixture.RendererConf.ShadowColor
                    );

                    // Update the canvas position to match the new border
                    fixture.CanvasX -= fixture.RendererConf.ShadowSize;
                    fixture.CanvasY -= fixture.RendererConf.ShadowSize;
                }

                if (fixture.RendererConf.Transparency != 0)
                {
                    modelCanvas.Alpha(AlphaOption.Set);

                    double divideValue = 100.0 / (100.0 - fixture.RendererConf.Transparency);
                    modelCanvas.Evaluate(Channels.Alpha, EvaluateOperator.Divide, divideValue);
                }

                overlay.Composite(modelCanvas, Convert.ToInt32(fixture.CanvasX), Convert.ToInt32(fixture.CanvasY), CompositeOperator.SrcOver);
            }
        }
开发者ID:Merec,项目名称:DAoC-MapCreator,代码行数:56,代码来源:MapFixtures.cs

示例7: Draw

        private void Draw(MagickImage map, List<DrawableFixture> fixtures)
        {
            MainForm.ProgressStart(string.Format("Drawing fixtures ({0}) ...", fixtures.Count));
            Stopwatch timer = Stopwatch.StartNew();

            using (MagickImage modelsOverlay = new MagickImage(MagickColor.Transparent, zoneConfiguration.TargetMapSize, zoneConfiguration.TargetMapSize))
            {
                using (MagickImage treeOverlay = new MagickImage(MagickColor.Transparent, zoneConfiguration.TargetMapSize, zoneConfiguration.TargetMapSize))
                {
                    int processCounter = 0;
                    foreach (DrawableFixture fixture in fixtures)
                    {
                        // Debug single models
                        /*
                        if (fixture.FixtureRow.NifId != 443 && fixture.FixtureRow.NifId != 433 && fixture.FixtureRow.NifId != 459)
                        {
                            continue;
                        }
                        else
                        {
                            DrawShaded((fixture.IsTree || fixture.IsTreeCluster) ? treeOverlay : modelsOverlay, fixture);
                        }
                        */

                        switch (fixture.RendererConf.Renderer)
                        {
                            case FixtureRenderererType.Shaded:
                                DrawShaded((fixture.IsTree || fixture.IsTreeCluster) ? treeOverlay : modelsOverlay, fixture);
                                break;
                            case FixtureRenderererType.Flat:
                                DrawFlat((fixture.IsTree || fixture.IsTreeCluster) ? treeOverlay : modelsOverlay, fixture);
                                break;
                            case FixtureRenderererType.Image:
                                //DrawShaded((fixture.IsTree || fixture.IsTreeCluster) ? treeOverlay : modelsOverlay, fixture);
                                DrawImage((fixture.IsTree || fixture.IsTreeCluster) ? treeOverlay : modelsOverlay, fixture);
                                break;
                        }

                        int percent = 100 * processCounter / fixtures.Count();
                        MainForm.ProgressUpdate(percent);
                        processCounter++;
                    }

                    MainForm.ProgressStartMarquee("Merging ...");

                    FixtureRendererConfiguration2 treeImagesRConf = FixtureRendererConfigurations.GetRendererById("TreeImage");
                    if (treeImagesRConf.HasShadow)
                    {
                        //treeOverlay.BorderColor = MagickColor.Transparent;
                        //treeOverlay.Border(1);
                        treeOverlay.Shadow(
                            treeImagesRConf.ShadowOffsetX,
                            treeImagesRConf.ShadowOffsetY,
                            treeImagesRConf.ShadowSize,
                            new Percentage(100 - treeImagesRConf.ShadowTransparency),
                            treeImagesRConf.ShadowColor
                        );

                    }

                    if (treeImagesRConf.Transparency != 0)
                    {
                        treeOverlay.Alpha(AlphaOption.Set);
                        double divideValue = 100.0 / (100.0 - TreeTransparency);
                        treeOverlay.Evaluate(Channels.Alpha, EvaluateOperator.Divide, divideValue);
                    }

                    map.Composite(modelsOverlay, 0, 0, CompositeOperator.SrcOver);
                    map.Composite(treeOverlay, 0, 0, CompositeOperator.SrcOver);
                }
            }

            timer.Stop();
            MainForm.Log(string.Format("Finished in {0} seconds.", timer.Elapsed.TotalSeconds), MainForm.LogLevel.success);
            MainForm.ProgressReset();
        }
开发者ID:Merec,项目名称:DAoC-MapCreator,代码行数:76,代码来源:MapFixtures.cs

示例8: Draw

        /// <summary>
        /// Draw the bounds onto map
        /// </summary>
        /// <param name="map"></param>
        public void Draw(MagickImage map)
        {
            if (m_bounds.Count == 0) return;
            MainForm.ProgressStart("Drawing zone bounds ...");

            // Sort the polygons
            List<List<Coordinate>> polygons = new List<List<Coordinate>>();
            List<List<Coordinate>> negatedPolygons = new List<List<Coordinate>>();

            foreach (List<PointF> polygon in m_bounds)
            {
                bool isClockwise = Tools.PolygonHasClockwiseOrder(polygon);
                var polygonConverted = polygon.Select(c => new Coordinate(zoneConfiguration.ZoneCoordinateToMapCoordinate(c.X), zoneConfiguration.ZoneCoordinateToMapCoordinate(c.Y))).ToList();

                // polygons in clockwise order needs to be negated
                if (isClockwise) negatedPolygons.Add(polygonConverted);
                else polygons.Add(polygonConverted);
            }

            MagickColor backgroundColor = MagickColor.Transparent;
            if (polygons.Count == 0) {
                // There are no normal polygons, we need to fill the hole zone and substract negatedPolygons
                backgroundColor = m_boundsColor;
            }

            using (MagickImage boundMap = new MagickImage(backgroundColor, zoneConfiguration.TargetMapSize, zoneConfiguration.TargetMapSize))
            {
                int progressCounter = 0;

                boundMap.Alpha(AlphaOption.Set);
                boundMap.FillColor = m_boundsColor;
                foreach (List<Coordinate> coords in polygons)
                {
                    DrawablePolygon poly = new DrawablePolygon(coords);
                    boundMap.Draw(poly);

                    progressCounter++;
                    int percent = 100 * progressCounter / m_bounds.Count();
                    MainForm.ProgressUpdate(percent);
                }

                if (negatedPolygons.Count > 0)
                {
                    using (MagickImage negatedBoundMap = new MagickImage(Color.Transparent, zoneConfiguration.TargetMapSize, zoneConfiguration.TargetMapSize))
                    {
                        negatedBoundMap.FillColor = m_boundsColor;

                        foreach (List<Coordinate> coords in negatedPolygons)
                        {
                            DrawablePolygon poly = new DrawablePolygon(coords);
                            negatedBoundMap.Draw(poly);

                            progressCounter++;
                            int percent = 100 * progressCounter / m_bounds.Count();
                            MainForm.ProgressUpdate(percent);
                        }
                        boundMap.Composite(negatedBoundMap, 0, 0, CompositeOperator.DstOut);
                    }
                }

                MainForm.ProgressStartMarquee("Merging ...");
                if (ExcludeFromMap)
                {
                    map.Composite(boundMap, 0, 0, CompositeOperator.DstOut);
                }
                else
                {
                    if (m_transparency != 0)
                    {
                        boundMap.Alpha(AlphaOption.Set);
                        double divideValue = 100.0 / (100.0 - m_transparency);
                        boundMap.Evaluate(Channels.Alpha, EvaluateOperator.Divide, divideValue);
                    }

                    map.Composite(boundMap, 0, 0, CompositeOperator.SrcOver);
                }
            }

            if (debug)
            {
                DebugMaps();
            }

            MainForm.ProgressReset();
        }
开发者ID:Merec,项目名称:DAoC-MapCreator,代码行数:89,代码来源:MapBounds.cs

示例9: Draw

        public void Draw(MagickImage map)
        {
            MainForm.ProgressStart("Rendering water ...");

            using (PixelCollection heightmapPixels = zoneConfiguration.Heightmap.HeightmapScaled.GetReadOnlyPixels())
            {
                using (MagickImage water = new MagickImage(MagickColor.Transparent, zoneConfiguration.TargetMapSize, zoneConfiguration.TargetMapSize))
                {
                    int progressCounter = 0;

                    foreach (WaterConfiguration river in m_waterAreas)
                    {
                        MainForm.Log(river.Name + "...", MainForm.LogLevel.notice);

                        MagickColor fillColor;
                        if (m_useClientColors) fillColor = river.Color;
                        else fillColor = m_waterColor;
                        //water.FillColor = fillColor;

                        // Get the river coordinates and scale them to the targets size
                        List<Coordinate> riverCoordinates = river.GetCoordinates().Select(c => new Coordinate(c.X * zoneConfiguration.MapScale, c.Y * zoneConfiguration.MapScale)).ToList();

                        // Texture
                        using (MagickImage texture = new MagickImage((river.Type.ToLower() == "lava") ? GetLavaTexture() : GetWateryTexture()))
                        {
                            using (MagickImage pattern = new MagickImage(fillColor, texture.Width, texture.Height))
                            {
                                texture.Composite(pattern, 0, 0, CompositeOperator.DstIn);
                                texture.Composite(pattern, 0, 0, CompositeOperator.ColorDodge);

                                water.FillPattern = texture;
                                DrawablePolygon poly = new DrawablePolygon(riverCoordinates);
                                water.Draw(poly);
                            }
                        }

                        // get the min/max and just process them
                        int minX = Convert.ToInt32(riverCoordinates.Min(m => m.X)) - 10;
                        int maxX = Convert.ToInt32(riverCoordinates.Max(m => m.X)) + 10;
                        int minY = Convert.ToInt32(riverCoordinates.Min(m => m.Y)) - 10;
                        int maxY = Convert.ToInt32(riverCoordinates.Max(m => m.Y)) + 10;

                        using (WritablePixelCollection riverPixelCollection = water.GetWritablePixels())
                        {
                            for (int x = minX; x < maxX; x++)
                            {
                                if (x < 0) continue;
                                if (x >= zoneConfiguration.TargetMapSize) continue;

                                for (int y = minY; y < maxY; y++)
                                {
                                    if (y < 0) continue;
                                    if (y >= zoneConfiguration.TargetMapSize) continue;

                                    ushort pixelHeight = heightmapPixels.GetPixel(x, y).GetChannel(0);
                                    if (pixelHeight > river.Height)
                                    {
                                        Pixel newPixel = new Pixel(x, y, new ushort[] { 0, 0, 0, ushort.MinValue });
                                        riverPixelCollection.Set(newPixel);
                                    }
                                }
                            }
                        }

                        if (debug)
                        {
                            DebugRiver(progressCounter, river, riverCoordinates);
                        }

                        int percent = 100 * progressCounter / m_waterAreas.Count();
                        MainForm.ProgressUpdate(percent);
                        progressCounter++;
                    }

                    MainForm.ProgressStartMarquee("Merging...");

                    if (WaterTransparency != 0)
                    {
                        water.Alpha(AlphaOption.Set);
                        double divideValue = 100.0 / (100.0 - WaterTransparency);
                        water.Evaluate(Channels.Alpha, EvaluateOperator.Divide, divideValue);
                    }

                    water.Blur();
                    map.Composite(water, 0, 0, CompositeOperator.SrcOver);
                }
            }

            MainForm.ProgressReset();
        }
开发者ID:Merec,项目名称:DAoC-MapCreator,代码行数:90,代码来源:MapWater.cs

示例10: Test_Channels

    public void Test_Channels()
    {
      PixelChannel[] rgb = new PixelChannel[]
      {
        PixelChannel.Red, PixelChannel.Green, PixelChannel.Blue
      };

      PixelChannel[] rgba = new PixelChannel[]
      {
        PixelChannel.Red, PixelChannel.Green, PixelChannel.Blue, PixelChannel.Alpha
      };

      PixelChannel[] gray = new PixelChannel[]
      {
        PixelChannel.Gray
      };

      PixelChannel[] grayAlpha = new PixelChannel[]
      {
        PixelChannel.Gray, PixelChannel.Alpha
      };

      PixelChannel[] cmyk = new PixelChannel[]
      {
        PixelChannel.Cyan, PixelChannel.Magenta, PixelChannel.Yellow, PixelChannel.Black
      };

      PixelChannel[] cmyka = new PixelChannel[]
      {
        PixelChannel.Cyan, PixelChannel.Magenta, PixelChannel.Yellow, PixelChannel.Black, PixelChannel.Alpha
      };

      using (MagickImage image = new MagickImage(Files.RoseSparkleGIF))
      {
        CollectionAssert.AreEqual(rgba, image.Channels.ToArray());

        image.Alpha(AlphaOption.Off);

        CollectionAssert.AreEqual(rgb, image.Channels.ToArray());
      }

      using (MagickImage image = new MagickImage(Files.SnakewarePNG))
      {
        CollectionAssert.AreEqual(grayAlpha, image.Channels.ToArray());

        using (MagickImage redChannel = image.Separate(Channels.Red).First())
        {
          CollectionAssert.AreEqual(gray, redChannel.Channels.ToArray());

          redChannel.Alpha(AlphaOption.On);

          CollectionAssert.AreEqual(grayAlpha, redChannel.Channels.ToArray());
        }
      }

      using (MagickImage image = new MagickImage(Files.SnakewarePNG))
      {
        image.ColorSpace = ColorSpace.CMYK;

        CollectionAssert.AreEqual(cmyka, image.Channels.ToArray());

        image.Alpha(AlphaOption.Off);

        CollectionAssert.AreEqual(cmyk, image.Channels.ToArray());
      }
    }
开发者ID:marinehero,项目名称:Magick.NET,代码行数:66,代码来源:MagickImageTests.cs

示例11: Test_Swirl

    public void Test_Swirl()
    {
      using (MagickImage image = new MagickImage(Files.Builtin.Logo))
      {
        image.Alpha(AlphaOption.Deactivate);

        ColorAssert.AreEqual(MagickColors.Red, image, 287, 74);
        ColorAssert.AreNotEqual(MagickColors.White, image, 363, 333);

        image.Swirl(60);

        ColorAssert.AreNotEqual(MagickColors.Red, image, 287, 74);
        ColorAssert.AreEqual(MagickColors.White, image, 363, 333);
      }
    }
开发者ID:dlemstra,项目名称:Magick.NET,代码行数:15,代码来源:MagickImageTests.cs

示例12: Test_Alpha

    public void Test_Alpha()
    {
      using (MagickImage image = new MagickImage(Files.Builtin.Wizard))
      {
        Assert.AreEqual(image.HasAlpha, false);

        image.Alpha(AlphaOption.Transparent);

        Assert.AreEqual(image.HasAlpha, true);
        ColorAssert.AreEqual(MagickColors.Transparent, image, 0, 0);

        image.BackgroundColor = new MagickColor("red");
        image.Alpha(AlphaOption.Background);
        image.Alpha(AlphaOption.Off);

        Assert.AreEqual(image.HasAlpha, false);
        ColorAssert.AreEqual(new MagickColor(Quantum.Max, 0, 0), image, 0, 0);
      }
    }
开发者ID:dlemstra,项目名称:Magick.NET,代码行数:19,代码来源:MagickImageTests.cs

示例13: Test_LevelColors

    public void Test_LevelColors()
    {
      using (MagickImage image = new MagickImage(Files.MagickNETIconPNG))
      {
        image.LevelColors(MagickColors.Fuchsia, MagickColors.Goldenrod);
        ColorAssert.AreEqual(new MagickColor("#ffffbed24bc3fffa"), image, 42, 75);
        ColorAssert.AreEqual(new MagickColor("#ffffffff0809"), image, 62, 75);
      }

      using (MagickImage first = new MagickImage(Files.MagickNETIconPNG))
      {
        first.LevelColors(MagickColors.Fuchsia, MagickColors.Goldenrod, Channels.Blue);
        first.InverseLevelColors(MagickColors.Fuchsia, MagickColors.Goldenrod, Channels.Blue);
        first.Alpha(AlphaOption.Background);

        using (MagickImage second = new MagickImage(Files.MagickNETIconPNG))
        {
          second.Alpha(AlphaOption.Background);
#if Q8
          Assert.AreEqual(0.0, first.Compare(second, ErrorMetric.RootMeanSquared));
#elif Q16 || Q16HDRI
          Assert.AreEqual(0.0, 0.00000001, first.Compare(second, ErrorMetric.RootMeanSquared));
#else
#error Not implemented!
#endif
        }
      }
    }
开发者ID:dlemstra,项目名称:Magick.NET,代码行数:28,代码来源:MagickImageTests.cs

示例14: Test_ContrastStretch

    public void Test_ContrastStretch()
    {
      using (MagickImage image = new MagickImage(Files.Builtin.Wizard))
      {
        image.ContrastStretch(new Percentage(50), new Percentage(80));
        image.Alpha(AlphaOption.Opaque);

        ColorAssert.AreEqual(MagickColors.Black, image, 160, 300);
        ColorAssert.AreEqual(MagickColors.Red, image, 325, 175);
      }
    }
开发者ID:dlemstra,项目名称:Magick.NET,代码行数:11,代码来源:MagickImageTests.cs


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