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


C# BitmapData.GetPointer方法代码示例

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


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

示例1: New

 public static Bitmap New(BitmapData data_bmp)
 {
     Bitmap ans; New(out ans,data_bmp.Width, data_bmp.Height);
     BitmapData data_ans = ans.GetBitmapData();
     byte* ptr_bmp = data_bmp.GetPointer();
     byte* ptr_ans = data_ans.GetPointer();
     Parallel.For(0, data_ans.Height, h =>
     {
         int i = data_ans.Stride * h;
         for (int w = 0; w < data_ans.Width; w++)
         {
             ptr_ans[i] = ptr_bmp[i]; i++;
             ptr_ans[i] = ptr_bmp[i]; i++;
             ptr_ans[i] = ptr_bmp[i]; i++;
             ptr_ans[i] = ptr_bmp[i]; i++;
         }
     });
     ans.UnlockBits(data_ans);
     return ans;
 }
开发者ID:fsps60312,项目名称:Digging-Game-2,代码行数:20,代码来源:BITMAP.cs

示例2: DrawOpaque

 public static void DrawOpaque(this BitmapData data_bac,BitmapData data_bmp)
 {
     if(data_bac.Width!=data_bmp.Width||data_bac.Height!=data_bmp.Height)
     {
         throw new ArgumentException("Both Size must be same");
     }
     byte* ptr_bac = data_bac.GetPointer();
     byte* ptr_bmp = data_bmp.GetPointer();
     Parallel.For(0, data_bac.Height, h =>
     {
         int i1 = h * data_bac.Stride;
         int i2 = h * data_bmp.Stride;
         for (int w = 0; w < data_bac.Width; w++)
         {
             if (ptr_bac[i1 + 3] == 0)
             {
                 i1 += 4;
                 i2 += 4;
             }
             else if (ptr_bac[i1 + 3] == 255)
             {
                 ptr_bac[i1++] = ptr_bmp[i2++];
                 ptr_bac[i1++] = ptr_bmp[i2++];
                 ptr_bac[i1++] = ptr_bmp[i2++];
                 ptr_bac[i1++] = ptr_bmp[i2++];
             }
             else throw new ArgumentException("Alpha value must be 0 or 255");
         }
     });
 }
开发者ID:fsps60312,项目名称:Digging-Game-2,代码行数:30,代码来源:BITMAP.cs

示例3: Paste_Transparent

 static void Paste_Transparent(this BitmapData data_bac, BitmapData data_bmp, Point p, Rectangle region = default(Rectangle))
 {
     if (region == default(Rectangle)) region = new Rectangle(0, 0, data_bac.Width, data_bac.Height);
     byte* ptr_bac = data_bac.GetPointer();
     byte* ptr_bmp = data_bmp.GetPointer();
     int w1 = Math.Max(Math.Max(-p.X, 0), region.X - p.X);
     int w2 = Math.Min(Math.Min(data_bmp.Width, data_bac.Width - p.X), region.X + region.Width - p.X);
     int h1 = Math.Max(Math.Max(-p.Y, 0), region.Y - p.Y);
     int h2 = Math.Min(Math.Min(data_bmp.Height, data_bac.Height - p.Y), region.Y + region.Height - p.Y);
     if (w1 >= w2 || h1 >= h2) return;
     ptr_bac += p.Y * data_bac.Stride + 4 * (w1 + p.X);
     ptr_bmp += 4 * w1;
     Parallel.For(h1, h2, h =>
     {
         int i1 = data_bac.Stride * h;
         int i2 = data_bmp.Stride * h;
         for (int w = w1; w < w2; w++)
         {
             if (ptr_bmp[i2 + 3] == 255)
             {
                 ptr_bac[i1++] = ptr_bmp[i2++];
                 ptr_bac[i1++] = ptr_bmp[i2++];
                 ptr_bac[i1++] = ptr_bmp[i2++];
                 ptr_bac[i1++] = ptr_bmp[i2++];
             }
             else if (ptr_bmp[i2 + 3] == 0) { i1 += 4; i2 += 4; }
             else
             {
                 Bitmap bmp = BITMAP.New(data_bmp);
                 bmp.Save("ErrorImage", ImageFormat.Png);
                 BitmapBox.Show(bmp);
                 throw new ArgumentException("Alpha Value must be 0 or 255: " + ptr_bmp[i2 + 3].ToString() + "(" + w.ToString() + "," + h.ToString() + ")");
             }
         }
     });
 }
开发者ID:fsps60312,项目名称:Digging-Game-2,代码行数:36,代码来源:BITMAP.cs

示例4: Paste_Gradient

 static void Paste_Gradient(this BitmapData data_bac, BitmapData data_bmp, Point p, Rectangle region = default(Rectangle))
 {
     if (region == default(Rectangle)) region = new Rectangle(0, 0, data_bac.Width, data_bac.Height);
     byte* ptr_bac = data_bac.GetPointer();
     byte* ptr_bmp = data_bmp.GetPointer();
     int w1 = Math.Max(Math.Max(-p.X, 0), region.X - p.X);
     int w2 = Math.Min(Math.Min(data_bmp.Width, data_bac.Width - p.X), region.X + region.Width - p.X);
     int h1 = Math.Max(Math.Max(-p.Y, 0), region.Y - p.Y);
     int h2 = Math.Min(Math.Min(data_bmp.Height, data_bac.Height - p.Y), region.Y + region.Height - p.Y);
     if (w1 >= w2 || h1 >= h2) return;
     ptr_bac += p.Y * data_bac.Stride + 4 * (w1 + p.X);
     ptr_bmp += 4 * w1;
     Parallel.For(h1, h2, h =>
     {
         int i1 = data_bac.Stride * h;
         int i2 = data_bmp.Stride * h;
         int b;
         for (int w = w1; w < w2; w++, i1++, i2++)
         {
             b = ptr_bmp[i2 + 3];
             ptr_bac[i1] = b.Approach_Byte(ptr_bac[i1], ptr_bmp[i2]); i1++; i2++;
             ptr_bac[i1] = b.Approach_Byte(ptr_bac[i1], ptr_bmp[i2]); i1++; i2++;
             ptr_bac[i1] = b.Approach_Byte(ptr_bac[i1], ptr_bmp[i2]); i1++; i2++;
         }
     });
 }
开发者ID:fsps60312,项目名称:Digging-Game-2,代码行数:26,代码来源:BITMAP.cs

示例5: DrawBackgroundImage

 unsafe static void DrawBackgroundImage(BitmapData data_bac)
 {
     byte* ptr_bac = data_bac.GetPointer();
     Parallel.For(0, data_bac.Height, h =>
     {
         int i = h * data_bac.Stride;
         Color c = GetColorByScreenY(h);
         for (int w = 0; w < data_bac.Width; w++)
         {
             ptr_bac[i++] = c.B;
             ptr_bac[i++] = c.G;
             ptr_bac[i++] = c.R;
             ptr_bac[i++] = c.A;
         }
     });
     foreach (var a in UNDER)
     {
         a.DrawImage(data_bac);
     }
     Sky.DrawImage(data_bac);
 }
开发者ID:fsps60312,项目名称:Digging-Game-2,代码行数:21,代码来源:Background.cs


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