2013-07-14 42 views
-3

請什麼是VB.net相當於下面的C#代碼:是否有VB.net相當於下面的C#代碼的

internal static unsafe void DistortedDraw(byte* sourceBuffer, Bitmap displacementMap, Bitmap destBitmap) { 
     int sourceWidth = destBitmap.Width, sourceHeight = destBitmap.Height; 
     BitmapData previewData = destBitmap.LockBits(new Rectangle(0, 0, sourceWidth, sourceHeight), ImageLockMode.WriteOnly, destBitmap.PixelFormat); 
     int sourceDataStride = previewData.Stride; 
     int sourceBPP = destBitmap.PixelFormat.ToString().Contains("16") ? 2 : destBitmap.PixelFormat.ToString().Contains("24") ? 3 : destBitmap.PixelFormat.ToString().Contains("32") ? 4 : 0; 

     if (displacementMap == null) { 
      unsafe { 
       byte* previewScan0 = (byte*)previewData.Scan0; 
       byte* sourceScan0 = (byte*)sourceBuffer; 
       for (int y = 0, yofs = 0, invyofs = (sourceHeight - 1 - y) * sourceDataStride; y < sourceHeight; y++, yofs += sourceDataStride, invyofs -= sourceDataStride) { 
        for (int x = 0; x < sourceDataStride; x += 4) { 
         *(int*)(previewScan0 + yofs + x) = *(int*)(sourceScan0 + invyofs + x); 
        } 
       } 
      } 
     } 
     destBitmap.UnlockBits(previewData); 
    } 

感謝。

+4

VB.Net不支持指針。 – SLaks

+4

我真的不明白downvotes。 – Sebastian

+0

@Sebastian謝謝你 –

回答

3

在Visual Basic中沒有直接的等價物。根本問題是VB.NET不支持不安全的關鍵字或指針。

您可以做的最好的檢查是什麼方法並找到一種方法來替換指針變量與其他100%託管構造。

+0

我編輯了這個問題,以包含完整的c#函數。 –