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


C# FastBitmap.Dispose方法代码示例

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


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

示例1: CreateShadowedImage

    /// <summary>
    /// Creates a new image of the specified size from the source image
    /// </summary>
    /// <param name="src">Source image path</param>
    /// <param name="dest">Destination image path</param>
    /// <param name="imgCfg">The configuration of the image</param>
    /// <param name="forceUpdate">Update in every case</param>
    /// <param name="jpegQuality">The Quality for the JPEG File 0..100</param>
    public void CreateShadowedImage(string src, string dest, ImageBrowserConfig.ImageCfg imgCfg, bool forceUpdate, byte jpegQuality)
    {
      try
      {
        if (!forceUpdate && File.Exists(cfg.PictureRootDirectory + "/" + dest) ) 
          return;

        string path = Directory.GetParent(cfg.PictureRootDirectory + "/" + dest).FullName;

        if ( ! Directory.Exists(path)) 
          Directory.CreateDirectory(path);

        // Values for building Shadow.
        Int32 shadowwidth = imgCfg.ShadowWidth;
        Int32 borderwidth = imgCfg.BorderWidth;
        Int32 margin = shadowwidth / 2;
        Int32 shadowdir = 0;
        Double shadowtrans = imgCfg.ShadowTransparency;
        Color bkcolor = Color.FromArgb(imgCfg.BackgroundColor);
        Color shadowcolor = Color.FromArgb(imgCfg.ShadowColor);
        Color bordercolor = Color.FromArgb(imgCfg.BorderColor);
        Boolean softshadow = imgCfg.SoftShadow;

        Image thumb = CreateImageInternal(src, imgCfg.MaxSize);
        if(thumb != null)
        {
          FastBitmap tmp = new FastBitmap(thumb);

          FastBitmap bmp = new FastBitmap(tmp.Width + borderwidth * 2, tmp.Height + borderwidth * 2,
            PixelFormat.Format32bppArgb);

          // add border if necessary
          if (borderwidth > 0) 
          {
            using(SolidBrush br = new SolidBrush(bordercolor))
            using (Graphics g = Graphics.FromImage(bmp._bitmap))
            {
              g.FillRectangle(br, 0, 0, borderwidth * 2 + tmp.Width, borderwidth * 2 + tmp.Height);
            }
          }

          tmp.CopyTo(bmp, borderwidth, borderwidth, 0, 0, tmp.Width, tmp.Height);
          tmp.Dispose();

          // create image

          Int32 width = bmp.Width + shadowwidth + margin * 2;
          Int32 height = bmp.Height + shadowwidth + margin * 2;
          LayeredImage image = new LayeredImage(width, height);

          Int32 shadowx = 0, shadowy = 0, imgx = 0, imgy = 0;

          if (softshadow) 
          {
            switch (shadowdir) 
            {
              case 0:
                shadowx = margin - shadowwidth / 2;
                shadowy = margin - shadowwidth / 2;
                imgx = margin;
                imgy = margin;
                break;
              case 1:
                shadowx = margin + shadowwidth - 3 * (shadowwidth / 2);
                shadowy = margin - shadowwidth / 2;
                imgx = margin + shadowwidth;
                imgy = margin;
                break;
              case 2:
                shadowx = margin + shadowwidth - 3 * (shadowwidth / 2);
                shadowy = margin + shadowwidth - 3 * (shadowwidth / 2);
                imgx = margin + shadowwidth;
                imgy = margin + shadowwidth;
                break;
              case 3:
                shadowx = margin - shadowwidth / 2;
                shadowy = margin + shadowwidth - 3 * (shadowwidth / 2);
                imgx = margin;
                imgy = margin + shadowwidth;
                break;
            }
          } 
          else 
          {
            switch (shadowdir) 
            {
              case 0:
                shadowx = margin;
                shadowy = margin;
                imgx = margin;
                imgy = margin;
                break;
//.........这里部分代码省略.........
开发者ID:dineshkummarc,项目名称:Portal-V2.8.1,代码行数:101,代码来源:ImageTools.cs

示例2: MakeDistortionGrid

        private void MakeDistortionGrid()
        {
            Bitmap bmpBlend = new Bitmap(config.BlendFile);
            FastBitmap fastBlend = new FastBitmap(bmpBlend);
            Bitmap bmpDistort = new Bitmap(config.DistortionGrid);
            FastBitmap fastDistort = new FastBitmap(bmpDistort);


            fastBlend.LockBitmapRgb();
            fastDistort.LockBitmapRgb();
            int subX = bmpBlend.Width - 1;
            int subY = subX;

            if (distortIndexBuffer != null)
            {
                distortIndexBuffer.Dispose();
                GC.SuppressFinalize(distortIndexBuffer);
            }

            if (distortVertexBuffer != null)
            {
                distortVertexBuffer.Dispose();
                GC.SuppressFinalize(distortVertexBuffer);
            }


            distortIndexBuffer = new IndexBuffer11(typeof(int), (subX * subY * 6), RenderContext11.PrepDevice);
            distortVertexBuffer = new PositionColorTexturedVertexBuffer11(((subX + 1) * (subY + 1)), RenderContext11.PrepDevice);

            distortVertexCount = (subX + 1) * (subY + 1);


            int index = 0;


            // Create a vertex buffer 
            PositionColoredTextured[] verts = (PositionColoredTextured[])distortVertexBuffer.Lock(0, 0); // Lock the buffer (which will return our structs)
            int x1, y1;

            unsafe
            {
                double maxU = 0;
                double maxV = 0;
                double textureStepX = 1.0f / subX;
                double textureStepY = 1.0f / subY;
                for (y1 = 0; y1 <= subY; y1++)
                {
                    double tv;
                    for (x1 = 0; x1 <= subX; x1++)
                    {
                        double tu;


                        index = y1 * (subX + 1) + x1;
                        PixelDataRgb* pdata = fastDistort.GetRgbPixel(x1, y1);

                        tu = (float)(pdata->blue + ((uint)pdata->red % 16) * 256) / 4095f;
                        tv = (float)(pdata->green + ((uint)pdata->red / 16) * 256) / 4095f;

                        //tu = (tu - .5f) * 1.7777778 + .5f;

                        if (tu > maxU)
                        {
                            maxU = tu;
                        }
                        if (tv > maxV)
                        {
                            maxV = tv;
                        }

                        verts[index].Position = new SharpDX.Vector4(((float)x1 / subX) - .5f, (1f - ((float)y1 / subY)) - .5f, .9f, 1f);
                        verts[index].Tu = (float)tu;
                        verts[index].Tv = (float)tv;
                        PixelDataRgb* pPixel = fastBlend.GetRgbPixel(x1, y1);

                        verts[index].Color = Color.FromArgb(255, pPixel->red, pPixel->green, pPixel->blue);

                    }
                }
                distortVertexBuffer.Unlock();
                distortTriangleCount = (subX) * (subY) * 2;
                uint[] indexArray = (uint[])distortIndexBuffer.Lock();
                index = 0;
                for (y1 = 0; y1 < subY; y1++)
                {
                    for (x1 = 0; x1 < subX; x1++)
                    {
                        // First triangle in quad
                        indexArray[index] = (uint)(y1 * (subX + 1) + x1);
                        indexArray[index + 1] = (uint)((y1 + 1) * (subX + 1) + x1);
                        indexArray[index + 2] = (uint)(y1 * (subX + 1) + (x1 + 1));

                        // Second triangle in quad
                        indexArray[index + 3] = (uint)(y1 * (subX + 1) + (x1 + 1));
                        indexArray[index + 4] = (uint)((y1 + 1) * (subX + 1) + x1);
                        indexArray[index + 5] = (uint)((y1 + 1) * (subX + 1) + (x1 + 1));
                        index += 6;
                    }
                }
                this.distortIndexBuffer.Unlock();
//.........这里部分代码省略.........
开发者ID:keenedge,项目名称:wwt-windows-client,代码行数:101,代码来源:3dWIndow.cs


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