C#與vb.net源碼代碼互轉網站


該轉換器是印度開發團隊推出的,推出時間也挺長,僅支持C#和VB.net代碼轉換。
代碼轉換地址: C# -> VB.NET  http://www.dotnetspider.com/convert/Csharp-To-Vb.aspx
                          VB.NET -> C#  http://www.dotnetspider.com/convert/Vb-To-Csharp.aspx
 

 

1,http://converter.telerik.com

網站很不錯  轉成c#源碼不錯

''' <summary>
''' 提取像素法 簡單的方法 上面的是好的 不過分析圖片時用很好用
''' </summary>
''' <param name="srcBitmap"></param>
''' <returns></returns>
Public Shared Function RGB2Gray1(ByVal srcBitmap As Bitmap) As Bitmap
Dim srcColor As Color
Dim wide As Integer = srcBitmap.Width
Dim height As Integer = srcBitmap.Height

For y As Integer = 0 To height - 1

For x As Integer = 0 To wide - 1
'獲取像素的RGB顏色值

srcColor = srcBitmap.GetPixel(x, y)
Dim temp As Byte = CByte((srcColor.R * 0.299 + srcColor.G * 0.587 + srcColor.B * 0.114))

' //設置像素的RGB顏色值
srcBitmap.SetPixel(x, y, Color.FromArgb(temp, temp, temp))
Next
Next

Return srcBitmap
End Function

 

轉換后

/// <summary>

/// ''' 提取像素法 簡單的方法 上面的是好的 不過分析圖片時用很好用

/// ''' </summary>

/// ''' <param name="srcBitmap"></param>

/// ''' <returns></returns>
public static Bitmap RGB2Gray1(Bitmap srcBitmap)
{
Color srcColor;
int wide = srcBitmap.Width;
int height = srcBitmap.Height;

for (int y = 0; y <= height - 1; y++)
{
for (int x = 0; x <= wide - 1; x++)
{
// 獲取像素的RGB顏色值

srcColor = srcBitmap.GetPixel(x, y);
byte temp = System.Convert.ToByte((srcColor.R * 0.299 + srcColor.G * 0.587 + srcColor.B * 0.114));

// //設置像素的RGB顏色值
srcBitmap.SetPixel(x, y, Color.FromArgb(temp, temp, temp));
}
}

return srcBitmap;
}

 

2,http://www.carlosag.net/Tools/CodeTranslator/

這個是強制轉換 代碼

 

 

''' <summary>
''' 提取像素法 簡單的方法 上面的是好的 不過分析圖片時用很好用
''' </summary>
''' <param name="srcBitmap"></param>
''' <returns></returns>
Public Shared Function RGB2Gray1(ByVal srcBitmap As Bitmap) As Bitmap
Dim srcColor As Color
Dim wide As Integer = srcBitmap.Width
Dim height As Integer = srcBitmap.Height

For y As Integer = 0 To height - 1

For x As Integer = 0 To wide - 1
'獲取像素的RGB顏色值

srcColor = srcBitmap.GetPixel(x, y)
Dim temp As Byte = CByte((srcColor.R * 0.299 + srcColor.G * 0.587 + srcColor.B * 0.114))

' //設置像素的RGB顏色值
srcBitmap.SetPixel(x, y, Color.FromArgb(temp, temp, temp))
Next
Next

Return srcBitmap
End Function

轉換后不支持 中文 

 

 

Unknown(
    
    
static Bitmap RGB2Gray1(Bitmap srcBitmap) {
        Color srcColor
;
        int 
wide srcBitmap.Width;
        int 
height srcBitmap.Height;
        for 
(int 0(y 
                    <
(height - 1))y++) {
            
for (int 0(x 
                        <
(wide - 1))x++) {
                
// ��� �2'"�r<
                
srcColor srcBitmap.GetPixel(x, y);
                byte 
temp = byte.Parse(((srcColor.R * 0.299
                                + ((srcColor.G * 
0.587
                                + (srcColor.B * 
0.114))));
                
srcBitmap.SetPixel(x, y, Color.FromArgb(temp, temp, temp));
            
}
            
        }
        
        
return srcBitmap;
    
}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM