ccc125l87l92l206cad32
fy53999
飞快的心情fy53999

该转换器是印度开发团队推出的,推出时间也挺长,仅支持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;
    
}

 

posted on 2019-10-16 09:09  fy53999  阅读(1321)  评论(2编辑  收藏  举报