Click here to Skip to main content
15,901,284 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
kindly tell me its solution. i stuck to it.
Posted
Comments
Did you try something and got stuck?
mishal khan 23-May-14 2:32am    
Yes i tried. i am working on visual stdio. i did something like

Bitmap myBitmap = new Bitmap(FILE_NAME);
int n = myBitmap.Height;
int m = myBitmap.Width;
int[, ,] arrayImg = new int[n, m, 3];
for (int x = 0; x < myBitmap.Width; x++)
{
for (int y = 0; y < myBitmap.Height; y++)
{
Color pixelColor = myBitmap.GetPixel(x, y);
r = pixelColor.R;
g = pixelColor.G;
b = pixelColor.B;

arrayImg[x, y, 0] = r;
arrayImg[x, y, 1] = g;
arrayImg[x, y, 2] = b;

}
}

but the problem is, it is giving error on myBitmap and pixelColor. i have made the application in console application and i have also added the reference to system.drawing.dll.

1 solution

You need to be more specific. As you had actually tried something, why not paste the code at first. Even now it would help a lot if you told us what the error was and on what line it occurred. Give us some help here!

One thing I can see is your multidimensional array has m and n the wrong way round, which will likely lead to an out of range index. Is that what you're getting?
 
Share this answer
 
Comments
mishal khan 23-May-14 5:45am    
yeah i should be specified. =) u r right that my array has m and n the wrong way round but i have figured out this problem already. now the issue is when i do it all in windows form on stdio it runs correctly but in case , when i do it all in console application on stdio it gives error on bitmap and pixelcolor though i have added system.drawing.dll already. whats the way to use this bitmap class in console app on stdio ?

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