kkirtac
May 27th, 2006, 06:45 AM
here is the code snippet :
#define INDEX(W, R, C) ((R)*(W)+(C)) //defined in Tools.h
//starts Form1.h
.....
......
......
static int arrayVal ;
static int* img; //the 1D array
static Bitmap* source; // source image
Bitmap* gray; // gray image
...
...
...
public: System::Void openFileDialog1_FileOk(System::Object * sender, System::ComponentModel::CancelEventArgs * e) {
source = new Bitmap(Image::FromFile(openFileDialog1->FileName));
gray = ConvertToGrayscale( source ) ; // ConvertToGrayScale is defined in
//Tools.h
img = (int*) new int[(gray->Width)*(gray->Height)] ;
for(int row=0; row < gray->Height; row++)
for(int col=1; col < gray->Width; col++)
{
a = (gray->GetPixel(col,row)).R;
img[ INDEX(gray->Width, row, col) ] = (gray->GetPixel(col,row)).R ;
}
//when i check the "a" value with debugger in the first iteration, it shows
//149 and when i check the img[1] value it shows 39 ; so shouldn't the
//img[1] value be 149 too ?? what's my mistake can anyone guess where i
//am wrong?
#define INDEX(W, R, C) ((R)*(W)+(C)) //defined in Tools.h
//starts Form1.h
.....
......
......
static int arrayVal ;
static int* img; //the 1D array
static Bitmap* source; // source image
Bitmap* gray; // gray image
...
...
...
public: System::Void openFileDialog1_FileOk(System::Object * sender, System::ComponentModel::CancelEventArgs * e) {
source = new Bitmap(Image::FromFile(openFileDialog1->FileName));
gray = ConvertToGrayscale( source ) ; // ConvertToGrayScale is defined in
//Tools.h
img = (int*) new int[(gray->Width)*(gray->Height)] ;
for(int row=0; row < gray->Height; row++)
for(int col=1; col < gray->Width; col++)
{
a = (gray->GetPixel(col,row)).R;
img[ INDEX(gray->Width, row, col) ] = (gray->GetPixel(col,row)).R ;
}
//when i check the "a" value with debugger in the first iteration, it shows
//149 and when i check the img[1] value it shows 39 ; so shouldn't the
//img[1] value be 149 too ?? what's my mistake can anyone guess where i
//am wrong?