//--------------------------------------------------------------------------- #include #include #pragma hdrstop #include "Unit1.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TForm1 *Form1; Graphics::TBitmap *TheBitmap, *TempBitmap; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TForm1::Open1Click(TObject *Sender) { int Height, Width; if(OpenPictureDialog1->Execute()) { Image1->Picture->LoadFromFile(OpenPictureDialog1->FileName); } Edit3->Text=Image1->Picture->Bitmap->Height; Edit4->Text=Image1->Picture->Bitmap->Width; } //--------------------------------------------------------------------------- void __fastcall TForm1::Exit1Click(TObject *Sender) { Close(); } //--------------------------------------------------------------------------- void __fastcall TForm1::N3x31Click(TObject *Sender) { Byte *ptr, *tptr; int Height, Width, Threshold; Threshold=StrToInt(Edit1->Text); TheBitmap=new Graphics::TBitmap(); TempBitmap=new Graphics::TBitmap(); TheBitmap=Image1->Picture->Bitmap; TempBitmap->Assign(TheBitmap); Height=TheBitmap->Height; Width=TheBitmap->Width; for (int row=1;rowScanLine[row]; tptr=(Byte*) TempBitmap->ScanLine[row]; for (int col=1; colThreshold ) tptr[col]=0; else tptr[col]=255; } } Image2->Picture->Bitmap=TempBitmap; } //--------------------------------------------------------------------------- void __fastcall TForm1::Save1Click(TObject *Sender) { if (SavePictureDialog1->Execute()) Image2->Picture->SaveToFile(SavePictureDialog1->FileName); } //--------------------------------------------------------------------------- void __fastcall TForm1::Area1Click(TObject *Sender) { Byte *ptr; int Height, Width, area=0; Height=TempBitmap->Height; Width=TheBitmap->Width; for (int row=1;rowScanLine[row]; for (int col=1; colText=area; } //---------------------------------------------------------------------------