Bitmap ^bmp1;
Bitmap ^bmp2;
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
// 開啟
openFileDialog1->Filter = "影像檔(*.bmp)|*.bmp|所有檔案(*.*)|*.*";
openFileDialog1->FilterIndex = 1;
openFileDialog1->RestoreDirectory = true;
openFileDialog1->DefaultExt = ".bmp|.jpg|";
if(openFileDialog1->ShowDialog() == System::Windows::Forms::DialogResult::OK && openFileDialog1->FileName->Length > 0 )
pictureBox1->Image =Image::FromFile(openFileDialog1->FileName); // 讀取影像
String^ str1 = openFileDialog1->FileName;
bmp1= gcnew Bitmap(str1);
}
private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {
//負片效果
int i,j;
Color rgb,rgb1;
Byte R1,G1,B1;
bmp2 = gcnew Bitmap(pictureBox1->Width,pictureBox1->Height);
for(j=0;j<>Height;j++)
for(i=0;i<>Width;i++)
{
rgb=bmp1->GetPixel(i,j); // 讀取原影像每一點像素
// RGB分解
R1=rgb.R;
G1=rgb.G;
B1=rgb.B;
//負片方法
bmp2->SetPixel(i,j,Color::FromArgb(255-R1,255-G1,255-B1));// 存每一點處理後像素至另一影像
}
pictureBox2->Image= bmp2;
}
搜尋此網誌
2009年5月19日 星期二
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言