欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

C#与vb.net源码代码互转网站

程序员文章站 2022-06-07 10:59:16
该转换器是印度开发团队推出的,推出时间也挺长,仅支持C#和VB.net代码转换。代码转换地址: C# -> VB.NET http://www.dotnetspider.com/convert/Csharp-To-Vb.aspx VB.NET -> C# http://www.dotnetspide ......

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