Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Equivalent of BufferedImage from Java to C#

Tags:

java

syntax

c#

.net

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...;

because in Java I have

import java.awt.image.BufferedImage;
like image 937
Bosco Avatar asked Jan 23 '11 22:01

Bosco


2 Answers

System.Drawing.Bitmap is the closest I can think of.

like image 133
gbvb Avatar answered Sep 25 '22 16:09

gbvb


What does this function do? Why bother with translating the code bit by bit when most probably there is another way achieving the same result using C# classes? In C# using System.Drawing.Bitmap is common practice but there are other ways depending on what the code is meant to be doing.

like image 25
jimjim Avatar answered Sep 24 '22 16:09

jimjim