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


C# MagickImage.GetWritablePixels方法代码示例

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


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

示例1: Draw

        public void Draw(MagickImage map)
        {
            MainForm.ProgressStart("Drawing lightmap ...");

            // Get the heightmap
            MagickImage heightmap = zoneConfiguration.Heightmap.Heightmap;

            using (MagickImage lightmap = new MagickImage(Color.Transparent, 256, 256))
            {
                using (PixelCollection heightmapPixels = heightmap.GetReadOnlyPixels())
                {
                    using (WritablePixelCollection lightmapPixels = lightmap.GetWritablePixels())
                    {
                        // z-component of surface normals
                        double nz = 512d / zScale;
                        double nz_2 = nz * nz;
                        double nzlz = nz * lightVector[2];

                        int y1 = 0, y2 = 0;
                        for (int y = 0; y < lightmap.Height; y++)
                        {
                            if (y == 0) y1 = 0;
                            else y1 = y - 1;
                            if (y == 255) y2 = 255;
                            else y2 = y + 1;

                            int x1 = 0, x2 = 0;
                            for (int x = 0; x < lightmap.Width; x++)
                            {
                                if (x == 0) x1 = 0;
                                else x1 = x - 1;
                                if (x == 255) x2 = 255;
                                else x2 = x + 1;

                                double l = heightmapPixels.GetPixel(x1, y).GetChannel(0);
                                double r = heightmapPixels.GetPixel(x2, y).GetChannel(0);
                                double u = heightmapPixels.GetPixel(x, y1).GetChannel(0);
                                double d = heightmapPixels.GetPixel(x, y2).GetChannel(0);

                                double nx = l - r;
                                double ny = u - d;

                                double m_normal = Math.Sqrt(nx * nx + ny * ny + nz_2);
                                double ndotl = (nx * lightVector[0] + ny * lightVector[1] + nzlz) / m_normal;

                                double pixelValue = lightBase - ndotl * lightScale * 256d;

                                ushort pixelValueDiff = 0;
                                ushort alphaValue = ushort.MaxValue;
                                if(pixelValue < 0)
                                {
                                    pixelValueDiff = 0;
                                    alphaValue = (ushort)pixelValue;
                                }
                                else
                                {
                                    pixelValueDiff = (ushort)pixelValue;
                                }

                                // ColorDodge map
                                // white lightens areas where black does nothing
                                // alpha darkens areas
                                lightmapPixels.Set(x, y, new ushort[] { pixelValueDiff, pixelValueDiff, pixelValueDiff, alphaValue });
                            }

                            int percent = 100 * y / lightmap.Height;
                            MainForm.ProgressUpdate(percent);
                        }
                    }
                }

                MainForm.ProgressStartMarquee("Merging...");
                lightmap.Blur(0.0, 0.5);

                lightmap.VirtualPixelMethod = VirtualPixelMethod.Transparent;
                lightmap.FilterType = FilterType.Gaussian;
                lightmap.Resize(zoneConfiguration.TargetMapSize, zoneConfiguration.TargetMapSize);

                // Apply the bumpmap using ColorDodge
                map.Composite(lightmap, 0, 0, CompositeOperator.ColorDodge);

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

示例2: PointGenerator

        public static List<string> PointGenerator(string inputBitmapPath, PixFormat _pixFor)
        {
            List<string> imglist = new List<string>();
            try
            {
                if (_pixFor == PixFormat._null)
                    throw new Exception("Format null olamaz") { Source = "" };

                using (MagickImage imagem = new MagickImage(inputBitmapPath))
                {
                    //############# ResizeImage #############
                    int yuzde = 100;
                    imagem.Quality = 100;
                    int _w = imagem.Width + (imagem.Width / 100) * yuzde;
                    int _h = imagem.Height + (imagem.Height / 100) * yuzde;
                    int new_W = _w - (_w % (int)_pixFor);
                    int new_H = _h - (_h % (int)_pixFor);
                    imagem.Resize(new_W, new_H);
                    imagem.Blur(5, 5);
                    //############# GenerateSquare #############
                    /////////// calculate image point rgb avg   ////////////
                    string curImgPth = Path.GetFileName(inputBitmapPath);
                    string path = UserProperty.PixelXmlMap_Path + "\\" + curImgPth.Substring(0, curImgPth.Length - 4) + _pixFor.ToString() + "_.xml";
                    FileInfo finf = new FileInfo(path);
                    List<ImgSquare> sp0 = new List<ImgSquare>();
                    if (!File.Exists(path))
                    {
                        int[,] pixavg = new int[5, 3];
                        int _pixformat = (int)_pixFor;
                        WritablePixelCollection _totalpix = imagem.GetWritablePixels(0, 0, imagem.Width, imagem.Height);
                        int range = _pixformat / 2;
                        for (int w = 0; w < imagem.Width; w += _pixformat)
                        {
                            for (int h = 0; h < imagem.Height; h += _pixformat)
                            {
                                if (!(w + _pixformat <= imagem.Width && h + _pixformat <= imagem.Height))
                                    continue;//olmazda olursa diye
                                pixavg = new int[5, 3];
                                for (int x = 0; x < range; x++)
                                {
                                    for (int y = 0; y < range; y++)
                                    {
                                        Color a = _totalpix.GetPixel(x + w + 0, h + 0 + y).ToColor().ToColor();
                                        pixavg[0, 0] += a.R;
                                        pixavg[0, 1] += a.G;
                                        pixavg[0, 2] += a.B;

                                        Color b = _totalpix.GetPixel(x + w + range, h + y).ToColor().ToColor();
                                        pixavg[1, 0] += b.R;
                                        pixavg[1, 1] += b.G;
                                        pixavg[1, 2] += b.B;

                                        Color c = _totalpix.GetPixel(x + w, h + range + y).ToColor().ToColor();
                                        pixavg[2, 0] += c.R;
                                        pixavg[2, 1] += c.G;
                                        pixavg[2, 2] += c.B;

                                        Color d = _totalpix.GetPixel(x + w + range, h + range + y).ToColor().ToColor();
                                        pixavg[3, 0] += d.R;
                                        pixavg[3, 1] += d.G;
                                        pixavg[3, 2] += d.B;
                                    }
                                }

                                //tümü için aynı toplanıyor
                                pixavg[4, 0] = pixavg[0, 0] + pixavg[1, 0] + pixavg[2, 0] + pixavg[3, 0];
                                pixavg[4, 1] = pixavg[0, 1] + pixavg[1, 1] + pixavg[2, 1] + pixavg[3, 1];
                                pixavg[4, 2] = pixavg[0, 2] + pixavg[1, 2] + pixavg[2, 2] + pixavg[3, 2];
                                //----

                                int totalminiPix = (range * range);
                                pixavg[0, 0] /= totalminiPix;
                                pixavg[0, 1] /= totalminiPix;
                                pixavg[0, 2] /= totalminiPix;

                                pixavg[1, 0] /= totalminiPix;
                                pixavg[1, 1] /= totalminiPix;
                                pixavg[1, 2] /= totalminiPix;

                                pixavg[2, 0] /= totalminiPix;
                                pixavg[2, 1] /= totalminiPix;
                                pixavg[2, 2] /= totalminiPix;

                                pixavg[3, 0] /= totalminiPix;
                                pixavg[3, 1] /= totalminiPix;
                                pixavg[3, 2] /= totalminiPix;


                                int totalPix = totalminiPix * 4;
                                pixavg[4, 0] /= totalPix;
                                pixavg[4, 1] /= totalPix;
                                pixavg[4, 2] /= totalPix;

                                sp0.Add(new ImgSquare(w, h, new List<QuardPixAvg>() 
                            {
                                new QuardPixAvg(Color.FromArgb((pixavg[0, 0]), (pixavg[0, 1]), (pixavg[0, 2])), QuardBolum.SolUst),
                                new QuardPixAvg (Color.FromArgb((pixavg[1, 0]), (pixavg[1, 1]), (pixavg[1, 2])), QuardBolum.SagUst),
                                new QuardPixAvg(Color.FromArgb((pixavg[2, 0]), (pixavg[2, 1]), (pixavg[2, 2])), QuardBolum.SolAlt),
                                new QuardPixAvg(Color.FromArgb((pixavg[3, 0]), (pixavg[3, 1]), (pixavg[3, 2])), QuardBolum.SagAlt),
                                new QuardPixAvg(Color.FromArgb((pixavg[4, 0]), (pixavg[4, 1]), (pixavg[4, 2])), QuardBolum.TotalAvg)
//.........这里部分代码省略.........
开发者ID:msx752,项目名称:OPALOP-Picture-Mosaic,代码行数:101,代码来源:ImageProperty.cs

示例3: DebugMaps

        private void DebugMaps()
        {
            MainForm.Log("Drawing debug bound images ...", MainForm.LogLevel.warning);
            MainForm.ProgressStartMarquee("Debug bound images ...");

            DirectoryInfo debugDir = new DirectoryInfo(string.Format("{0}\\debug\\bound\\{1}", System.Windows.Forms.Application.StartupPath, zoneConfiguration.ZoneId));
            if (!debugDir.Exists) debugDir.Create();
            debugDir.GetFiles().ToList().ForEach(f => f.Delete());

            int boundIndex = 0;
            foreach (List<PointF> allCoords in m_bounds)
            {
                using (MagickImage bound = new MagickImage(MagickColor.Transparent, zoneConfiguration.TargetMapSize, zoneConfiguration.TargetMapSize))
                {
                    List<Coordinate> coords = allCoords.Select(c => new Coordinate(zoneConfiguration.ZoneCoordinateToMapCoordinate(c.X), zoneConfiguration.ZoneCoordinateToMapCoordinate(c.Y))).ToList();

                    DrawablePolygon poly = new DrawablePolygon(coords);
                    bound.FillColor = new MagickColor(0, 0, 0, 256 * 128);
                    bound.Draw(poly);

                    // Print Text
                    for (int i = 0; i < coords.Count; i++)
                    {
                        double x, y;

                        if (coords[i].X > zoneConfiguration.TargetMapSize / 2) x = coords[i].X - 15;
                        else x = coords[i].X + 1;

                        if (coords[i].Y < zoneConfiguration.TargetMapSize / 2) y = coords[i].Y + 15;
                        else y = coords[i].Y - 1;

                        bound.FontPointsize = 10.0;
                        bound.FillColor = Color.Black;
                        DrawableText text = new DrawableText(x, y, string.Format("{0} ({1}/{2})", i, zoneConfiguration.MapCoordinateToZoneCoordinate(coords[i].X), zoneConfiguration.MapCoordinateToZoneCoordinate(coords[i].Y)));
                        bound.Draw(text);

                        using (WritablePixelCollection pixels = bound.GetWritablePixels())
                        {
                            int x2, y2;
                            if (coords[i].X == zoneConfiguration.TargetMapSize) x2 = zoneConfiguration.TargetMapSize - 1;
                            else x2 = (int)coords[i].X;
                            if (coords[i].Y == zoneConfiguration.TargetMapSize) y2 = zoneConfiguration.TargetMapSize - 1;
                            else y2 = (int)coords[i].Y;

                            pixels.Set(x2, y2, new ushort[] { 0, 0, 65535, 0 });
                        }
                    }

                    //bound.Quality = 100;
                    bound.Write(string.Format("{0}\\bound_{1}.png", debugDir.FullName, boundIndex));

                    boundIndex++;
                }
            }

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

示例4: 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

示例5: GenerateHeightmap

        private void GenerateHeightmap()
        {
            if(this.heightmapGenerated) return;
            MainForm.ProgressStart("Processing heightmap ...");

            using (MagickImage offsetmap = zoneConfiguration.GetOffsetMap())
            {
                using (MagickImage terrainmap = zoneConfiguration.GetTerrainMap())
                {
                    m_heightmap = new MagickImage(Color.Black, offsetmap.Width, offsetmap.Height);

                    using (WritablePixelCollection heightmapPixels = m_heightmap.GetWritablePixels())
                    {
                        PixelCollection terrainPixels = terrainmap.GetReadOnlyPixels();
                        PixelCollection offsetPixels = offsetmap.GetReadOnlyPixels();

                        for (int x = 0; x < offsetmap.Width; x++)
                        {
                            for (int y = 0; y < offsetmap.Height; y++)
                            {
                                ushort terrainPixelValue = (ushort)(terrainPixels[x, y].GetChannel(0) / 256);
                                ushort offsetPixelValue = (ushort)(offsetPixels[x, y].GetChannel(0) / 256);
                                ushort heightmapPixelValue = (ushort)(terrainPixelValue * m_terrainfactor + offsetPixelValue * m_offsetfactor);

                                heightmapPixels.Set(x, y, new ushort[] { heightmapPixelValue, heightmapPixelValue, heightmapPixelValue });
                            }

                            int percent = 100 * x / offsetmap.Width;
                            MainForm.ProgressUpdate(percent);
                        }

                        heightmapPixels.Write();
                    }

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

                    m_heightmap.Quality = 100;
                    m_heightmap.Write(m_heightmapFile.FullName);

                    // Scale to target size
                    m_heightmapScaled = new MagickImage(m_heightmap);
                    m_heightmapScaled.Resize(zoneConfiguration.TargetMapSize, zoneConfiguration.TargetMapSize);
                }
            }

            this.heightmapGenerated = true;
            MainForm.ProgressReset();
        }
开发者ID:Merec,项目名称:DAoC-MapCreator,代码行数:48,代码来源:MapHeightmap.cs

示例6: Test_GetValue

 public void Test_GetValue()
 {
   using (MagickImage image = new MagickImage(Color.Red, 5, 10))
   {
     using (WritablePixelCollection pixels = image.GetWritablePixels())
     {
       Test_PixelColor(pixels, Color.Red);
     }
   }
 }
开发者ID:levesque,项目名称:Magick.NET,代码行数:10,代码来源:WritablePixelCollectionTests.cs

示例7: Test_Dimensions

 public void Test_Dimensions()
 {
   using (MagickImage image = new MagickImage(Color.Red, 5, 10))
   {
     using (WritablePixelCollection pixels = image.GetWritablePixels())
     {
       Assert.AreEqual(5, pixels.Width);
       Assert.AreEqual(10, pixels.Height);
       Assert.AreEqual(3, pixels.Channels);
       Assert.AreEqual(5 * 10 * pixels.Channels, pixels.GetValues().Length);
     }
   }
 }
开发者ID:levesque,项目名称:Magick.NET,代码行数:13,代码来源:WritablePixelCollectionTests.cs

示例8: Test_Write

    public void Test_Write()
    {
      using (MagickImage image = new MagickImage(Color.Red, 10, 1))
      {
        using (WritablePixelCollection pixels = image.GetWritablePixels())
        {
          byte[] bytes = new byte[10 * pixels.Channels];
          for (int i = 0; i < bytes.Length; i++)
            bytes[i] = 0;

          pixels.Set(bytes);
          pixels.Write();
        }

        TestPixels(image, new MagickColor(0, 0, 0));

        using (WritablePixelCollection pixels = image.GetWritablePixels())
        {
          foreach (Pixel pixel in pixels)
          {
            pixel.SetChannel(2, Quantum.Max);
          }

          pixels.Write();
        }

        TestPixels(image, Color.Blue);
      }
    }
开发者ID:levesque,项目名称:Magick.NET,代码行数:29,代码来源:WritablePixelCollectionTests.cs

示例9: Test_Set

    public void Test_Set()
    {
      using (MagickImage image = new MagickImage(Color.Red, 5, 10))
      {
        using (WritablePixelCollection pixels = image.GetWritablePixels())
        {
          ExceptionAssert.Throws<ArgumentNullException>(delegate ()
          {
            pixels.Set((QuantumType[])null);
          });

          ExceptionAssert.Throws<ArgumentNullException>(delegate ()
          {
            pixels.Set((Pixel)null);
          });

          ExceptionAssert.Throws<ArgumentNullException>(delegate ()
          {
            pixels.Set((Pixel[])null);
          });

          Assert.AreEqual(3, pixels.Channels);
          Test_Set(pixels, new QuantumType[] { });
          Test_Set(pixels, new QuantumType[] { 0 });
          Test_Set(pixels, new QuantumType[] { 0, 0 });

          pixels.Set(new QuantumType[] { 0, 0, 0 });
          Test_PixelColor(pixels, Color.Black);
          pixels.Write();
        }

        using (PixelCollection pixels = image.GetReadOnlyPixels())
        {
          Test_PixelColor(pixels, Color.Black);
        }

        using (WritablePixelCollection pixels = image.GetWritablePixels())
        {
          pixels.Set(new uint[] { 4294967295, 0, 0 });
          Test_PixelColor(pixels, Color.Red);
          pixels.Set(new ushort[] { 0, 0, 65535 });
          Test_PixelColor(pixels, Color.Blue);
          pixels.Set(new byte[] { 0, 255, 0 });
          Test_PixelColor(pixels, Color.Lime);
        }

        using (WritablePixelCollection pixels = image.GetWritablePixels())
        {
          for (int x = 0; x < pixels.Width; x++)
          {
            for (int y = 0; y < pixels.Height; y++)
            {
              pixels.Set(x, y, new QuantumType[] { 0, 0, 0 });
            }
          }
        }
      }
    }
开发者ID:levesque,项目名称:Magick.NET,代码行数:58,代码来源:WritablePixelCollectionTests.cs

示例10: PointGenerator

        public static NewImagePart PointGenerator(string UserName, byte[] ImagePart, int _x, int _y, int width, int height, int PxFormat)
        {
            try
            {
                Rectangle recti = new Rectangle(_x, _y, width, height);
                PixFormat _pixFor = (PixFormat)StringToEnum(typeof(PixFormat), Convert.ToString("_" + PxFormat.ToString() + "x" + PxFormat.ToString()));
                qprPath resources = new qprPath(UserName);
                if (_pixFor == PixFormat._null)
                    throw new Exception("Format null olamaz") { Source = "" };

                //GC.Collect();
                //Bitmap bmp;
                //using (var ms = new MemoryStream(ImagePart))
                //{
                //    bmp = new Bitmap(ms);
                //}

                using (MagickImage imagem = new MagickImage(ImagePart))
                {
                    imagem.Quality = 100;
                    imagem.Blur(5, 5);

                    List<ImgSquare> sp0 = new List<ImgSquare>();
                    if (true)
                    {
                        int[,] pixavg = new int[5, 3];
                        int _pixformat = (int)_pixFor;
                        WritablePixelCollection _totalpix = imagem.GetWritablePixels(0, 0, imagem.Width, imagem.Height);
                        int range = _pixformat / 2;
                        for (int w = 0; w < imagem.Width; w += _pixformat)
                        {
                            for (int h = 0; h < imagem.Height; h += _pixformat)
                            {
                                if (!(w + _pixformat <= imagem.Width && h + _pixformat <= imagem.Height))
                                    continue;//olmazda olursa diye
                                pixavg = new int[5, 3];
                                for (int x = 0; x < range; x++)
                                {
                                    for (int y = 0; y < range; y++)
                                    {
                                        Color a = _totalpix.GetPixel(x + w + 0, h + 0 + y).ToColor().ToColor();
                                        pixavg[0, 0] += a.R;
                                        pixavg[0, 1] += a.G;
                                        pixavg[0, 2] += a.B;

                                        Color b = _totalpix.GetPixel(x + w + range, h + y).ToColor().ToColor();
                                        pixavg[1, 0] += b.R;
                                        pixavg[1, 1] += b.G;
                                        pixavg[1, 2] += b.B;

                                        Color c = _totalpix.GetPixel(x + w, h + range + y).ToColor().ToColor();
                                        pixavg[2, 0] += c.R;
                                        pixavg[2, 1] += c.G;
                                        pixavg[2, 2] += c.B;

                                        Color d = _totalpix.GetPixel(x + w + range, h + range + y).ToColor().ToColor();
                                        pixavg[3, 0] += d.R;
                                        pixavg[3, 1] += d.G;
                                        pixavg[3, 2] += d.B;
                                    }
                                }

                                //tümü için aynı toplanıyor
                                pixavg[4, 0] = pixavg[0, 0] + pixavg[1, 0] + pixavg[2, 0] + pixavg[3, 0];
                                pixavg[4, 1] = pixavg[0, 1] + pixavg[1, 1] + pixavg[2, 1] + pixavg[3, 1];
                                pixavg[4, 2] = pixavg[0, 2] + pixavg[1, 2] + pixavg[2, 2] + pixavg[3, 2];
                                //----

                                int totalminiPix = (range * range);
                                pixavg[0, 0] /= totalminiPix;
                                pixavg[0, 1] /= totalminiPix;
                                pixavg[0, 2] /= totalminiPix;

                                pixavg[1, 0] /= totalminiPix;
                                pixavg[1, 1] /= totalminiPix;
                                pixavg[1, 2] /= totalminiPix;

                                pixavg[2, 0] /= totalminiPix;
                                pixavg[2, 1] /= totalminiPix;
                                pixavg[2, 2] /= totalminiPix;

                                pixavg[3, 0] /= totalminiPix;
                                pixavg[3, 1] /= totalminiPix;
                                pixavg[3, 2] /= totalminiPix;

                                int totalPix = totalminiPix * 4;
                                pixavg[4, 0] /= totalPix;
                                pixavg[4, 1] /= totalPix;
                                pixavg[4, 2] /= totalPix;

                                sp0.Add(new ImgSquare(w, h, new List<QuardPixAvg>()
                            {
                                new QuardPixAvg(Color.FromArgb((pixavg[0, 0]), (pixavg[0, 1]), (pixavg[0, 2])), QuardBolum.SolUst),
                                new QuardPixAvg (Color.FromArgb((pixavg[1, 0]), (pixavg[1, 1]), (pixavg[1, 2])), QuardBolum.SagUst),
                                new QuardPixAvg(Color.FromArgb((pixavg[2, 0]), (pixavg[2, 1]), (pixavg[2, 2])), QuardBolum.SolAlt),
                                new QuardPixAvg(Color.FromArgb((pixavg[3, 0]), (pixavg[3, 1]), (pixavg[3, 2])), QuardBolum.SagAlt),
                                new QuardPixAvg(Color.FromArgb((pixavg[4, 0]), (pixavg[4, 1]), (pixavg[4, 2])), QuardBolum.TotalAvg)
                            }));
                            }
                        }
//.........这里部分代码省略.........
开发者ID:msx752,项目名称:OPALOP-Picture-Mosaic,代码行数:101,代码来源:ImageProperty.cs


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