herrDeng網內搜尋
自訂搜尋
Ads
訂閱:
張貼留言 (Atom)
熱門文章
-
教育部為提昇全民資安素養與電腦防護能力,本部於101年9月5日至11月5日舉辦「全民資安素養自我評量」活動,請在活動期間內踴躍上網檢測資訊安全素養認知程度,並有機會參與抽獎,詳情請參閱活動網站(網址: https://isafe.moe.edu.tw/event
-
先說明一下這是後知後覺的解答,所謂後知就是股票價格已知存在陣列(清單),當然就要用迴圈練習,雙迴圈暴力解需時O(n**2),當然不用,採python單一迴圈解答「最佳股票的買賣時機#LeetCode 121 Best Time to Buy and Sell Stock」,解...
-
url="https://www.twse.com.tw/exchangeReport/STOCK_DAY?response=json&date=20220330&stockNo=2330"
-
你會用C的算子sizeof?
-
Python C++使用字串find迴圈速解Leetcode 2490 Circular Sentence C++ & Python都有字串的find,用法都類似 split=s.find(' ', split+1)能找到s從index=split+1開...
-
Python CPP heap priority queue速解L eetcode 2530. Maximal Score After Applying K Operations heap/priority queue是重要的資料結構,無論是C++的std::priority_q...
30 則留言:
RGB operator+(RGB p1,RGB p2) {
int r = Clamp(p1.R + p2.R, 0, 255);
int g = Clamp(p1.G + p2.G, 0, 255);
int b = Clamp(p1.B + p2.B, 0, 255);
return RGB(r, g, b);
}
RGB operator*(double alpha, RGB p) {
int r = Clamp((int)(p.R*alpha), 0, 255);
int g = Clamp((int)(p.G*alpha), 0, 255);
int b = Clamp((int)(p.B*alpha), 0, 255);
return RGB(r, g, b);
}
void image_blend(Bitmap^im0,Bitmap^im1,double alpha,double beta) {
int W0 = im0->Width, H0 = im0->Height;
int W1 = im1->Width, H1 = im1->Height;
if (W1 != W0 || H1 != H0) {
cout << "圖大小不合\n";
return;
}
Bitmap im2(W0, H0);
Color Black = Color::FromArgb(0, 0, 0);
for(int x=0;xGetPixel(x, y);
Color p1 = im1->GetPixel(x, y);
RGB pp = (alpha*RGB(p0)) + (beta*RGB(p1));
Color pixel2 = Color::FromArgb(pp.R, pp.G, pp.B);
im2.SetPixel(x, y, pixel2);
}
im2.Save("ROGOOD.png");
cout << "RO圖檔產生\n";
}
RGB operator+(RGB p1, RGB p2) {
int r = Clamp(p1.R + p2.R, 0, 255);
int g = Clamp(p1.G + p2.G, 0, 255);
int b = Clamp(p1.B + p2.B, 0, 255);
return RGB(r, g, b);
}
RGB operator*(double alpha, RGB p) {
int r = Clamp((int)(p.R*alpha), 0, 255);
int g = Clamp((int)(p.G*alpha), 0, 255);
int b = Clamp((int)(p.B*alpha), 0, 255);
return RGB(r, g, b);
}
void image_blend(Bitmap^im0, Bitmap^im1, double alpha, double beta) {
int W0 = im0->Width, H0 = im0->Height;
int W1 = im1->Width, H1 = im1->Height;
if (W1 != W0 || H1 != H0) {
cout << "圖大小不合。\n";
return;
}
Bitmap im2(W0, H0);
Color Black = Color::FromArgb(0, 0, 0);
for (int x=0 ; x<W0 ; x++)
for (int y = 0 ; y < H0 ; y++)
{
Color p0 = im0->GetPixel(x, y);
Color p1 = im1->GetPixel(x, y);
RGB pp = (alpha*RGB(p0)) + (beta*RGB(p1));
Color pixel2 = Color::FromArgb(pp.R,pp.G,pp.B);
im2.SetPixel(x, y, pixel2);
}
im2.Save("blend.png");
cout << "blend.png圖檔產生\n";
}
RGB operator+(RGB p1, RGB p2) {
int r = Clamp(p1.R + p2.R, 0, 255);
int g = Clamp(p1.G + p2.G, 0, 255);
int b = Clamp(p1.B + p2.B, 0, 255);
return RGB(r, g, b);
}
RGB operator*(double alpha, RGB p) {
int r = Clamp((int)(p.R*alpha), 0, 255);
int g = Clamp((int)(p.G*alpha), 0, 255);
int b = Clamp((int)(p.B*alpha), 0, 255);
return RGB(r, g, b);
}
void image_blend(Bitmap^im0, Bitmap^im1, double alpha, double beta) {
int W0 = im0->Width, H0 = im0->Height;
int W1 = im1->Width, H1 = im1->Height;
if (W1 != W0 || H1 != H0) {
cout << "圖大小不合。\n";
return;
}
Bitmap im2(W0, H0);
Color Black = Color::FromArgb(0, 0, 0);
for (int x=0 ; x<W0 ; x++)
for (int y = 0 ; y < H0 ; y++)
{
Color p0 = im0->GetPixel(x, y);
Color p1 = im1->GetPixel(x, y);
RGB pp = (alpha*RGB(p0)) + (beta*RGB(p1));
Color pixel2 = Color::FromArgb(pp.R,pp.G,pp.B);
im2.SetPixel(x, y, pixel2);
}
im2.Save("blend.png");
cout << "blend.png圖檔產生\n";
}
RGB operator+(RGB p1, RGB p2) {
int r = Clamp(p1.R + p2.R, 0, 255);
int g = Clamp(p1.G + p2.G, 0, 255);
int b = Clamp(p1.B + p2.B, 0, 255);
return RGB(r, g, b);
}
RGB operator*(double alpha, RGB p) {
int r = Clamp((int)(p.R*alpha), 0, 255);
int g = Clamp((int)(p.G*alpha), 0, 255);
int b = Clamp((int)(p.B*alpha), 0, 255);
return RGB(r, g, b);
}
void image_blend(Bitmap^im0, Bitmap^im1, double alpha, double beta) {
int W0 = im0->Width, H0 = im0->Height;
int W1 = im1->Width, H1 = im1->Height;
if (W1 != W0 || H1 != H0) {
cout << "圖大小不合。\n";
return;
}
Bitmap im2(W0, H0);
Color Black = Color::FromArgb(0, 0, 0);
for (int x=0 ; x<W0 ; x++)
for (int y = 0 ; y < H0 ; y++)
{
Color p0 = im0->GetPixel(x, y);
Color p1 = im1->GetPixel(x, y);
RGB pp = (alpha*RGB(p0)) + (beta*RGB(p1));
Color pixel2 = Color::FromArgb(pp.R,pp.G,pp.B);
im2.SetPixel(x, y, pixel2);
}
im2.Save("blend.png");
cout << "blend.png圖檔產生\n";
}
RGB operator+(RGB p1, RGB p2) {
int r = Clamp(p1.R + p2.R, 0, 255);
int g = Clamp(p1.G + p2.G, 0, 255);
int b = Clamp(p1.B + p2.B, 0, 255);
return RGB(r, g, b);
}
RGB operator*(double alpha, RGB p) {
int r = Clamp((int)(p.R*alpha), 0, 255);
int g = Clamp((int)(p.G*alpha), 0, 255);
int b = Clamp((int)(p.B*alpha), 0, 255);
return RGB(r, g, b);
}
void image_blend(Bitmap^im0, Bitmap^im1, double alpha, double beta) {
int W0 = im0->Width, H0 = im0->Height;
int W1 = im1->Width, H1 = im1->Height;
if (W1 != W0 || H1 != H0) {
cout << "圖大小不合。\n";
return;
}
Bitmap im2(W0, H0);
Color Black = Color::FromArgb(0, 0, 0);
for (int x=0 ; x<W0 ; x++)
for (int y = 0 ; y < H0 ; y++)
{
Color p0 = im0->GetPixel(x, y);
Color p1 = im1->GetPixel(x, y);
RGB pp = (alpha*RGB(p0)) + (beta*RGB(p1));
Color pixel2 = Color::FromArgb(pp.R,pp.G,pp.B);
im2.SetPixel(x, y, pixel2);
}
im2.Save("blend.png");
cout << "blend.png圖檔產生\n";
}
RGB operator+(RGB p1, RGB p2) {
int r = Clamp(p1.R + p2.R, 0, 255);
int g = Clamp(p1.G + p2.G, 0, 255);
int b = Clamp(p1.B + p2.B, 0, 255);
return RGB(r, g, b);
}
RGB operator*(double alpha, RGB p) {
int r = Clamp((int)(p.R*alpha), 0, 255);
int g = Clamp((int)(p.G*alpha), 0, 255);
int b = Clamp((int)(p.B*alpha), 0, 255);
return RGB(r, g, b);
}
void image_blend(Bitmap^im0, Bitmap^im1, double alpha, double beta) {
int W0 = im0->Width, H0 = im0->Height;
int W1 = im1->Width, H1 = im1->Height;
if (W1 != W0 || H1 != H0) {
cout << "圖大小不合。\n";
return;
}
Bitmap im2(W0, H0);
Color Black = Color::FromArgb(0, 0, 0);
for (int x=0 ; x<W0 ; x++)
for (int y = 0 ; y < H0 ; y++)
{
Color p0 = im0->GetPixel(x, y);
Color p1 = im1->GetPixel(x, y);
RGB pp = (alpha*RGB(p0)) + (beta*RGB(p1));
Color pixel2 = Color::FromArgb(pp.R,pp.G,pp.B);
im2.SetPixel(x, y, pixel2);
}
im2.Save("blend.png");
cout << "blend.png圖檔產生\n";
}
RGB operator+(RGB p1, RGB p2) {
int r = Clamp(p1.R + p2.R, 0, 255);
int g = Clamp(p1.G + p2.G, 0, 255);
int b = Clamp(p1.B + p2.B, 0, 255);
return RGB(r, g, b);
}
RGB operator*(double alpha, RGB p) {
int r = Clamp((int)(p.R*alpha), 0, 255);
int g = Clamp((int)(p.G*alpha), 0, 255);
int b = Clamp((int)(p.B*alpha), 0, 255);
return RGB(r, g, b);
}
void image_blend(Bitmap^im0, Bitmap^im1, double alpha, double beta) {
int W0 = im0->Width, H0 = im0->Height;
int W1 = im1->Width, H1 = im1->Height;
if (W1 != W0 || H1 != H0) {
cout << "圖大小不合。\n";
return;
}
Bitmap im2(W0, H0);
Color Black = Color::FromArgb(0, 0, 0);
for (int x=0 ; x<W0 ; x++)
for (int y = 0 ; y < H0 ; y++)
{
Color p0 = im0->GetPixel(x, y);
Color p1 = im1->GetPixel(x, y);
RGB pp = (alpha*RGB(p0)) + (beta*RGB(p1));
Color pixel2 = Color::FromArgb(pp.R,pp.G,pp.B);
im2.SetPixel(x, y, pixel2);
}
im2.Save("blend.png");
cout << "blend.png圖檔產生\n";
}
//RGB + 的方法
RGB operator+(RGB p1, RGB p2) {
int r = Clamp(p1.R + p2.R, 0, 255);
int g = Clamp(p1.G + p2.G, 0, 255);
int b = Clamp(p1.B + p2.B, 0, 255);
return RGB(r, g, b);
}
//RGB * 的方法
RGB operator*(double a , RGB p) {
int r = Clamp((int)(p.R * a), 0, 255);
int g = Clamp((int)(p.G * a), 0, 255);
int b = Clamp((int)(p.B * a), 0, 255);
return RGB(r, g, b);
}
//浮水印方法
void image_blend(Bitmap^ im0, Bitmap^ im1, double alpha, double beta) {
//宣告H0,H1,W0,W1 來得到兩張圖的長 跟 寬
int H0 = im0->Height, W0 = im0->Width;
int H1 = im1->Height, W1 = im1->Width;
// 判斷如果兩張圖大小不一樣就跳出程式
if (H0 != H1 || W0 != W1) {
cout << "兩圖大小不合。\n";
return;
}
//宣告物件Bitmap im2 來存浮水印的結果 成為另一張圖 blend.png
Bitmap im2(W0, H0);
Color Black = Color::FromArgb(0, 0, 0);
//兩層迴圈來得到 第一張圖 跟第二張圖(要成為浮水印的圖) 的每個Pixel
for (int x = 0; x < W0; x++) {
for (int y = 0; y < H0; y++)
{
Color p0 = im0->GetPixel(x, y);
Color p1 = im1->GetPixel(x, y);
//浮水印公式 (a*im0)+(b*im1)
// alpha,beta 色彩彩度
RGB pp = (alpha*p0) + (beta*p1);
//公式算好後 存在一個新宣告物件的顏色 pixel2
//pp.R pp.G pp.B 是 浮水應公式計算後的顏色
Color pixel2 = Color::FromArgb(pp.R, pp.G, pp.B);
//再來設定im2每個點(x,y)的顏色(pixel2)
im2.SetPixel(x, y, pixel2);
}
}
//迴圈計算好後另存一個圖檔
im2.Save("blend.png");
cout << "blend.png圖檔產生\n";
}
RGB operator+(RGB p1, RGB p2) {
return RGB(clamp(p1.R + p2.R, 0, 255),
clamp(p1.G + p2.G, 0, 255),
clamp(p1.B + p2.B, 0, 255));
}
RGB operator*(double a, RGB p) {
return RGB(clamp(p.R*a, 0, 255),
clamp(p.G*a, 0, 255),
clamp(p.B*a, 0, 255));
}
void blend(Bitmap^ im0, Bitmap^ im1, double a, double b) {
int H0 = im0->Height, WO = im0->Width;
int H1 = im1->Height, W1 = im1->Width;
if (H0 != H1 || WO != W1) { cout << "大小不合\n"; return; }
Bitmap im2(WO, H0);
for (int x = 0; x < WO; x++)
for (int y = 0; y < H0; y++) {
RGB p0(im0->GetPixel(x, y));
RGB p1(im1->GetPixel(x, y));
RGB p2 = (a*p0) + (b*p1);
Color pixel2 = Color::FromArgb(p2.R, p2.G, p2.B);
im2.SetPixel(x, y, pixel2);
}
im2.Save("blend.png");
cout << "blend.png圖好了。\n";
}
RGB operator+(RGB p1, RGB p2) {
return RGB(clamp(p1.R + p2.R, 0, 255),
clamp(p1.G + p2.G, 0, 255),
clamp(p1.B + p2.B, 0, 255));
}
RGB operator*(double a, RGB p) {
return RGB(clamp(p.R*a, 0, 255),
clamp(p.G*a, 0, 255),
clamp(p.B*a, 0, 255));
}
void blend(Bitmap^ im0, Bitmap^ im1, double a, double b) {
int H0 = im0->Height, WO = im0->Width;
int H1 = im1->Height, W1 = im1->Width;
if (H0 != H1 || WO != W1) { cout << "大小不合\n"; return; }
Bitmap im2(WO, H0);
for (int x = 0; x < WO; x++)
for (int y = 0; y < H0; y++) {
RGB p0(im0->GetPixel(x, y));
RGB p1(im1->GetPixel(x, y));
RGB p2 = (a*p0) + (b*p1);
Color pixel2 = Color::FromArgb(p2.R, p2.G, p2.B);
im2.SetPixel(x, y, pixel2);
}
im2.Save("blend.png");
cout << "blend.png圖好了。\n";
}
RGB operator+(RGB p1, RGB p2) {
int r = Clamp(p1.R + p2.R, 0, 255);
int g = Clamp(p1.G + p2.G, 0, 255);
int b = Clamp(p1.B + p2.B, 0, 255);
return RGB(r, g, b);
}
RGB operator*(double alpha, RGB p) {
int r = Clamp((int)(p.R*alpha), 0, 255);
int g = Clamp((int)(p.G*alpha), 0, 255);
int b = Clamp((int)(p.B*alpha), 0, 255);
return RGB(r, g, b);
}
void image_blend(Bitmap^ im0, Bitmap^ im1, double alpha, double beta) {
int W0 = im0->Width, H0 = im0->Height;
int W1 = im1->Width, H1 = im1->Height;
if (W1 != W0 || H1 != H0) {
cout << "圖大小不合。\n";
return;
}
Bitmap im2(W0, H0);
Color Black = Color::FromArgb(0, 0, 0);
for(int x= 0 ; x < W0 ; x++)
for (int y=0 ; y < H0; y++) {
Color p0 = im0->GetPixel(x, y);
Color p1 = im1->GetPixel(x, y);
RGB pp = (alpha*RGB(p0)) + (beta*RGB(p1));
Color pixel2 = Color::FromArgb(pp.R, pp.G, pp.B);
im2.SetPixel(x, y, pixel2);
}
im2.Save("blend.png");
cout << "blend.png圖檔產生\n";
}
#include <iostream>
#include <cstdlib>
using namespace std;
#using <System.Drawing.dll>
using namespace System::Drawing;
struct RGB {
int R, G, B;
RGB() {}
RGB(int R, int G, int B) :R(R), G(G), B(B) {}
RGB(Color p) {
R = p.R; G = p.G; B = p.B;
}
};
int clamp(int X, int L, int U) {
if (X < L)return L;
else if (X > U)return U;
else return X;
}
RGB operator+(RGB p1, RGB p2) {
return RGB(clamp(p1.R + p2.R, 0, 255), clamp(p1.G + p2.G, 0, 255), clamp(p1.B + p2.B, 0, 255));
}
RGB operator*(double a, RGB p) {
return RGB(clamp(p.R*a, 0, 255), clamp(p.G*a, 0, 255), clamp(p.B*a, 0, 255));
}
void blend (Bitmap^im0, Bitmap^im1,double a, double b){
int H0 = im0->Height, W0 = im0->Width;
int H1 = im1->Height, W1 = im1->Width;
if (H0 != H1 || W0 != W1) { cout << "大小不合\n"; return; }
Bitmap im2(W0, H0);
for (int x = 0; x < W0; x++)
for (int y = 0; y < H0; y++) {
RGB p0(im0->GetPixel(x, y));
RGB p1(im1->GetPixel(x, y));
RGB p2 = (a*p0) + (b*p1);
Color pixel2 = Color::FromArgb(p2.R, p2.G, p2.B);
im2.SetPixel(x, y, pixel2);
}
im2.Save("blend.png");
cout << "blend.png圖好了。\n";
}
int main()
{
Bitmap^im0 = gcnew Bitmap("rabbit.jpg");
Bitmap^im1 = gcnew Bitmap("8.jpg");
double a = 0.9, b = 0.1;
blend(im0, im1, a, b);
cout << "浮水印\n";
system("Pause");
return 0;
}
#include <iostream>
#include <cstdlib>
using namespace std;
#using <System.Drawing.dll>
using namespace System::Drawing;
struct RGB {
int R, G, B;
RGB() {}
RGB(int R, int G, int B) :R(R), G(G), B(B) {}
RGB(Color p) {
R = p.R; G = p.G; B = p.B;
}
};
int clamp(int X, int L, int U) {
if (X < L)return L;
else if (X > U)return U;
else return X;
}
RGB operator+(RGB p1, RGB p2) {
return RGB(clamp(p1.R + p2.R, 0, 255), clamp(p1.G + p2.G, 0, 255), clamp(p1.B + p2.B, 0, 255));
}
RGB operator*(double a, RGB p) {
return RGB(clamp(p.R*a, 0, 255), clamp(p.G*a, 0, 255), clamp(p.B*a, 0, 255));
}
void blend (Bitmap^im0, Bitmap^im1,double a, double b){
int H0 = im0->Height, W0 = im0->Width;
int H1 = im1->Height, W1 = im1->Width;
if (H0 != H1 || W0 != W1) { cout << "大小不合\n"; return; }
Bitmap im2(W0, H0);
for (int x = 0; x < W0; x++)
for (int y = 0; y < H0; y++) {
RGB p0(im0->GetPixel(x, y));
RGB p1(im1->GetPixel(x, y));
RGB p2 = (a*p0) + (b*p1);
Color pixel2 = Color::FromArgb(p2.R, p2.G, p2.B);
im2.SetPixel(x, y, pixel2);
}
im2.Save("blend.png");
cout << "blend.png圖好了。\n";
}
int main()
{
Bitmap^im0 = gcnew Bitmap("rabbit.jpg");
Bitmap^im1 = gcnew Bitmap("8.jpg");
double a = 0.9, b = 0.1;
blend(im0, im1, a, b);
cout << "浮水印\n";
system("Pause");
return 0;
}
#include <iostream>
#include <cstdlib>
using namespace std;
#using <System.Drawing.dll>
using namespace System::Drawing;
struct RGB {
int R, G, B;
RGB() {}
RGB(int R, int G, int B) :R(R), G(G), B(B) {}
RGB(Color p) {
R = p.R; G = p.G; B = p.B;
}
};
int clamp(int X, int L, int U) {
if (X < L)return L;
else if (X > U)return U;
else return X;
}
RGB operator+(RGB p1, RGB p2) {
return RGB(clamp(p1.R + p2.R, 0, 255), clamp(p1.G + p2.G, 0, 255), clamp(p1.B + p2.B, 0, 255));
}
RGB operator*(double a, RGB p) {
return RGB(clamp(p.R*a, 0, 255), clamp(p.G*a, 0, 255), clamp(p.B*a, 0, 255));
}
void blend (Bitmap^im0, Bitmap^im1,double a, double b){
int H0 = im0->Height, W0 = im0->Width;
int H1 = im1->Height, W1 = im1->Width;
if (H0 != H1 || W0 != W1) { cout << "大小不合\n"; return; }
Bitmap im2(W0, H0);
for (int x = 0; x < W0; x++)
for (int y = 0; y < H0; y++) {
RGB p0(im0->GetPixel(x, y));
RGB p1(im1->GetPixel(x, y));
RGB p2 = (a*p0) + (b*p1);
Color pixel2 = Color::FromArgb(p2.R, p2.G, p2.B);
im2.SetPixel(x, y, pixel2);
}
im2.Save("blend.png");
cout << "blend.png圖好了。\n";
}
int main()
{
Bitmap^im0 = gcnew Bitmap("rabbit.jpg");
Bitmap^im1 = gcnew Bitmap("8.jpg");
double a = 0.9, b = 0.1;
blend(im0, im1, a, b);
cout << "浮水印\n";
system("Pause");
return 0;
}
#include <iostream>
#include <cstdlib>
using namespace std;
#using <System.Drawing.dll>
using namespace System::Drawing;
struct RGB {
int R, G, B;
RGB() {}
RGB(int R, int G, int B) :R(R), G(G), B(B) {}
RGB(Color p) {
R = p.R; G = p.G; B = p.B;
}
};
int clamp(int X, int L, int U) {
if (X < L)return L;
else if (X > U)return U;
else return X;
}
RGB operator+(RGB p1, RGB p2) {
return RGB(clamp(p1.R + p2.R, 0, 255), clamp(p1.G + p2.G, 0, 255), clamp(p1.B + p2.B, 0, 255));
}
RGB operator*(double a, RGB p) {
return RGB(clamp(p.R*a, 0, 255), clamp(p.G*a, 0, 255), clamp(p.B*a, 0, 255));
}
void blend (Bitmap^im0, Bitmap^im1,double a, double b){
int H0 = im0->Height, W0 = im0->Width;
int H1 = im1->Height, W1 = im1->Width;
if (H0 != H1 || W0 != W1) { cout << "大小不合\n"; return; }
Bitmap im2(W0, H0);
for (int x = 0; x < W0; x++)
for (int y = 0; y < H0; y++) {
RGB p0(im0->GetPixel(x, y));
RGB p1(im1->GetPixel(x, y));
RGB p2 = (a*p0) + (b*p1);
Color pixel2 = Color::FromArgb(p2.R, p2.G, p2.B);
im2.SetPixel(x, y, pixel2);
}
im2.Save("blend.png");
cout << "blend.png圖好了。\n";
}
int main()
{
Bitmap^im0 = gcnew Bitmap("rabbit.jpg");
Bitmap^im1 = gcnew Bitmap("8.jpg");
double a = 0.9, b = 0.1;
blend(im0, im1, a, b);
cout << "浮水印\n";
system("Pause");
return 0;
}
#include <iostream>
#include <cstdlib>
using namespace std;
#using <System.Drawing.dll>
using namespace System::Drawing;
struct RGB {
int R, G, B;
RGB() {}
RGB(int R, int G, int B) :R(R), G(G), B(B) {}
RGB(Color p) {
R = p.R; G = p.G; B = p.B;
}
};
int clamp(int X, int L, int U) {
if (X < L)return L;
else if (X > U)return U;
else return X;
}
RGB operator+(RGB p1, RGB p2) {
return RGB(clamp(p1.R + p2.R, 0, 255), clamp(p1.G + p2.G, 0, 255), clamp(p1.B + p2.B, 0, 255));
}
RGB operator*(double a, RGB p) {
return RGB(clamp(p.R*a, 0, 255), clamp(p.G*a, 0, 255), clamp(p.B*a, 0, 255));
}
void blend (Bitmap^im0, Bitmap^im1,double a, double b){
int H0 = im0->Height, W0 = im0->Width;
int H1 = im1->Height, W1 = im1->Width;
if (H0 != H1 || W0 != W1) { cout << "大小不合\n"; return; }
Bitmap im2(W0, H0);
for (int x = 0; x < W0; x++)
for (int y = 0; y < H0; y++) {
RGB p0(im0->GetPixel(x, y));
RGB p1(im1->GetPixel(x, y));
RGB p2 = (a*p0) + (b*p1);
Color pixel2 = Color::FromArgb(p2.R, p2.G, p2.B);
im2.SetPixel(x, y, pixel2);
}
im2.Save("blend.png");
cout << "blend.png圖好了。\n";
}
int main()
{
Bitmap^im0 = gcnew Bitmap("rabbit.jpg");
Bitmap^im1 = gcnew Bitmap("8.jpg");
double a = 0.9, b = 0.1;
blend(im0, im1, a, b);
cout << "浮水印\n";
system("Pause");
return 0;
}
#include <iostream>
#include <cstdlib>
using namespace std;
#using <System.Drawing.dll>
using namespace System::Drawing;
struct RGB {
int R, G, B;
RGB() {}
RGB(int R, int G, int B) :R(R), G(G), B(B) {}
RGB(Color p) {
R = p.R; G = p.G; B = p.B;
}
};
int clamp(int X, int L, int U) {
if (X < L)return L;
else if (X > U)return U;
else return X;
}
RGB operator+(RGB p1, RGB p2) {
return RGB(clamp(p1.R + p2.R, 0, 255), clamp(p1.G + p2.G, 0, 255), clamp(p1.B + p2.B, 0, 255));
}
RGB operator*(double a, RGB p) {
return RGB(clamp(p.R*a, 0, 255), clamp(p.G*a, 0, 255), clamp(p.B*a, 0, 255));
}
void blend (Bitmap^im0, Bitmap^im1,double a, double b){
int H0 = im0->Height, W0 = im0->Width;
int H1 = im1->Height, W1 = im1->Width;
if (H0 != H1 || W0 != W1) { cout << "大小不合\n"; return; }
Bitmap im2(W0, H0);
for (int x = 0; x < W0; x++)
for (int y = 0; y < H0; y++) {
RGB p0(im0->GetPixel(x, y));
RGB p1(im1->GetPixel(x, y));
RGB p2 = (a*p0) + (b*p1);
Color pixel2 = Color::FromArgb(p2.R, p2.G, p2.B);
im2.SetPixel(x, y, pixel2);
}
im2.Save("blend.png");
cout << "blend.png圖好了。\n";
}
int main()
{
Bitmap^im0 = gcnew Bitmap("rabbit.jpg");
Bitmap^im1 = gcnew Bitmap("8.jpg");
double a = 0.9, b = 0.1;
blend(im0, im1, a, b);
cout << "浮水印\n";
system("Pause");
return 0;
}
#include <iostream>
#include <cstdlib>
using namespace std;
#using <System.Drawing.dll>
using namespace System::Drawing;
struct RGB {
int R, G, B;
RGB() {}
RGB(int R, int G, int B) :R(R), G(G), B(B) {}
RGB(Color p) {
R = p.R; G = p.G; B = p.B;
}
};
int clamp(int X, int L, int U) {
if (X < L)return L;
else if (X > U)return U;
else return X;
}
RGB operator+(RGB p1, RGB p2) {
return RGB(clamp(p1.R + p2.R, 0, 255), clamp(p1.G + p2.G, 0, 255), clamp(p1.B + p2.B, 0, 255));
}
RGB operator*(double a, RGB p) {
return RGB(clamp(p.R*a, 0, 255), clamp(p.G*a, 0, 255), clamp(p.B*a, 0, 255));
}
void blend (Bitmap^im0, Bitmap^im1,double a, double b){
int H0 = im0->Height, W0 = im0->Width;
int H1 = im1->Height, W1 = im1->Width;
if (H0 != H1 || W0 != W1) { cout << "大小不合\n"; return; }
Bitmap im2(W0, H0);
for (int x = 0; x < W0; x++)
for (int y = 0; y < H0; y++) {
RGB p0(im0->GetPixel(x, y));
RGB p1(im1->GetPixel(x, y));
RGB p2 = (a*p0) + (b*p1);
Color pixel2 = Color::FromArgb(p2.R, p2.G, p2.B);
im2.SetPixel(x, y, pixel2);
}
im2.Save("blend.png");
cout << "blend.png圖好了。\n";
}
int main()
{
Bitmap^im0 = gcnew Bitmap("rabbit.jpg");
Bitmap^im1 = gcnew Bitmap("8.jpg");
double a = 0.9, b = 0.1;
blend(im0, im1, a, b);
cout << "浮水印\n";
system("Pause");
return 0;
}
#include <iostream>
#include <cstdlib>
using namespace std;
#using <System.Drawing.dll>
using namespace System::Drawing;
struct RGB {
int R, G, B;
RGB() {}
RGB(int R, int G, int B) :R(R), G(G), B(B) {}
RGB(Color p) {
R = p.R; G = p.G; B = p.B;
}
};
int clamp(int X, int L, int U) {
if (X < L)return L;
else if (X > U)return U;
else return X;
}
RGB operator+(RGB p1, RGB p2) {
return RGB(clamp(p1.R + p2.R, 0, 255), clamp(p1.G + p2.G, 0, 255), clamp(p1.B + p2.B, 0, 255));
}
RGB operator*(double a, RGB p) {
return RGB(clamp(p.R*a, 0, 255), clamp(p.G*a, 0, 255), clamp(p.B*a, 0, 255));
}
void blend (Bitmap^im0, Bitmap^im1,double a, double b){
int H0 = im0->Height, W0 = im0->Width;
int H1 = im1->Height, W1 = im1->Width;
if (H0 != H1 || W0 != W1) { cout << "大小不合\n"; return; }
Bitmap im2(W0, H0);
for (int x = 0; x < W0; x++)
for (int y = 0; y < H0; y++) {
RGB p0(im0->GetPixel(x, y));
RGB p1(im1->GetPixel(x, y));
RGB p2 = (a*p0) + (b*p1);
Color pixel2 = Color::FromArgb(p2.R, p2.G, p2.B);
im2.SetPixel(x, y, pixel2);
}
im2.Save("blend.png");
cout << "blend.png圖好了。\n";
}
int main()
{
Bitmap^im0 = gcnew Bitmap("rabbit.jpg");
Bitmap^im1 = gcnew Bitmap("8.jpg");
double a = 0.9, b = 0.1;
blend(im0, im1, a, b);
cout << "浮水印\n";
system("Pause");
return 0;
}
#include <iostream>
#include <cstdlib>
using namespace std;
#using <System.Drawing.dll>
using namespace System::Drawing;
struct RGB {
int R, G, B;
RGB() {}
RGB(int R, int G, int B) :R(R), G(G), B(B) {}
RGB(Color p) {
R = p.R; G = p.G; B = p.B;
}
};
int clamp(int X, int L, int U) {
if (X < L)return L;
else if (X > U)return U;
else return X;
}
RGB operator+(RGB p1, RGB p2) {
return RGB(clamp(p1.R + p2.R, 0, 255), clamp(p1.G + p2.G, 0, 255), clamp(p1.B + p2.B, 0, 255));
}
RGB operator*(double a, RGB p) {
return RGB(clamp(p.R*a, 0, 255), clamp(p.G*a, 0, 255), clamp(p.B*a, 0, 255));
}
void blend (Bitmap^im0, Bitmap^im1,double a, double b){
int H0 = im0->Height, W0 = im0->Width;
int H1 = im1->Height, W1 = im1->Width;
if (H0 != H1 || W0 != W1) { cout << "大小不合\n"; return; }
Bitmap im2(W0, H0);
for (int x = 0; x < W0; x++)
for (int y = 0; y < H0; y++) {
RGB p0(im0->GetPixel(x, y));
RGB p1(im1->GetPixel(x, y));
RGB p2 = (a*p0) + (b*p1);
Color pixel2 = Color::FromArgb(p2.R, p2.G, p2.B);
im2.SetPixel(x, y, pixel2);
}
im2.Save("blend.png");
cout << "blend.png圖好了。\n";
}
int main()
{
Bitmap^im0 = gcnew Bitmap("rabbit.jpg");
Bitmap^im1 = gcnew Bitmap("8.jpg");
double a = 0.9, b = 0.1;
blend(im0, im1, a, b);
cout << "浮水印\n";
system("Pause");
return 0;
}
RGB operator+(RGB p1, RGB p2) {
return RGB(clamp(p1.R + p2.R,0, 255),
clamp(p1,G +p2.G,0, 255),
clamp(p1,B +p2.B,0, 255)),
}
RGB operator*(double a, RGB p) {
return RGB(clamp(p.R*a,0,255),
clamp(p.G*a,0,255),.
clamp(p.B*a,0,255),
}
void blend(Bitmap^ im0, Bitmap^ im1, doublea, double b) {
int H0= im0->Height,W0 =im0->width;
int H1= im1->Height,W1 =im1->width;
if (H0 ! H1 ||=w1) { cout<< "大小不合\n"; return ; }
Bitmap im2(w0,H0);
for (int x=0; x<w0; x++)
//RGB + 的方法
RGB operator+(RGB p1, RGB p2) {
int r = Clamp(p1.R + p2.R, 0, 255);
int g = Clamp(p1.G + p2.G, 0, 255);
int b = Clamp(p1.B + p2.B, 0, 255);
return RGB(r, g, b);
}
//RGB * 的方法
RGB operator*(double a , RGB p) {
int r = Clamp((int)(p.R * a), 0, 255);
int g = Clamp((int)(p.G * a), 0, 255);
int b = Clamp((int)(p.B * a), 0, 255);
return RGB(r, g, b);
}
//浮水印方法
void image_blend(Bitmap^ im0, Bitmap^ im1, double alpha, double beta) {
//宣告H0,H1,W0,W1 來得到兩張圖的長 跟 寬
int H0 = im0->Height, W0 = im0->Width;
int H1 = im1->Height, W1 = im1->Width;
// 判斷如果兩張圖大小不一樣就跳出程式
if (H0 != H1 || W0 != W1) {
cout << "兩圖大小不合。\n";
return;
}
//宣告物件Bitmap im2 來存浮水印的結果 成為另一張圖 blend.png
Bitmap im2(W0, H0);
Color Black = Color::FromArgb(0, 0, 0);
//兩層迴圈來得到 第一張圖 跟第二張圖(要成為浮水印的圖) 的每個Pixel
for (int x = 0; x < W0; x++) {
for (int y = 0; y < H0; y++)
{
Color p0 = im0->GetPixel(x, y);
Color p1 = im1->GetPixel(x, y);
//浮水印公式 (a*im0)+(b*im1)
// alpha,beta 色彩彩度
RGB pp = (alpha*p0) + (beta*p1);
//公式算好後 存在一個新宣告物件的顏色 pixel2
//pp.R pp.G pp.B 是 浮水應公式計算後的顏色
Color pixel2 = Color::FromArgb(pp.R, pp.G, pp.B);
//再來設定im2每個點(x,y)的顏色(pixel2)
im2.SetPixel(x, y, pixel2);
}
}
//迴圈計算好後另存一個圖檔
im2.Save("blend.png");
cout << "blend.png圖檔產生\n";
}
#include
#include
using namespace std;
#using
using namespace System::Drawing;
struct RGB {
int R, G, B;
RGB() {}
RGB(int R, int G, int B) :R(R), G(G), B(B) {}
RGB(Color p) {
R = p.R; G = p.G; B = p.B;
}
};
int clamp(int X, int L, int U) {
if (X < L)return L;
else if (X > U)return U;
else return X;
}
RGB operator+(RGB p1, RGB p2) {
return RGB(clamp(p1.R + p2.R, 0, 255), clamp(p1.G + p2.G, 0, 255), clamp(p1.B + p2.B, 0, 255));
}
RGB operator*(double a, RGB p) {
return RGB(clamp(p.R*a, 0, 255), clamp(p.G*a, 0, 255), clamp(p.B*a, 0, 255));
}
void blend (Bitmap^im0, Bitmap^im1,double a, double b){
int H0 = im0->Height, W0 = im0->Width;
int H1 = im1->Height, W1 = im1->Width;
if (H0 != H1 || W0 != W1) { cout << "大小不合\n"; return; }
Bitmap im2(W0, H0);
for (int x = 0; x < W0; x++)
for (int y = 0; y < H0; y++) {
RGB p0(im0->GetPixel(x, y));
RGB p1(im1->GetPixel(x, y));
RGB p2 = (a*p0) + (b*p1);
Color pixel2 = Color::FromArgb(p2.R, p2.G, p2.B);
im2.SetPixel(x, y, pixel2);
}
im2.Save("blend.png");
cout << "blend.png圖好了。\n";
}
int main()
{
Bitmap^im0 = gcnew Bitmap("rabbit.jpg");
Bitmap^im1 = gcnew Bitmap("8.jpg");
double a = 0.9, b = 0.1;
blend(im0, im1, a, b);
cout << "浮水印\n";
system("Pause");
return 0;
}
#include
#include
using namespace std;
#using
using namespace System::Drawing;
struct RGB {
int R, G, B;
RGB() {}
RGB(int R, int G, int B) :R(R), G(G), B(B) {}
RGB(Color p) {
R = p.R; G = p.G; B = p.B;
}
};
int clamp(int X, int L, int U) {
if (X < L)return L;
else if (X > U)return U;
else return X;
}
RGB operator+(RGB p1, RGB p2) {
return RGB(clamp(p1.R + p2.R, 0, 255), clamp(p1.G + p2.G, 0, 255), clamp(p1.B + p2.B, 0, 255));
}
RGB operator*(double a, RGB p) {
return RGB(clamp(p.R*a, 0, 255), clamp(p.G*a, 0, 255), clamp(p.B*a, 0, 255));
}
void blend (Bitmap^im0, Bitmap^im1,double a, double b){
int H0 = im0->Height, W0 = im0->Width;
int H1 = im1->Height, W1 = im1->Width;
if (H0 != H1 || W0 != W1) { cout << "大小不合\n"; return; }
Bitmap im2(W0, H0);
for (int x = 0; x < W0; x++)
for (int y = 0; y < H0; y++) {
RGB p0(im0->GetPixel(x, y));
RGB p1(im1->GetPixel(x, y));
RGB p2 = (a*p0) + (b*p1);
Color pixel2 = Color::FromArgb(p2.R, p2.G, p2.B);
im2.SetPixel(x, y, pixel2);
}
im2.Save("blend.png");
cout << "blend.png圖好了。\n";
}
int main()
{
Bitmap^im0 = gcnew Bitmap("rabbit.jpg");
Bitmap^im1 = gcnew Bitmap("8.jpg");
double a = 0.9, b = 0.1;
blend(im0, im1, a, b);
cout << "浮水印\n";
system("Pause");
return 0;
}
#include
#include
using namespace std;
#using
using namespace System::Drawing;
struct RGB {
int R, G, B;
RGB() {}
RGB(int R, int G, int B) :R(R), G(G), B(B) {}
RGB(Color p) {
R = p.R; G = p.G; B = p.B;
}
};
int clamp(int X, int L, int U) {
if (X < L)return L;
else if (X > U)return U;
else return X;
}
RGB operator+(RGB p1, RGB p2) {
return RGB(clamp(p1.R + p2.R, 0, 255), clamp(p1.G + p2.G, 0, 255), clamp(p1.B + p2.B, 0, 255));
}
RGB operator*(double a, RGB p) {
return RGB(clamp(p.R*a, 0, 255), clamp(p.G*a, 0, 255), clamp(p.B*a, 0, 255));
}
void blend (Bitmap^im0, Bitmap^im1,double a, double b){
int H0 = im0->Height, W0 = im0->Width;
int H1 = im1->Height, W1 = im1->Width;
if (H0 != H1 || W0 != W1) { cout << "大小不合\n"; return; }
Bitmap im2(W0, H0);
for (int x = 0; x < W0; x++)
for (int y = 0; y < H0; y++) {
RGB p0(im0->GetPixel(x, y));
RGB p1(im1->GetPixel(x, y));
RGB p2 = (a*p0) + (b*p1);
Color pixel2 = Color::FromArgb(p2.R, p2.G, p2.B);
im2.SetPixel(x, y, pixel2);
}
im2.Save("blend.png");
cout << "blend.png圖好了。\n";
}
int main()
{
Bitmap^im0 = gcnew Bitmap("rabbit.jpg");
Bitmap^im1 = gcnew Bitmap("8.jpg");
double a = 0.9, b = 0.1;
blend(im0, im1, a, b);
cout << "浮水印\n";
system("Pause");
return 0;
}
RGB operator+(RGB p1, RGB p2) {
int r = Clamp(p1.R + p2.R, 0, 255);
int g = Clamp(p1.G + p2.G, 0, 255);
int b = Clamp(p1.B + p2.B, 0, 255);
return RGB(r, g, b);
}
RGB operator*(double alpha, RGB p) {
int r = Clamp((int)(p.R*alpha), 0, 255);
int g = Clamp((int)(p.G*alpha), 0, 255);
int b = Clamp((int)(p.B*alpha), 0, 255);
return RGB(r, g, b);
}
void image_blend(Bitmap^im0, Bitmap^im1, double alpha, double beta) {
int W0 = im0->Width, H0 = im0->Height;
int W1 = im1->Width, H1 = im1->Height;
if (W1 != W0 || H1 != H0) {
cout << "圖大小不合。\n";
return;
}
Bitmap im2(W0, H0);
Color Black = Color::FromArgb(0, 0, 0);
for (int x=0 ; xGetPixel(x, y);
Color p1 = im1->GetPixel(x, y);
RGB pp = (alpha*RGB(p0)) + (beta*RGB(p1));
Color pixel2 = Color::FromArgb(pp.R,pp.G,pp.B);
im2.SetPixel(x, y, pixel2);
}
im2.Save("blend.png");
cout << "blend.png圖檔產生\n";
}
RGB operator+(RGB p1,RGB p2) {
int r = Clamp(p1.R + p2.R, 0, 255);
int g = Clamp(p1.G + p2.G, 0, 255);
int b = Clamp(p1.B + p2.B, 0, 255);
return RGB(r, g, b);
}
RGB operator*(double alpha, RGB p) {
int r = Clamp((int)(p.R*alpha), 0, 255);
int g = Clamp((int)(p.G*alpha), 0, 255);
int b = Clamp((int)(p.B*alpha), 0, 255);
return RGB(r, g, b);
}
void image_blend(Bitmap^im0,Bitmap^im1,double alpha,double beta) {
int W0 = im0->Width, H0 = im0->Height;
int W1 = im1->Width, H1 = im1->Height;
if (W1 != W0 || H1 != H0) {
cout << "圖大小不合\n";
return;
}
Bitmap im2(W0, H0);
Color Black = Color::FromArgb(0, 0, 0);
for(int x=0;xGetPixel(x, y);
Color p1 = im1->GetPixel(x, y);
RGB pp = (alpha*RGB(p0)) + (beta*RGB(p1));
Color pixel2 = Color::FromArgb(pp.R, pp.G, pp.B);
im2.SetPixel(x, y, pixel2);
}
im2.Save("ROGOOD.png");
cout << "RO圖檔產生\n";
}
RGB operator+(RGB p1, RGB p2) {
int r = Clamp(p1.R + p2.R, 0, 255);
int g = Clamp(p1.G + p2.G, 0, 255);
int b = Clamp(p1.B + p2.B, 0, 255);
return RGB(r, g, b);
}
RGB operator*(double alpha, RGB p) {
int r = Clamp((int)(p.R*alpha), 0, 255);
int g = Clamp((int)(p.G*alpha), 0, 255);
int b = Clamp((int)(p.B*alpha), 0, 255);
return RGB(r, g, b);
}
void image_blend(Bitmap^im0, Bitmap^im1, double alpha, double beta) {
int W0 = im0->Width, H0 = im0->Height;
int W1 = im1->Width, H1 = im1->Height;
if (W1 != W0 || H1 != H0) {
cout << "圖大小不合。\n";
return;
}
Bitmap im2(W0, H0);
Color Black = Color::FromArgb(0, 0, 0);
for (int x=0 ; xGetPixel(x, y);
Color p1 = im1->GetPixel(x, y);
RGB pp = (alpha*RGB(p0)) + (beta*RGB(p1));
Color pixel2 = Color::FromArgb(pp.R,pp.G,pp.B);
im2.SetPixel(x, y, pixel2);
}
im2.Save("blend.png");
cout << "blend.png圖檔產生\n";
}
RGB operator+(RGB p1, RGB p2) {
int r = Clamp(p1.R + p2.R, 0, 255);
int g = Clamp(p1.G + p2.G, 0, 255);
int b = Clamp(p1.B + p2.B, 0, 255);
return RGB(r, g, b);
}
RGB operator*(double alpha, RGB p) {
int r = Clamp((int)(p.R*alpha), 0, 255);
int g = Clamp((int)(p.G*alpha), 0, 255);
int b = Clamp((int)(p.B*alpha), 0, 255);
return RGB(r, g, b);
}
void image_blend(Bitmap^im0, Bitmap^im1, double alpha, double beta) {
int W0 = im0->Width, H0 = im0->Height;
int W1 = im1->Width, H1 = im1->Height;
if (W1 != W0 || H1 != H0) {
cout << "圖大小不合。\n";
return;
}
Bitmap im2(W0, H0);
Color Black = Color::FromArgb(0, 0, 0);
for (int x=0 ; xGetPixel(x, y);
Color p1 = im1->GetPixel(x, y);
RGB pp = (alpha*RGB(p0)) + (beta*RGB(p1));
Color pixel2 = Color::FromArgb(pp.R,pp.G,pp.B);
im2.SetPixel(x, y, pixel2);
}
im2.Save("blend.png");
cout << "blend.png圖檔產生\n";
}
RGB operator+(RGB p1, RGB p2) {
int r = Clamp(p1.R + p2.R, 0, 255);
int g = Clamp(p1.G + p2.G, 0, 255);
int b = Clamp(p1.B + p2.B, 0, 255);
return RGB(r, g, b);
}
RGB operator*(double alpha, RGB p) {
int r = Clamp((int)(p.R*alpha), 0, 255);
int g = Clamp((int)(p.G*alpha), 0, 255);
int b = Clamp((int)(p.B*alpha), 0, 255);
return RGB(r, g, b);
}
void image_blend(Bitmap^im0, Bitmap^im1, double alpha, double beta) {
int W0 = im0->Width, H0 = im0->Height;
int W1 = im1->Width, H1 = im1->Height;
if (W1 != W0 || H1 != H0) {
cout << "圖大小不合。\n";
return;
}
Bitmap im2(W0, H0);
Color Black = Color::FromArgb(0, 0, 0);
for (int x=0 ; xGetPixel(x, y);
Color p1 = im1->GetPixel(x, y);
RGB pp = (alpha*RGB(p0)) + (beta*RGB(p1));
Color pixel2 = Color::FromArgb(pp.R,pp.G,pp.B);
im2.SetPixel(x, y, pixel2);
}
im2.Save("blend.png");
cout << "blend.png圖檔產生\n";
}
張貼留言