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


C# BitmapSource.GetAsFrozen方法代码示例

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


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

示例1: Visualize


//.........这里部分代码省略.........
          iLength = iWidth * iHeight;
          stride = iWidth * bpp;
          result = this.result;
          isAlive = this.isAlive;
          isDone = this.isDone;
          palette = this.palette;
          liveClr = this.liveClr;
          palType = this.paletteType;
          palOffs = this.offs;
          palScale = this.scale;

          doRepop = this.byteLen != byteLen;
          byteLen = this.byteLen;
        }

        if (bWidth == 0 || bHeight == 0) continue;

        if (doRepop)
          bytes = new byte[byteLen];


        offs = isDone ? palOffs : 0;
        isPalRel = palType == VisPaletteType.Relative || !isDone;

        if (isPalRel) {
          min = double.MaxValue;
          max = double.MinValue;

          for (i = 1; i < bLength; i++) {
            if (!isAlive[i]) {
              min = Math.Min(min, result[i]);
              max = Math.Max(max, result[i]);
            }
          }

          Console.WriteLine($"[Visualizer] Current minimum: {min}; current maximum: {max}.");

          offs -= min;
          scale = (isDone ? palScale * (palette.Length - 1) : 1) / (max - min);
        }
        else scale = (palType == VisPaletteType.CyclicSingle ? 1 : palette.Length) / palScale;

        if (isDone) {
          for (int row = 0; row < iHeight; row++) {
            for (int col = 0; col < iWidth; col++) {
              i = (col + row * bWidth) * spls;
              j = (col + row * iWidth) * bpp;

              currClr = new FloatColor(0, 0, 0, 0);

              for (int sRow = 0; sRow < spls; sRow++) {
                for (int sCol = 0; sCol < spls; sCol++) {
                  spl = i + sCol + sRow * bWidth;

                  currClr += isAlive[spl] ? liveClr : isPalRel ? GetColor(palette, liveClr, (result[spl] + offs) * scale) : GetColor(palette, liveClr, Math.Log(result[spl] + 1) * scale);
                }
              }

              currClr /= splCount;

              bytes[j] = (byte)(currClr.B * 255);
              bytes[j + 1] = (byte)(currClr.G * 255);
              bytes[j + 2] = (byte)(currClr.R * 255);
              bytes[j + 3] = (byte)(currClr.A * 255);
            }
          }
        }
        else {
          for (int row = 0; row < iHeight; row++) {
            for (int col = 0; col < iWidth; col++) {
              i = (col + row * bWidth) * spls;
              j = (col + row * iWidth) * bpp;

              currSpl = 0;

              for (int sRow = 0; sRow < spls; sRow++) {
                for (int sCol = 0; sCol < spls; sCol++) {
                  spl = i + sCol + sRow * bWidth;

                  currSpl += isAlive[spl] ? 0 : (float)((result[spl] + offs) * scale);
                }
              }

              currSpl /= splCount;

              bytes[j] =
                bytes[j + 1] =
                bytes[j + 2] = (byte)(Math.Max(0, Math.Min(1, currSpl)) * 255);
              bytes[j + 3] = (byte)255;
            }
          }
        }

        src = BitmapSource.Create(iWidth, iHeight, dpiX, dpiY, PixelFormats.Bgra32, null, bytes, stride);

        Source = src.GetAsFrozen() as BitmapSource;

        visualized?.Invoke(this);
      }
    }
开发者ID:rookie1024,项目名称:JuliaSet,代码行数:101,代码来源:Visualizer.cs


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