从Java到C#的BufferedImage等效 [英] Equivalent of BufferedImage from Java to C#
本文介绍了从Java到C#的BufferedImage等效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将Java程序转换为C#,但我不知道BufferedImage从Java到C#的等效功能...
来自Java的代码:
I am trying to convert a Java program to C# and I don''t know the equivalent of BufferedImage from Java to C#...
Code from Java:
public static String ActiveContour(int x11, int x22, int y11, int y22, BufferedImage bufIm, int contor)
{
double [][] img=new double[bufIm.getHeight()][bufIm.getWidth()];
double [][] imgf=new double[bufIm.getHeight()][bufIm.getWidth()];
w=bufIm.getWidth();
h=bufIm.getHeight();
for(int i=0;i<h;i++)
for(int j=0;j<w;j++)
{
img[i][j]=bufIm.getRGB(j, i);
c = new Color((int)img[i][j]);
img[i][j]= 0.2898*c.getRed() + 0.5870*c.getGreen() + 0.1140*c.getBlue();
}
我想念一条声明吗?
Am I missing a statement?
using System...;
因为在Java中,我有
because in Java I have
import java.awt.image.BufferedImage;
推荐答案
您已经在这里得到答案: ^ ].
您可以使用System.Drawing中的Bitmap类.为此,尽管我认为您必须在工程中添加对System.Drawing的引用.通过解决方案资源管理器添加参考.在代码中,您可以添加using语句,这样就不必完全限定类型:
使用System.Drawing;
...
...
位图bm = ....
一旦可行,您就必须更改访问位图字节的代码.
最好的问候,
曼弗雷德(Manfred)
You already got your answer here: http://stackoverflow.com/questions/4776939/equivalent-of-bufferedimage-from-java-to-c[^].
You can use the Bitmap class from System.Drawing. For that to work though I think you''ll have to add a reference to System.Drawing to your project. Adding a reference is done via solution explorer. In your code you can add a using statement so you don''t have to fully qualify the type:
using System.Drawing;
...
...
Bitmap bm = ....
As soon as this works you''ll have to change the code that accesses the Bitmaps bytes.
Best Regards,
Manfred
这篇关于从Java到C#的BufferedImage等效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文