Unit1.cpp
上传用户:lhxd_sz
上传日期:2014-10-02
资源大小:38814k
文件大小:2k
- //---------------------------------------------------------------------------
- #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::SplitColor(TCanvas *S_Cv,TCanvas *D_Cv,int width,int height,int nn)
- {
- int ii,jj;
- int rgb,rgb1,Rv,Gv,Bv,Cv,Mv,Yv,Kv;
- for(ii=0;ii<height;ii++)
- {
- for(jj=0;jj<width;jj++)
- {
- rgb=S_Cv->Pixels[jj][ii];
- Rv=GetRValue(rgb);
- Gv=GetGValue(rgb);
- Bv=GetBValue(rgb);
- Cv=Rv;
- Mv=Gv;
- Yv=Bv;
- if((Rv==Gv)&&(Gv==Bv))
- {
- Kv=Gv;Cv=255;Mv=255;Yv=255;
- }
- else Kv=255;
- //
- if(nn==0)rgb1=Cv;
- else if(nn==1)rgb1=Mv;
- else if(nn==2)rgb1=Yv;
- else rgb1=Kv;
- D_Cv->Pixels[jj][ii]=TColor(RGB(Byte(rgb1),Byte(rgb1),Byte(rgb1)));
- }
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button1Click(TObject *Sender)
- {
- SplitColor(Image1->Canvas,Image2->Canvas,Image1->Width,Image1->Height,0);
- SplitColor(Image1->Canvas,Image3->Canvas,Image1->Width,Image1->Height,1);
- SplitColor(Image1->Canvas,Image4->Canvas,Image1->Width,Image1->Height,2);
- SplitColor(Image1->Canvas,Image5->Canvas,Image1->Width,Image1->Height,3);
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button2Click(TObject *Sender)
- {
- SplitColor(Image6->Canvas,Image2->Canvas,Image1->Width,Image1->Height,0);
- SplitColor(Image6->Canvas,Image3->Canvas,Image1->Width,Image1->Height,1);
- SplitColor(Image6->Canvas,Image4->Canvas,Image1->Width,Image1->Height,2);
- SplitColor(Image6->Canvas,Image5->Canvas,Image1->Width,Image1->Height,3);
- }
- //---------------------------------------------------------------------------