當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。