home *** CD-ROM | disk | FTP | other *** search
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #pragma hdrstop
-
- #include "UGray.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma resource "*.dfm"
- TForm1 *Form1;
- //---------------------------------------------------------------------------
- __fastcall TForm1::TForm1(TComponent* Owner)
- : TForm(Owner)
- {
- }
- //---------------------------------------------------------------------------
-
- void __fastcall TForm1::OpenClick(TObject *Sender)
- {
- if (OpenDialog->Execute()) Image1->Picture->LoadFromFile (OpenDialog->FileName);
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::GrayScaleClick(TObject *Sender)
- {
- Image1->Picture->Bitmap->PixelFormat = pf32bit;
- for (int Row = 0; Row < Image1->Picture->Height; Row++) {
- RGBQUAD * p = (RGBQUAD *) Image1->Picture->Bitmap->ScanLine [Row];
- for (int Col = 0; Col < Image1->Picture->Width; Col++) {
- int Brightness = p->rgbRed + p->rgbGreen + p->rgbBlue;
- p->rgbRed = Brightness / 3;
- p->rgbGreen = p->rgbRed;
- p->rgbBlue = p->rgbRed;
- p++;
- }
- }
-
- Image1->Invalidate();
- }
- //---------------------------------------------------------------------------
-