Click here to Skip to main content
15,903,385 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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;
Posted
Comments
Manfred Rudolf Bihy 7-Feb-11 7:39am    
Whats new? I didn't see any response to my answer from you so I thought I dropped by to ask you how you are getting along.
bosco_boom 7-Feb-11 8:25am    
On "stackoverflow" I got the answer I needed...I managed to convert the code from Java to C#, and now it's working...thank you for your help

1 solution

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
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900