IMAGE S, D;
BYTE *R, *G, *B, *E;
char *ptr;
int x, y, Width, Height;
double Gx,Gy,pi=3.14159;
Width = Image1->Picture->Bitmap->Width;
Height = Image1->Picture->Bitmap->Height;
S.LoadImg(Image1->Picture->Bitmap);
R = new BYTE[Width*Height];
G = new BYTE[Width*Height];
B = new BYTE[Width*Height];
E = new BYTE[Width*Height]; for(y=0;yPicture->Bitmap->ScanLine[y];
for(x=0;x -(pi/8)) && (fabs(Gy) fabs(Gx))/2>100 )
{
E[y*Width x] = 255;
a= E[y*Width x]; }
else if ( atan(Gy/Gx)<(3*pi/8) && atan(Gy/Gx)>(pi/8) && (fabs(Gy) fabs(Gx))/2>100 )
{
E[y*Width x] = 255;
b= E[y*Width x]; }
else if ( atan(Gy/Gx)<(5*pi/8) && atan(Gy/Gx)>(3*pi/8) && (fabs(Gy) fabs(Gx))/2>100 )
{
E[y*Width x] = 255;
c= E[y*Width x]; }
else if ( atan(Gy/Gx)< -(pi/8) && atan(Gy/Gx)> -(3*pi/8) && (fabs(Gy) fabs(Gx))/2>100 )
{
E[y*Width x] = 255;
d= E[y*Width x]; }
}
}
if(a==255 && (fabs(Gy) fabs(Gx))/2>100)
ShowMessage("這是0度");
else if(b==255 && (fabs(Gy) fabs(Gx))/2>100)
ShowMessage("這是45度");
else if(c==255 && (fabs(Gy) fabs(Gx))/2>100)
ShowMessage("這是90度");
else if(d==255 && (fabs(Gy) fabs(Gx))/2>100)
ShowMessage("這是135度");
ShowMessage(fabs(Gx));
Image2->Picture->Bitmap->Width = Image1->Picture->Bitmap->Width;
Image2->Picture->Bitmap->Height = Image1->Picture->Bitmap->Height;
Image2->Picture->Bitmap->PixelFormat = pf24bit; for(y=0;yPicture->Bitmap->ScanLine[y];
for(x=0;xPicture->Bitmap);
Image2->Refresh(); delete R;
delete G;
delete B;