Unit1.cpp
上传用户:lhxd_sz
上传日期:2014-10-02
资源大小:38814k
文件大小:1k
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #pragma hdrstop
- #include "Unit1.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma resource "*.dfm"
- TForm1 *Form1;
- //---------------------------------------------------------------------------
- __fastcall TForm1::TForm1(TComponent* Owner)
- : TForm(Owner)
- {
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button1Click(TObject *Sender)
- {
- int ii,jj,pix,pix1;
- byte cr,cg,cb;
- for(jj=0;jj<Image1->Height;jj++)
- for(ii=0;ii<Image1->Width;ii++)
- {
- pix=Image1->Picture->Bitmap->Canvas->Pixels[ii][jj];
- cr=GetRValue(pix);
- cg=GetGValue(pix);
- cb=GetBValue(pix);
- pix1=0.3*cr+0.6*cg+0.1*cb;
- pix=RGB(pix1,pix1,pix1);
- Image1->Picture->Bitmap->Canvas->Pixels[ii][jj]=(TColor)pix;
- }
- }
- //---------------------------------------------------------------------------