当前位置: 移动技术网 > IT编程>开发语言>.net > C#与vb.net源码代码互转网站

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

2019年10月16日  | 移动技术网IT编程  | 我要评论

趁春浓为我展欢颜,柳传志演讲视频,艳星公司

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

 

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网