數位媒體概論--1116的課題
//---------------------------------------------------------------------------
#include
#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 R1 , G1 , B1 , x , y , R2 , G2 , B2 ,R , G , B;
for (x=0;x<300;x++){ y="0;y<300;y++){" r1="GetRValue(Image1-">Canvas->Pixels[x][y]);
G1=GetGValue(Image1->Canvas->Pixels[x][y]);
B1=GetBValue(Image1->Canvas->Pixels[x][y]);
//讀取第二章圖RGB
R2=GetRValue(Image2->Canvas->Pixels[x][y]);
G2=GetGValue(Image2->Canvas->Pixels[x][y]);
B2=GetBValue(Image2->Canvas->Pixels[x][y]);
R=(R1+R2)/2;
G=(G1+G2)/2;
B=(B1+B2)/2;
Image3->Canvas->Pixels[x][y]=(TColor)RGB(R,G,B);
}
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
int R1 , G1 , B1 , x , y , R2 , G2 , B2 ,R , G , B;
for (x=0;x<300;x++){ y="0;y<300;y++){" r1="GetRValue(Image1-">Canvas->Pixels[x][y]);
G1=GetGValue(Image1->Canvas->Pixels[x][y]);
B1=GetBValue(Image1->Canvas->Pixels[x][y]);
//讀取第二章圖RGB
R2=GetRValue(Image2->Canvas->Pixels[x][y]);
G2=GetGValue(Image2->Canvas->Pixels[x][y]);
B2=GetBValue(Image2->Canvas->Pixels[x][y]);
R=(3*R1+R2)/4;
G=(3*G1+G2)/4;
B=(3*B1+B2)/4;
Image3->Canvas->Pixels[x][y]=(TColor)RGB(R,G,B);
}
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{
int R1 , G1 , B1 , x , y , R2 , G2 , B2 ,R , G , B;
for (x=0;x<300;x++){ y="0;y<300;y++){" r1="GetRValue(Image1-">Canvas->Pixels[x][y]);
G1=GetGValue(Image1->Canvas->Pixels[x][y]);
B1=GetBValue(Image1->Canvas->Pixels[x][y]);
//讀取第二章圖RGB
R2=GetRValue(Image2->Canvas->Pixels[x][y]);
G2=GetGValue(Image2->Canvas->Pixels[x][y]);
B2=GetBValue(Image2->Canvas->Pixels[x][y]);
R=(R1+3*R2)/4;
G=(G1+3*G2)/4;
B=(B1+3*B2)/4;
Image3->Canvas->Pixels[x][y]=(TColor)RGB(R,G,B);
}
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ScrollBar1Change(TObject *Sender)
{
int R1 , G1 , B1 , x , y , R2 , G2 , B2 ,R , G , B;
for (x=0;x<300;x++){ y="0;y<300;y++){" r1="GetRValue(Image1-">Canvas->Pixels[x][y]);
G1=GetGValue(Image1->Canvas->Pixels[x][y]);
B1=GetBValue(Image1->Canvas->Pixels[x][y]);
//讀取第二章圖RGB
R2=GetRValue(Image2->Canvas->Pixels[x][y]);
G2=GetGValue(Image2->Canvas->Pixels[x][y]);
B2=GetBValue(Image2->Canvas->Pixels[x][y]);
int test=ScrollBar1->Position;
if (Position==50)
{
R=(R1 * test + R2 * test)/100;
G=(G1 * test + G2 * test)/100;
B=(B1 * test + B2 * test)/100;
}
else if (Position>50)
{
R=(R1 * test + R2 * (100-test))/100;
G=(G1 * test + G2 * (100-test))/100;
B=(B1 * test + B2 * (100-test))/100;
}
else if(Position<50) r="(R1" g="(G1" b="(B1">Canvas->Pixels[x][y]=(TColor)RGB(R,G,B);
}
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button4Click(TObject *Sender)
{
int R1 , G1 , B1 , x , y , R2 , G2 , B2 ,R , G , B;
for (x=0;x<300;x++){ y="0;y<300;y++){" r1="GetRValue(Image1-">Canvas->Pixels[x][y]);
G1=GetGValue(Image1->Canvas->Pixels[x][y]);
B1=GetBValue(Image1->Canvas->Pixels[x][y]);
//讀取第二章圖RGB
R2=GetRValue(Image2->Canvas->Pixels[x][y]);
G2=GetGValue(Image2->Canvas->Pixels[x][y]);
B2=GetBValue(Image2->Canvas->Pixels[x][y]);
R=(R1 * (300-x) + x * R2)/300;
G=(G1 * (300-x) + x * G2)/300;
B=(B1 * (300-x) + x * B2)/300;
Image3->Canvas->Pixels[x][y]=(TColor)RGB(R,G,B);
}
}
}
//---------------------------------------------------------------------------
套用這支程式,就可以把自己的照片+另一張圖片做出類似浮水印的效果
0 Comments:
Post a Comment
<< Home