从Java到C#的BufferedImage等效 [英] Equivalent of BufferedImage from Java to C#

查看:321
本文介绍了从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;

推荐答案

您已经在这里得到答案:
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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆