herrDeng網內搜尋
自訂搜尋
Ads
訂閱:
張貼留言 (Atom)
熱門文章
-
教育部為提昇全民資安素養與電腦防護能力,本部於101年9月5日至11月5日舉辦「全民資安素養自我評量」活動,請在活動期間內踴躍上網檢測資訊安全素養認知程度,並有機會參與抽獎,詳情請參閱活動網站(網址: https://isafe.moe.edu.tw/event
-
url="https://www.twse.com.tw/exchangeReport/STOCK_DAY?response=json&date=20220330&stockNo=2330"
-
先說明一下這是後知後覺的解答,所謂後知就是股票價格已知存在陣列(清單),當然就要用迴圈練習,雙迴圈暴力解需時O(n**2),當然不用,採python單一迴圈解答「最佳股票的買賣時機#LeetCode 121 Best Time to Buy and Sell Stock」,解...
-
你會用C的算子sizeof?
-
XOR prefixsum CPP python解Leetcode 1829 Maximum XOR for Each Query 其實這裡考慮的是元素個數為2^maximumBit的交換群,運算子為XOR。 [Python code請進]
-
Python C++使用字串find迴圈速解Leetcode 2490 Circular Sentence C++ & Python都有字串的find,用法都類似 split=s.find(' ', split+1)能找到s從index=split+1開...
51 則留言:
#include<iostream>
#include<cstdlib>
using namespace std;
#using <System.Drawing.dll>
using namespace System::Drawing;
void to_Gray(Bitmap^im) {
int W = im->Width, H = im->Height;
cout << "w=" << W << "H=" << H << endl;
double c = W / 2.0;
double r = c;
Color p2,Black = Color::FromArgb(0, 0, 0);
Bitmap im2(W, H);
for(int x=0;x<W;x++)
for (int y = 0; y < H; y++) {
Color pixel = im -> GetPixel(x,y);
int R = pixel.R, G = pixel.G, B = pixel.B;
if ((x - c)*(x - c) + (y - c)*(y - c) <= r*r) {
Color p2 = Color::FromArgb(R, G, B);
im2.SetPixel(x, y, p2);
}
else {
im2.SetPixel(x, y,Black);
}
}
im2.Save("Disk_Black.png");
im2.MakeTransparent(Black);
im2.Save("Disk.png");
}
int main()
{
Bitmap^ im = gcnew Bitmap("tiffany511.jpg");
to_Gray(im);
cout << "圖像練習\n";
system("Pause");
return 0;
}
void to_DIsk(Bitmap^ im) {
int W = im->Width, H = im->Height;
if (W != H) {
cout << "非方圖\n";
return;
}
double c = W / 2.0;
double r = c;
Bitmap im2(W, H);
Color p2, Black = Color::FromArgb(0, 0, 0);
for (int x = 0; x<W; x++)
for (int y = 0; y < H; y++) {
Color pixel = im->GetPixel(x, y);
int R =pixel.R, G =pixel.G, B =pixel.B;
if ((x - c)*(x - c) + (y - c)*(y - c) <= r*r) {
p2 = Color::FromArgb(R, G, B);
im2.SetPixel(x, y, p2);
}
else {
im2.SetPixel(x, y, Black);
}
}
im2.Save("Dask_Black.png");
im2.MakeTransparent(Black);
im2.Save("Dask.png");
cout << "圓圖好了\n";
}
void to_Gray(Bitmap^im)
{
int W = im->Width, H = im->Height;
cout << "W=" << W << "H=" << H << endl;
Bitmap im2(W, H);
for (int x = 0; x<W; x++)
for (int y = 0; y < H; y++) {
Color pixel = im->GetPixel(x, y);
int R = pixel.R, G = pixel.G, B = pixel.B;
int Gray = (R * 313524 + G * 615514 + B * 119538) >> 20;
Color p2 = Color::FromArgb(Gray, Gray, Gray);
im2.SetPixel(x, y, p2);
}
im2.Save("Gray.png");
}
void to_CC(Bitmap^im)
{
int W = im->Width, H = im->Height;
cout << "W=" << W << "H=" << H << endl;
Bitmap im2(W, H);
for (int x = 0; x<W; x++)
for (int y = 0; y < H; y++) {
Color pixel = im->GetPixel(x, y);
int R = 255 - pixel.R, G = 255 - pixel.G, B =255- pixel.B;
Color p2 = Color::FromArgb(R, G, B);
im2.SetPixel(x, y, p2);
}
im2.Save("G.png");
}
void to_Disk(Bitmap^im) {
int W = im->Width, H = im->Height;
if (W != H) {
cout << "非方圖\n";
return;
}
double c = W / 2.0;
double r = c;
Bitmap im2(W, H);
Color p2, Black = Color::FromArgb(0, 0, 0);
for (int x = 0; x < W; x++)
for (int y = 0; y < H; y++) {
Color pixel = im->GetPixel(x, y);
int R = pixel.R, G = pixel.G, B = pixel.B;
if ((x - c)*(x - c) + (y - c)*(y - c) <= r*r) {
p2 = Color::FromArgb(R, G, B);
im2.SetPixel(x, y, p2);
}
else {
im2.SetPixel(x, y, Black);
}
}
im2.Save("Disk_Black.png");
im2.MakeTransparent(Black);
im2.Save("Disk.png");
cout << "圖圓好了\n";
}
void to_Gray(Bitmap^im)
{
int W = im->Width, H = im->Height;
cout << "W=" << W << "H=" << H << endl;
Bitmap im2(W, H);
for (int x = 0; x<W; x++)
for (int y = 0; y < H; y++) {
Color pixel = im->GetPixel(x, y);
int R = pixel.R, G = pixel.G, B = pixel.B;
int Gray = (R * 313524 + G * 615514 + B * 119538) >> 20;
Color p2 = Color::FromArgb(Gray, Gray, Gray);
im2.SetPixel(x, y, p2);
}
im2.Save("Gray.png");
}
void to_CC(Bitmap^im)
{
int W = im->Width, H = im->Height;
cout << "W=" << W << "H=" << H << endl;
Bitmap im2(W, H);
for (int x = 0; x<W; x++)
for (int y = 0; y < H; y++) {
Color pixel = im->GetPixel(x, y);
int R = 255 - pixel.R, G = 255 - pixel.G, B =255- pixel.B;
Color p2 = Color::FromArgb(R, G, B);
im2.SetPixel(x, y, p2);
}
im2.Save("G.png");
}
void to_Disk(Bitmap^im) {
int W = im->Width, H = im->Height;
if (W != H) {
cout << "非方圖\n";
return;
}
double c = W / 2.0;
double r = c;
Bitmap im2(W, H);
Color p2, Black = Color::FromArgb(0, 0, 0);
for (int x = 0; x < W; x++)
for (int y = 0; y < H; y++) {
Color pixel = im->GetPixel(x, y);
int R = pixel.R, G = pixel.G, B = pixel.B;
if ((x - c)*(x - c) + (y - c)*(y - c) <= r*r) {
p2 = Color::FromArgb(R, G, B);
im2.SetPixel(x, y, p2);
}
else {
im2.SetPixel(x, y, Black);
}
}
im2.Save("Disk_Black.png");
im2.MakeTransparent(Black);
im2.Save("Disk.png");
cout << "圖圓好了\n";
}
void to_Gray(Bitmap^im)
{
int W = im->Width, H = im->Height;
cout << "W=" << W << "H=" << H << endl;
Bitmap im2(W, H);
for (int x = 0; x<W; x++)
for (int y = 0; y < H; y++) {
Color pixel = im->GetPixel(x, y);
int R = pixel.R, G = pixel.G, B = pixel.B;
int Gray = (R * 313524 + G * 615514 + B * 119538) >> 20;
Color p2 = Color::FromArgb(Gray, Gray, Gray);
im2.SetPixel(x, y, p2);
}
im2.Save("Gray.png");
}
void to_CC(Bitmap^im)
{
int W = im->Width, H = im->Height;
cout << "W=" << W << "H=" << H << endl;
Bitmap im2(W, H);
for (int x = 0; x<W; x++)
for (int y = 0; y < H; y++) {
Color pixel = im->GetPixel(x, y);
int R = 255 - pixel.R, G = 255 - pixel.G, B =255- pixel.B;
Color p2 = Color::FromArgb(R, G, B);
im2.SetPixel(x, y, p2);
}
im2.Save("G.png");
}
void to_Disk(Bitmap^im) {
int W = im->Width, H = im->Height;
if (W != H) {
cout << "非方圖\n";
return;
}
double c = W / 2.0;
double r = c;
Bitmap im2(W, H);
Color p2, Black = Color::FromArgb(0, 0, 0);
for (int x = 0; x < W; x++)
for (int y = 0; y < H; y++) {
Color pixel = im->GetPixel(x, y);
int R = pixel.R, G = pixel.G, B = pixel.B;
if ((x - c)*(x - c) + (y - c)*(y - c) <= r*r) {
p2 = Color::FromArgb(R, G, B);
im2.SetPixel(x, y, p2);
}
else {
im2.SetPixel(x, y, Black);
}
}
im2.Save("Disk_Black.png");
im2.MakeTransparent(Black);
im2.Save("Disk.png");
cout << "圖圓好了\n";
}
void to_Gray(Bitmap^im)
{
int W = im->Width, H = im->Height;
cout << "W=" << W << "H=" << H << endl;
Bitmap im2(W, H);
for (int x = 0; x<W; x++)
for (int y = 0; y < H; y++) {
Color pixel = im->GetPixel(x, y);
int R = pixel.R, G = pixel.G, B = pixel.B;
int Gray = (R * 313524 + G * 615514 + B * 119538) >> 20;
Color p2 = Color::FromArgb(Gray, Gray, Gray);
im2.SetPixel(x, y, p2);
}
im2.Save("Gray.png");
}
void to_CC(Bitmap^im)
{
int W = im->Width, H = im->Height;
cout << "W=" << W << "H=" << H << endl;
Bitmap im2(W, H);
for (int x = 0; x<W; x++)
for (int y = 0; y < H; y++) {
Color pixel = im->GetPixel(x, y);
int R = 255 - pixel.R, G = 255 - pixel.G, B =255- pixel.B;
Color p2 = Color::FromArgb(R, G, B);
im2.SetPixel(x, y, p2);
}
im2.Save("G.png");
}
void to_Disk(Bitmap^im) {
int W = im->Width, H = im->Height;
if (W != H) {
cout << "非方圖\n";
return;
}
double c = W / 2.0;
double r = c;
Bitmap im2(W, H);
Color p2, Black = Color::FromArgb(0, 0, 0);
for (int x = 0; x < W; x++)
for (int y = 0; y < H; y++) {
Color pixel = im->GetPixel(x, y);
int R = pixel.R, G = pixel.G, B = pixel.B;
if ((x - c)*(x - c) + (y - c)*(y - c) <= r*r) {
p2 = Color::FromArgb(R, G, B);
im2.SetPixel(x, y, p2);
}
else {
im2.SetPixel(x, y, Black);
}
}
im2.Save("Disk_Black.png");
im2.MakeTransparent(Black);
im2.Save("Disk.png");
cout << "圖圓好了\n";
}
void to_Gray(Bitmap^im)
{
int W = im->Width, H = im->Height;
cout << "W=" << W << "H=" << H << endl;
Bitmap im2(W, H);
for (int x = 0; x<W; x++)
for (int y = 0; y < H; y++) {
Color pixel = im->GetPixel(x, y);
int R = pixel.R, G = pixel.G, B = pixel.B;
int Gray = (R * 313524 + G * 615514 + B * 119538) >> 20;
Color p2 = Color::FromArgb(Gray, Gray, Gray);
im2.SetPixel(x, y, p2);
}
im2.Save("Gray.png");
}
void to_CC(Bitmap^im)
{
int W = im->Width, H = im->Height;
cout << "W=" << W << "H=" << H << endl;
Bitmap im2(W, H);
for (int x = 0; x<W; x++)
for (int y = 0; y < H; y++) {
Color pixel = im->GetPixel(x, y);
int R = 255 - pixel.R, G = 255 - pixel.G, B =255- pixel.B;
Color p2 = Color::FromArgb(R, G, B);
im2.SetPixel(x, y, p2);
}
im2.Save("G.png");
}
void to_Disk(Bitmap^im) {
int W = im->Width, H = im->Height;
if (W != H) {
cout << "非方圖\n";
return;
}
double c = W / 2.0;
double r = c;
Bitmap im2(W, H);
Color p2, Black = Color::FromArgb(0, 0, 0);
for (int x = 0; x < W; x++)
for (int y = 0; y < H; y++) {
Color pixel = im->GetPixel(x, y);
int R = pixel.R, G = pixel.G, B = pixel.B;
if ((x - c)*(x - c) + (y - c)*(y - c) <= r*r) {
p2 = Color::FromArgb(R, G, B);
im2.SetPixel(x, y, p2);
}
else {
im2.SetPixel(x, y, Black);
}
}
im2.Save("Disk_Black.png");
im2.MakeTransparent(Black);
im2.Save("Disk.png");
cout << "圖圓好了\n";
}
void to_Gray(Bitmap^ im)
{
int W = im->Width, H = im->Height;
Bitmap im2(W, H);
for(int x=0; xGetPixel(x, y);
int R=pixel.R, G=pixel.G, B= pixel.B;
int Gray = (R * 313524 + G * 615514 + B * 119538) >> 20;
Color p2 = Color::FromArgb(Gray, Gray, Gray);
im2.SetPixel(x, y, p2);
}
im2.Save("Gray.png");
cout << "灰階圖好了\n";
}
void to_Gray(Bitmap^im)
{
int W = im->Width, H = im->Height;
cout << "W=" << W << "H=" << H << endl;
Bitmap im2(W, H);
for (int x = 0; x<W; x++)
for (int y = 0; y < H; y++) {
Color pixel = im->GetPixel(x, y);
int R = pixel.R, G = pixel.G, B = pixel.B;
int Gray = (R * 313524 + G * 615514 + B * 119538) >> 20;
Color p2 = Color::FromArgb(Gray, Gray, Gray);
im2.SetPixel(x, y, p2);
}
im2.Save("Gray.png");
}
void to_CC(Bitmap^im)
{
int W = im->Width, H = im->Height;
cout << "W=" << W << "H=" << H << endl;
Bitmap im2(W, H);
for (int x = 0; x<W; x++)
for (int y = 0; y < H; y++) {
Color pixel = im->GetPixel(x, y);
int R = 255 - pixel.R, G = 255 - pixel.G, B =255- pixel.B;
Color p2 = Color::FromArgb(R, G, B);
im2.SetPixel(x, y, p2);
}
im2.Save("G.png");
}
void to_Disk(Bitmap^im) {
int W = im->Width, H = im->Height;
if (W != H) {
cout << "非方圖\n";
return;
}
double c = W / 2.0;
double r = c;
Bitmap im2(W, H);
Color p2, Black = Color::FromArgb(0, 0, 0);
for (int x = 0; x < W; x++)
for (int y = 0; y < H; y++) {
Color pixel = im->GetPixel(x, y);
int R = pixel.R, G = pixel.G, B = pixel.B;
if ((x - c)*(x - c) + (y - c)*(y - c) <= r*r) {
p2 = Color::FromArgb(R, G, B);
im2.SetPixel(x, y, p2);
}
else {
im2.SetPixel(x, y, Black);
}
}
im2.Save("Disk_Black.png");
im2.MakeTransparent(Black);
im2.Save("Disk.png");
cout << "圖圓好了\n";
}
void toDisk(Bitmap^ im) {
int W = im->Width, H = im->Height;
if (W != H) {
cout << "非方圖\n";
return;
}
double c = W / 2.0;
double r = c;
Bitmap im2(W, H);
Color p2, Black = Color::FromArgb(0, 0, 0);
for (int x = 0; x < W; x++) {
for (int y = 0; y < H; y++) {
//取得每一個點的顏色
Color pixel = im->GetPixel(x, y);
int R = pixel.R, G = pixel.G, B = pixel.B;
//(x-c)^2+(y-c)^2=r^2 圓外變黑色 圓內保持原本顏色
if ((x - c)*(x - c) + (y - c)*(y - c) <= r*r) {
Color p2 = Color::FromArgb(R, G, B);
im2.SetPixel(x, y, p2);
}
else {
im2.SetPixel(x, y, Black);
}
}
}
im2.Save("Disk_Black.png");
//將黑色變成透明
im2.MakeTransparent(Black);
//將黑色部分去背
im2.Save("Disk_Blackoff.png");
cout << "畫圓好了\n";
}
void toDisk(Bitmap^ im) {
int W = im->Width, H = im->Height;
if (W != H) {
cout << "非方圖\n";
return;
}
double c = W / 2.0;
double r = c;
Bitmap im2(W, H);
Color p2, Black = Color::FromArgb(0, 0, 0);
for (int x = 0; x < W; x++) {
for (int y = 0; y < H; y++) {
//取得每一個點的顏色
Color pixel = im->GetPixel(x, y);
int R = pixel.R, G = pixel.G, B = pixel.B;
//(x-c)^2+(y-c)^2=r^2 圓外變黑色 圓內保持原本顏色
if ((x - c)*(x - c) + (y - c)*(y - c) <= r*r) {
Color p2 = Color::FromArgb(R, G, B);
im2.SetPixel(x, y, p2);
}
else {
im2.SetPixel(x, y, Black);
}
}
}
im2.Save("Disk_Black.png");
//將黑色變成透明
im2.MakeTransparent(Black);
//將黑色部分去背
im2.Save("Disk_Blackoff.png");
cout << "畫圓好了\n";
}
void to_Gray(Bitmap^ im)
{
int W = im->Width, H = im->Height;
Bitmap im2(W, H);
for(int x=0; xGetPixel(x, y);
int R=pixel.R, G=pixel.G, B= pixel.B;
int Gray = (R * 313524 + G * 615514 + B * 119538) >> 20;
Color p2 = Color::FromArgb(Gray, Gray, Gray);
im2.SetPixel(x, y, p2);
}
im2.Save("Gray.png");
cout << "灰階圖好了\n";
}
void to_Disk(Bitmap^ im) {
int W = im->Width, H = im->Height;
if (W != H) {
cout << "非方圖\n";
return;
}
double c = W / 2.0;
double r = c;
Bitmap im2(W, H);
Color p2, Black = Color::FromArgb(0, 0, 0);
for (int x = 0; x < W; x++)
for (int y = 0; y < H; y++) {
Color pixel = im->GetPixel(x, y);
int R = pixel.R, G = pixel.G, B = pixel.B;
if ((x - c)*(x - c) + (y - c)*(y - c) <= r*r) {
p2 = Color::FromArgb(R, G, B);
im2.SetPixel(x, y, p2);
}
else {
im2.SetPixel(x, y, Black);
}
}
im2.Save("Disk_Black.png");
im2.MakeTransparent(Black);
im2.Save("Disk.png");
cout << "圓圖\n";
}
void to_Disk(Bitmap^ im) {
int W = im->Width, H = im->Height;
if (W != H) {
cout << "非方圖\n";
return;
}
double c = W / 2.0;
double r = c;
Bitmap im2(W, H);
Color p2, Black = Color::FromArgb(0, 0, 0);
for (int x = 0; x < W; x++)
for (int y = 0; y < H; y++) {
Color pixel = im->GetPixel(x, y);
int R = pixel.R, G = pixel.G, B = pixel.B;
if ((x - c)*(x - c) + (y - c)*(y - c) <= r*r) {
p2 = Color::FromArgb(R, G, B);
im2.SetPixel(x, y, p2);
}
else {
im2.SetPixel(x, y, Black);
}
}
im2.Save("Disk_Black.png");
im2.MakeTransparent(Black);
im2.Save("Disk.png");
cout << "圓圖\n";
}
{
int W = im->Width, H = im->Height;
cout << "W=" << W<< "H=" << H << endl;
Bitmap im2(W, H);
for(int x=0;x<W;x++)
for (int y = 0; y < H; y++) {
Color pixel = im->GetPixel(x, y);
int R = pixel.R, G = pixel.G, B = pixel.B;
int Gray = (R * 313524 + G * 615514 + B * 119538) >> 20;
Color p2 = Color::FromArgb(Gray, Gray, Gray);
im2.SetPixel(x, y, p2);
}
im2.Save("Gray.png");
cout << "灰階圖好了\n";
}
void to_CC(Bitmap^ im)
{
int w=im->Width,H= im->Height;
Bitmap im2(W,H);
for (int x=0; x<W;x++)
for (int y=0; y<H; y++) {
Color pixel = im->Getpixel(x,y);
int R= 255-pixel.R,G =255- pixel.G,B =255- pixel.B;
Color p2= Color::FromArgb(R,G,B);
im2.SetPixel(x,y,p2);
}
im2. Save("G.png");
cout <<"互補色圖好了\n";
}
{
int W = im->Width, H = im->Height;
cout << "W=" << W<< "H=" << H << endl;
Bitmap im2(W, H);
for(int x=0;x<W;x++)
for (int y = 0; y < H; y++) {
Color pixel = im->GetPixel(x, y);
int R = pixel.R, G = pixel.G, B = pixel.B;
int Gray = (R * 313524 + G * 615514 + B * 119538) >> 20;
Color p2 = Color::FromArgb(Gray, Gray, Gray);
im2.SetPixel(x, y, p2);
}
im2.Save("Gray.png");
cout << "灰階圖好了\n";
}
{
int W = im->Width, H = im->Height;
cout << "W=" << W<< "H=" << H << endl;
Bitmap im2(W, H);
for(int x=0;x<W;x++)
for (int y = 0; y < H; y++) {
Color pixel = im->GetPixel(x, y);
int R = pixel.R, G = pixel.G, B = pixel.B;
int Gray = (R * 313524 + G * 615514 + B * 119538) >> 20;
Color p2 = Color::FromArgb(Gray, Gray, Gray);
im2.SetPixel(x, y, p2);
}
im2.Save("Gray.png");
cout << "灰階圖好了\n";
}
void to_Disk(Bitmap^ im) {
int W = im->Width, H = im->Height;
if (W != H) {
cout << "非方圖\n";
return;
}
double c = W / 2.0;
double r = c;
Bitmap im2(W, H);
Color p2, Black = Color::FromArgb(0, 0, 0);
for (int x = 0; x < W; x++)
for (int y = 0; y < H; y++) {
Color pixel = im->GetPixel(x, y);
int R = pixel.R, G = pixel.G, B = pixel.B;
if ((x - c)*(x - c) + (y - c)*(y - c) <= r*r) {
p2 = Color::FromArgb(R, G, B);
im2.SetPixel(x, y, p2);
}
else {
im2.SetPixel(x, y, Black);
}
}
im2.Save("Disk_Black.png");
im2.MakeTransparent(Black);
im2.Save("Disk.png");
cout << "圓圖\n";
}
void to_Disk(Bitmap^ im) {
int W = im->Width, H = im->Height;
if (W != H) {
cout << "非方圖\n";
return;
}
double c = W / 2.0;
double r = c;
Bitmap im2(W, H);
Color p2, Black = Color::FromArgb(0, 0, 0);
for (int x = 0; x < W; x++)
for (int y = 0; y < H; y++) {
Color pixel = im->GetPixel(x, y);
int R = pixel.R, G = pixel.G, B = pixel.B;
if ((x - c)*(x - c) + (y - c)*(y - c) <= r*r) {
p2 = Color::FromArgb(R, G, B);
im2.SetPixel(x, y, p2);
}
else {
im2.SetPixel(x, y, Black);
}
}
im2.Save("Disk_Black.png");
im2.MakeTransparent(Black);
im2.Save("Disk.png");
cout << "圓圖\n";
}
#include <iostream>
#include <cstdlib>
using namespace std;
#using <System.Drawing.dll>
using namespace System::Drawing;
void to_Gray(Bitmap^ im)
{
cout << "W=" << im->Width << "H=" << im->Height << endl;
Bitmap im2(im->Width, im->Height);
for(int x=0; x<im->Width;x++)
for (int y= 0; y < im->Height; y++) {
Color pixel = im->GetPixel(x, y);
int R = pixel.R, G = pixel.G, B = pixel.B;
int Gray = (R * 313524 + G * 615514 + B * 119538) >> 20;
Color p2 = Color::FromArgb(Gray, Gray, Gray);
im2.SetPixel(x, y,p2);
}
im2.Save("Gray.png");
}
void to_CC(Bitmap^ im)
{
cout << "W=" << im->Width << "H=" << im->Height << endl;
Bitmap im2(im->Width, im->Height);
for (int x = 0; x<im->Width; x++)
for (int y = 0; y < im->Height; y++) {
Color pixel = im->GetPixel(x, y);
int R = 255 - pixel.R, G = 255 - pixel.G, B = 255 - pixel.B;
Color p2 = Color::FromArgb(R, G, B);
im2.SetPixel(x, y, p2);
}
im2.Save("G.png");
}
void to_Disk(Bitmap^ im) {
int W = im->Width, H = im->Height;
if (W != H) {
cout << "非方圖\n";
return;
}
double c = W / 2.0;
double r = c;
Bitmap im2(W, H);
Color p2, Black = Color::FromArgb(0, 0, 0);
for (int x = 0; x < W; x++)
for (int y = 0; y < H; y++) {
Color pixel = im->GetPixel(x, y);
int R = pixel.R, G = pixel.G, B = pixel.B;
if ((x - c)*(x - c) + (y - c)*(y - c) <= r*r) {
p2 = Color::FromArgb(R, G, B);
im2.SetPixel(x, y, p2);
}
else {
im2.SetPixel(x, y, Black);
}
}
im2.Save("Disk_Black.png");
im2.MakeTransparent(Black);
im2.Save("Disk.png");
cout << "圓圖\n";
}
int main()
{
Bitmap^ im = gcnew Bitmap("2.jpg");
to_Gray(im);
to_CC(im);
to_Disk(im);
cout << "圖檔練習。\n";
system("Pause");
return 0;
}
#include <iostream>
#include <cstdlib>
using namespace std;
#using <System.Drawing.dll>
using namespace System::Drawing;
void to_Gray(Bitmap^ im)
{
cout << "W=" << im->Width << "H=" << im->Height << endl;
Bitmap im2(im->Width, im->Height);
for(int x=0; x<im->Width;x++)
for (int y= 0; y < im->Height; y++) {
Color pixel = im->GetPixel(x, y);
int R = pixel.R, G = pixel.G, B = pixel.B;
int Gray = (R * 313524 + G * 615514 + B * 119538) >> 20;
Color p2 = Color::FromArgb(Gray, Gray, Gray);
im2.SetPixel(x, y,p2);
}
im2.Save("Gray.png");
}
void to_CC(Bitmap^ im)
{
cout << "W=" << im->Width << "H=" << im->Height << endl;
Bitmap im2(im->Width, im->Height);
for (int x = 0; x<im->Width; x++)
for (int y = 0; y < im->Height; y++) {
Color pixel = im->GetPixel(x, y);
int R = 255 - pixel.R, G = 255 - pixel.G, B = 255 - pixel.B;
Color p2 = Color::FromArgb(R, G, B);
im2.SetPixel(x, y, p2);
}
im2.Save("G.png");
}
void to_Disk(Bitmap^ im) {
int W = im->Width, H = im->Height;
if (W != H) {
cout << "非方圖\n";
return;
}
double c = W / 2.0;
double r = c;
Bitmap im2(W, H);
Color p2, Black = Color::FromArgb(0, 0, 0);
for (int x = 0; x < W; x++)
for (int y = 0; y < H; y++) {
Color pixel = im->GetPixel(x, y);
int R = pixel.R, G = pixel.G, B = pixel.B;
if ((x - c)*(x - c) + (y - c)*(y - c) <= r*r) {
p2 = Color::FromArgb(R, G, B);
im2.SetPixel(x, y, p2);
}
else {
im2.SetPixel(x, y, Black);
}
}
im2.Save("Disk_Black.png");
im2.MakeTransparent(Black);
im2.Save("Disk.png");
cout << "圓圖\n";
}
int main()
{
Bitmap^ im = gcnew Bitmap("2.jpg");
to_Gray(im);
to_CC(im);
to_Disk(im);
cout << "圖檔練習。\n";
system("Pause");
return 0;
}
void to_Disk(Bitmap^ im) {
int W = im->Width, H = im->Height;
if (W != H) {
cout << "非方圖\n";
return;
}
double c = W / 2.0;
double r = c;
Bitmap im2(W, H);
Color p2, Black = Color::FromArgb(0, 0, 0);
for (int x = 0; x < W; x++)
for (int y = 0; y < H; y++) {
Color pixel = im->GetPixel(x, y);
int R = pixel.R, G = pixel.G, B = pixel.B;
if ((x - c)*(x - c) + (y - c)*(y - c) <= r*r) {
p2 = Color::FromArgb(R, G, B);
im2.SetPixel(x, y, p2);
}
else {
im2.SetPixel(x, y, Black);
}
}
im2.Save("Disk_Black.png");
im2.MakeTransparent(Black);
im2.Save("Disk.png");
cout << "圓圖\n";
}
void to_Disk(Bitmap^ im) {
int W = im->Width, H = im->Height;
if (W != H) {
cout << "非方圖\n";
return;
}
double c = W / 2.0;
double r = c;
Bitmap im2(W, H);
Color p2, Black = Color::FromArgb(0, 0, 0);
for (int x = 0; x < W; x++)
for (int y = 0; y < H; y++) {
Color pixel = im->GetPixel(x, y);
int R = pixel.R, G = pixel.G, B = pixel.B;
if ((x - c)*(x - c) + (y - c)*(y - c) <= r*r) {
p2 = Color::FromArgb(R, G, B);
im2.SetPixel(x, y, p2);
}
else {
im2.SetPixel(x, y, Black);
}
}
im2.Save("Disk_Black.png");
im2.MakeTransparent(Black);
im2.Save("Disk.png");
cout << "圓圖\n";
}
#include<iostream>
#include<cstdlib>
using namespace std;
#using <System.Drawing.dll>
using namespace System::Drawing;
void to_Disk(Bitmap^ im) {
int W = im->Width, H = im->Height;
Bitmap im2(W, H);
Color p2;
for (int x = 0; x<W; x++)
for (int y = 0; y < H; y++) {
Color pixel = im->GetPixel(x, y);
int R =255- pixel.R, G = 255-pixel.G, B = 255-pixel.B;
p2 = Color::FromArgb(R, G, B);
im2.SetPixel(x, y, p2);
}
im2.Save("negative.png");
cout << "負片好了\n";
}
int main()
{
cout << "圖檔\n";
Bitmap^ im = gcnew Bitmap("lena.jpg");
to_Disk(im);
system("Pause");
return 0;
}
void toDisk(Bitmap^ im) {
int W = im->Width, H = im->Height;
if (W != H) {
cout << "非方圖\n";
return;
}
double c = W / 2.0;
double r = c;
Bitmap im2(W, H);
Color p2, Black = Color::FromArgb(0, 0, 0);
for (int x = 0; x < W; x++) {
for (int y = 0; y < H; y++) {
//取得每一個點的顏色
Color pixel = im->GetPixel(x, y);
int R = pixel.R, G = pixel.G, B = pixel.B;
//(x-c)^2+(y-c)^2=r^2 圓外變黑色 圓內保持原本顏色
if ((x - c)*(x - c) + (y - c)*(y - c) <= r*r) {
Color p2 = Color::FromArgb(R, G, B);
im2.SetPixel(x, y, p2);
}
else {
im2.SetPixel(x, y, Black);
}
}
}
im2.Save("Disk_Black.png");
//將黑色變成透明
im2.MakeTransparent(Black);
//將黑色部分去背
im2.Save("Disk_Blackoff.png");
cout << "畫圓好了\n";
}
void to_Gray(Bitmap^im)
{
int W = im->Width, H = im->Height;
cout << "W=" << W << "H=" << H << endl;
Bitmap im2(W, H);
for (int x = 0; xGetPixel(x, y);
int R = pixel.R, G = pixel.G, B = pixel.B;
int Gray = (R * 313524 + G * 615514 + B * 119538) >> 20;
Color p2 = Color::FromArgb(Gray, Gray, Gray);
im2.SetPixel(x, y, p2);
}
im2.Save("Gray.png");
}
void to_CC(Bitmap^im)
{
int W = im->Width, H = im->Height;
cout << "W=" << W << "H=" << H << endl;
Bitmap im2(W, H);
for (int x = 0; xGetPixel(x, y);
int R = 255 - pixel.R, G = 255 - pixel.G, B =255- pixel.B;
Color p2 = Color::FromArgb(R, G, B);
im2.SetPixel(x, y, p2);
}
im2.Save("G.png");
}
void to_Disk(Bitmap^im) {
int W = im->Width, H = im->Height;
if (W != H) {
cout << "非方圖\n";
return;
}
double c = W / 2.0;
double r = c;
Bitmap im2(W, H);
Color p2, Black = Color::FromArgb(0, 0, 0);
for (int x = 0; x < W; x++)
for (int y = 0; y < H; y++) {
Color pixel = im->GetPixel(x, y);
int R = pixel.R, G = pixel.G, B = pixel.B;
if ((x - c)*(x - c) + (y - c)*(y - c) <= r*r) {
p2 = Color::FromArgb(R, G, B);
im2.SetPixel(x, y, p2);
}
else {
im2.SetPixel(x, y, Black);
}
}
im2.Save("Disk_Black.png");
im2.MakeTransparent(Black);
im2.Save("Disk.png");
cout << "圖圓好了\n";
}
void toDisk(Bitmap^ im) {
int W = im->Width, H = im->Height;
if (W != H) {
cout << "非方圖\n";
return;
}
double c = W / 2.0;
double r = c;
Bitmap im2(W, H);
Color p2, Black = Color::FromArgb(0, 0, 0);
for (int x = 0; x < W; x++) {
for (int y = 0; y < H; y++) {
//取得每一個點的顏色
Color pixel = im->GetPixel(x, y);
int R = pixel.R, G = pixel.G, B = pixel.B;
//(x-c)^2+(y-c)^2=r^2 圓外變黑色 圓內保持原本顏色
if ((x - c)*(x - c) + (y - c)*(y - c) <= r*r) {
Color p2 = Color::FromArgb(R, G, B);
im2.SetPixel(x, y, p2);
}
else {
im2.SetPixel(x, y, Black);
}
}
}
im2.Save("Disk_Black.png");
//將黑色變成透明
im2.MakeTransparent(Black);
//將黑色部分去背
im2.Save("Disk_Blackoff.png");
cout << "畫圓好了\n";
}
#include
#include
using namespace std;
#using
using namespace System::Drawing;
void to_Gray(Bitmap^ im)
{
cout << "W=" << im->Width << "H=" << im->Height << endl;
Bitmap im2(im->Width, im->Height);
for(int x=0; xWidth;x++)
for (int y= 0; y < im->Height; y++) {
Color pixel = im->GetPixel(x, y);
int R = pixel.R, G = pixel.G, B = pixel.B;
int Gray = (R * 313524 + G * 615514 + B * 119538) >> 20;
Color p2 = Color::FromArgb(Gray, Gray, Gray);
im2.SetPixel(x, y,p2);
}
im2.Save("Gray.png");
}
void to_CC(Bitmap^ im)
{
cout << "W=" << im->Width << "H=" << im->Height << endl;
Bitmap im2(im->Width, im->Height);
for (int x = 0; xWidth; x++)
for (int y = 0; y < im->Height; y++) {
Color pixel = im->GetPixel(x, y);
int R = 255 - pixel.R, G = 255 - pixel.G, B = 255 - pixel.B;
Color p2 = Color::FromArgb(R, G, B);
im2.SetPixel(x, y, p2);
}
im2.Save("G.png");
}
void to_Disk(Bitmap^ im) {
int W = im->Width, H = im->Height;
if (W != H) {
cout << "非方圖\n";
return;
}
double c = W / 2.0;
double r = c;
Bitmap im2(W, H);
Color p2, Black = Color::FromArgb(0, 0, 0);
for (int x = 0; x < W; x++)
for (int y = 0; y < H; y++) {
Color pixel = im->GetPixel(x, y);
int R = pixel.R, G = pixel.G, B = pixel.B;
if ((x - c)*(x - c) + (y - c)*(y - c) <= r*r) {
p2 = Color::FromArgb(R, G, B);
im2.SetPixel(x, y, p2);
}
else {
im2.SetPixel(x, y, Black);
}
}
im2.Save("Disk_Black.png");
im2.MakeTransparent(Black);
im2.Save("Disk.png");
cout << "圓圖\n";
}
int main()
{
Bitmap^ im = gcnew Bitmap("2.jpg");
to_Gray(im);
to_CC(im);
to_Disk(im);
cout << "圖檔練習。\n";
system("Pause");
return 0;
}
#include
#include
using namespace std;
#using
using namespace System::Drawing;
void to_Gray(Bitmap^ im)
{
cout << "W=" << im->Width << "H=" << im->Height << endl;
Bitmap im2(im->Width, im->Height);
for(int x=0; xWidth;x++)
for (int y= 0; y < im->Height; y++) {
Color pixel = im->GetPixel(x, y);
int R = pixel.R, G = pixel.G, B = pixel.B;
int Gray = (R * 313524 + G * 615514 + B * 119538) >> 20;
Color p2 = Color::FromArgb(Gray, Gray, Gray);
im2.SetPixel(x, y,p2);
}
im2.Save("Gray.png");
}
void to_CC(Bitmap^ im)
{
cout << "W=" << im->Width << "H=" << im->Height << endl;
Bitmap im2(im->Width, im->Height);
for (int x = 0; xWidth; x++)
for (int y = 0; y < im->Height; y++) {
Color pixel = im->GetPixel(x, y);
int R = 255 - pixel.R, G = 255 - pixel.G, B = 255 - pixel.B;
Color p2 = Color::FromArgb(R, G, B);
im2.SetPixel(x, y, p2);
}
im2.Save("G.png");
}
void to_Disk(Bitmap^ im) {
int W = im->Width, H = im->Height;
if (W != H) {
cout << "非方圖\n";
return;
}
double c = W / 2.0;
double r = c;
Bitmap im2(W, H);
Color p2, Black = Color::FromArgb(0, 0, 0);
for (int x = 0; x < W; x++)
for (int y = 0; y < H; y++) {
Color pixel = im->GetPixel(x, y);
int R = pixel.R, G = pixel.G, B = pixel.B;
if ((x - c)*(x - c) + (y - c)*(y - c) <= r*r) {
p2 = Color::FromArgb(R, G, B);
im2.SetPixel(x, y, p2);
}
else {
im2.SetPixel(x, y, Black);
}
}
im2.Save("Disk_Black.png");
im2.MakeTransparent(Black);
im2.Save("Disk.png");
cout << "圓圖\n";
}
int main()
{
Bitmap^ im = gcnew Bitmap("2.jpg");
to_Gray(im);
to_CC(im);
to_Disk(im);
cout << "圖檔練習。\n";
system("Pause");
return 0;
}
void to_Disk(Bitmap^ im) {
int W = im->Width, H = im->Height;
if (W != H) {
cout << "非方圖\n";
return;
}
double c = W / 2.0;
double r = c;
Bitmap im2(W, H);
Color p2, Black = Color::FromArgb(0, 0, 0);
for (int x = 0; x < W; x++)
for (int y = 0; y < H; y++) {
Color pixel = im->GetPixel(x, y);
int R = pixel.R, G = pixel.G, B = pixel.B;
if ((x - c)*(x - c) + (y - c)*(y - c) <= r*r) {
p2 = Color::FromArgb(R, G, B);
im2.SetPixel(x, y, p2);
}
else {
im2.SetPixel(x, y, Black);
}
}
im2.Save("Disk_Black.png");
im2.MakeTransparent(Black);
im2.Save("Disk.png");
cout << "圓圖\n";
}
void to_Disk(Bitmap^ im) {
int W = im->Width, H = im->Height;
if (W != H) {
cout << "非方圖\n";
return;
}
double c = W / 2.0;
double r = c;
Bitmap im2(W, H);
Color p2, Black = Color::FromArgb(0, 0, 0);
for (int x = 0; x < W; x++)
for (int y = 0; y < H; y++) {
Color pixel = im->GetPixel(x, y);
int R = pixel.R, G = pixel.G, B = pixel.B;
if ((x - c)*(x - c) + (y - c)*(y - c) <= r*r) {
p2 = Color::FromArgb(R, G, B);
im2.SetPixel(x, y, p2);
}
else {
im2.SetPixel(x, y, Black);
}
}
im2.Save("Disk_Black.png");
im2.MakeTransparent(Black);
im2.Save("Disk.png");
cout << "圓圖\n";
}
void to_Disk(Bitmap^ im) {
int W = im->Width, H = im->Height;
if (W != H) {
cout << "非方圖\n";
return;
}
double c = W / 2.0;
double r = c;
Bitmap im2(W, H);
Color p2, Black = Color::FromArgb(0, 0, 0);
for (int x = 0; x < W; x++)
for (int y = 0; y < H; y++) {
Color pixel = im->GetPixel(x, y);
int R = pixel.R, G = pixel.G, B = pixel.B;
if ((x - c)*(x - c) + (y - c)*(y - c) <= r*r) {
p2 = Color::FromArgb(R, G, B);
im2.SetPixel(x, y, p2);
}
else {
im2.SetPixel(x, y, Black);
}
}
im2.Save("Disk_Black.png");
im2.MakeTransparent(Black);
im2.Save("Disk.png");
cout << "圓圖\n";
}
void to_DIsk(Bitmap^ im) {
int W = im->Width, H = im -> Height;
if (W != H) {
cout << "方圖\n";
return;
}
double c = W / 2.0;
double r = c;
Bitmap im2(W, H);
Color p2, Black = Color::FromArgb(0, 0, 0);
for (int x = 0; x < W; x++)
for (int y = 0; y < H; y++) {
Color pixel = im->GetPixel(x, y);
int R = pixel.R, G = pixel.G, B = pixel.B;
if ((x - c)*(x - c) + (y - c)*(y - c) <= r*r) {
p2 = Color::FromArgb(R, G, B);
im2.SetPixel(x, y, p2);
}
else {
im2.SetPixel(x, y, Black);
}
}
im2.Save("Dask_Black.png");
im2.MakeTransparent(Black);
im2.Save("Dask.png");
cout << "圓圖好了\n";
}
#include
#include
using namespace std;
#using
using namespace System::Drawing;
void to_Gray(Bitmap^im) {
int W = im->Width, H = im->Height;
cout << "w=" << W << "H=" << H << endl;
double c = W / 2.0;
double r = c;
Color p2,Black = Color::FromArgb(0, 0, 0);
Bitmap im2(W, H);
for(int x=0;x GetPixel(x,y);
int R = pixel.R, G = pixel.G, B = pixel.B;
if ((x - c)*(x - c) + (y - c)*(y - c) <= r*r) {
Color p2 = Color::FromArgb(R, G, B);
im2.SetPixel(x, y, p2);
}
else {
im2.SetPixel(x, y,Black);
}
}
im2.Save("Disk_Black.png");
im2.MakeTransparent(Black);
im2.Save("Disk.png");
}
int main()
{
Bitmap^ im = gcnew Bitmap("tiffany511.jpg");
to_Gray(im);
cout << "圖像練習\n";
system("Pause");
return 0;
}
void to_Disk(Bitmap^ im) {
int W = im->Width, H = im->Height;
if (W != H) {
cout << "非方圖\n";
return;
}
double c = W / 2.0;
double r = c;
Bitmap im2(W, H);
Color p2, Black = Color::FromArgb(0, 0, 0);
for (int x = 0; x < W; x++)
for (int y = 0; y < H; y++) {
Color pixel = im->GetPixel(x, y);
int R = pixel.R, G = pixel.G, B = pixel.B;
if ((x - c)*(x - c) + (y - c)*(y - c) <= r*r) {
p2 = Color::FromArgb(R, G, B);
im2.SetPixel(x, y, p2);
}
else {
im2.SetPixel(x, y, Black);
}
}
im2.Save("Disk_Black.png");
im2.MakeTransparent(Black);
im2.Save("Disk.png");
cout << "圓圖\n";
}
#include
#include
using namespace std;
#using
using namespace System::Drawing;
void to_Gray(Bitmap^ im)
{
cout << "W=" << im->Width << "H=" << im->Height << endl;
Bitmap im2(im->Width, im->Height);
for(int x=0; xWidth;x++)
for (int y= 0; y < im->Height; y++) {
Color pixel = im->GetPixel(x, y);
int R = pixel.R, G = pixel.G, B = pixel.B;
int Gray = (R * 313524 + G * 615514 + B * 119538) >> 20;
Color p2 = Color::FromArgb(Gray, Gray, Gray);
im2.SetPixel(x, y,p2);
}
im2.Save("Gray.png");
}
void to_CC(Bitmap^ im)
{
cout << "W=" << im->Width << "H=" << im->Height << endl;
Bitmap im2(im->Width, im->Height);
for (int x = 0; xWidth; x++)
for (int y = 0; y < im->Height; y++) {
Color pixel = im->GetPixel(x, y);
int R = 255 - pixel.R, G = 255 - pixel.G, B = 255 - pixel.B;
Color p2 = Color::FromArgb(R, G, B);
im2.SetPixel(x, y, p2);
}
im2.Save("G.png");
}
void to_Disk(Bitmap^ im) {
int W = im->Width, H = im->Height;
if (W != H) {
cout << "非方圖\n";
return;
}
double c = W / 2.0;
double r = c;
Bitmap im2(W, H);
Color p2, Black = Color::FromArgb(0, 0, 0);
for (int x = 0; x < W; x++)
for (int y = 0; y < H; y++) {
Color pixel = im->GetPixel(x, y);
int R = pixel.R, G = pixel.G, B = pixel.B;
if ((x - c)*(x - c) + (y - c)*(y - c) <= r*r) {
p2 = Color::FromArgb(R, G, B);
im2.SetPixel(x, y, p2);
}
else {
im2.SetPixel(x, y, Black);
}
}
im2.Save("Disk_Black.png");
im2.MakeTransparent(Black);
im2.Save("Disk.png");
cout << "圓圖\n";
}
int main()
{
Bitmap^ im = gcnew Bitmap("2.jpg");
to_Gray(im);
to_CC(im);
to_Disk(im);
cout << "圖檔練習。\n";
system("Pause");
return 0;
}
#include
#include
using namespace std;
#using
using namespace System::Drawing;
void to_Gray(Bitmap^ im)
{
cout << "W=" << im->Width << "H=" << im->Height << endl;
Bitmap im2(im->Width, im->Height);
for(int x=0; xWidth;x++)
for (int y= 0; y < im->Height; y++) {
Color pixel = im->GetPixel(x, y);
int R = pixel.R, G = pixel.G, B = pixel.B;
int Gray = (R * 313524 + G * 615514 + B * 119538) >> 20;
Color p2 = Color::FromArgb(Gray, Gray, Gray);
im2.SetPixel(x, y,p2);
}
im2.Save("Gray.png");
}
void to_CC(Bitmap^ im)
{
cout << "W=" << im->Width << "H=" << im->Height << endl;
Bitmap im2(im->Width, im->Height);
for (int x = 0; xWidth; x++)
for (int y = 0; y < im->Height; y++) {
Color pixel = im->GetPixel(x, y);
int R = 255 - pixel.R, G = 255 - pixel.G, B = 255 - pixel.B;
Color p2 = Color::FromArgb(R, G, B);
im2.SetPixel(x, y, p2);
}
im2.Save("G.png");
}
void to_Disk(Bitmap^ im) {
int W = im->Width, H = im->Height;
if (W != H) {
cout << "非方圖\n";
return;
}
double c = W / 2.0;
double r = c;
Bitmap im2(W, H);
Color p2, Black = Color::FromArgb(0, 0, 0);
for (int x = 0; x < W; x++)
for (int y = 0; y < H; y++) {
Color pixel = im->GetPixel(x, y);
int R = pixel.R, G = pixel.G, B = pixel.B;
if ((x - c)*(x - c) + (y - c)*(y - c) <= r*r) {
p2 = Color::FromArgb(R, G, B);
im2.SetPixel(x, y, p2);
}
else {
im2.SetPixel(x, y, Black);
}
}
im2.Save("Disk_Black.png");
im2.MakeTransparent(Black);
im2.Save("Disk.png");
cout << "圓圖\n";
}
int main()
{
Bitmap^ im = gcnew Bitmap("2.jpg");
to_Gray(im);
to_CC(im);
to_Disk(im);
cout << "圖檔練習。\n";
system("Pause");
return 0;
}
#include
#include
using namespace std;
#using
using namespace System::Drawing;
void to_Gray(Bitmap^im) {
int W = im->Width, H = im->Height;
cout << "w=" << W << "H=" << H << endl;
double c = W / 2.0;
double r = c;
Color p2,Black = Color::FromArgb(0, 0, 0);
Bitmap im2(W, H);
for(int x=0;x GetPixel(x,y);
int R = pixel.R, G = pixel.G, B = pixel.B;
if ((x - c)*(x - c) + (y - c)*(y - c) <= r*r) {
Color p2 = Color::FromArgb(R, G, B);
im2.SetPixel(x, y, p2);
}
else {
im2.SetPixel(x, y,Black);
}
}
im2.Save("Disk_Black.png");
im2.MakeTransparent(Black);
im2.Save("Disk.png");
}
int main()
{
Bitmap^ im = gcnew Bitmap("tiffany511.jpg");
to_Gray(im);
cout << "圖像練習\n";
system("Pause");
return 0;
}
#include
#include
using namespace std;
#using
using namespace System::Drawing;
void to_Gray(Bitmap^im) {
int W = im->Width, H = im->Height;
cout << "w=" << W << "H=" << H << endl;
double c = W / 2.0;
double r = c;
Color p2,Black = Color::FromArgb(0, 0, 0);
Bitmap im2(W, H);
for(int x=0;x GetPixel(x,y);
int R = pixel.R, G = pixel.G, B = pixel.B;
if ((x - c)*(x - c) + (y - c)*(y - c) <= r*r) {
Color p2 = Color::FromArgb(R, G, B);
im2.SetPixel(x, y, p2);
}
else {
im2.SetPixel(x, y,Black);
}
}
im2.Save("Disk_Black.png");
im2.MakeTransparent(Black);
im2.Save("Disk.png");
}
int main()
{
Bitmap^ im = gcnew Bitmap("tiffany511.jpg");
to_Gray(im);
cout << "圖像練習\n";
system("Pause");
return 0;
}
#include
#include
using namespace std;
#using
using namespace System::Drawing;
void to_Gray(Bitmap^im) {
int W = im->Width, H = im->Height;
cout << "w=" << W << "H=" << H << endl;
double c = W / 2.0;
double r = c;
Color p2,Black = Color::FromArgb(0, 0, 0);
Bitmap im2(W, H);
for(int x=0;x GetPixel(x,y);
int R = pixel.R, G = pixel.G, B = pixel.B;
if ((x - c)*(x - c) + (y - c)*(y - c) <= r*r) {
Color p2 = Color::FromArgb(R, G, B);
im2.SetPixel(x, y, p2);
}
else {
im2.SetPixel(x, y,Black);
}
}
im2.Save("Disk_Black.png");
im2.MakeTransparent(Black);
im2.Save("Disk.png");
}
int main()
{
Bitmap^ im = gcnew Bitmap("tiffany511.jpg");
to_Gray(im);
cout << "圖像練習\n";
system("Pause");
return 0;
}
#include
#include
using namespace std;
#using
using namespace System::Drawing;
void to_Gray(Bitmap^im) {
int W = im->Width, H = im->Height;
cout << "w=" << W << "H=" << H << endl;
double c = W / 2.0;
double r = c;
Color p2,Black = Color::FromArgb(0, 0, 0);
Bitmap im2(W, H);
for(int x=0;x GetPixel(x,y);
int R = pixel.R, G = pixel.G, B = pixel.B;
if ((x - c)*(x - c) + (y - c)*(y - c) <= r*r) {
Color p2 = Color::FromArgb(R, G, B);
im2.SetPixel(x, y, p2);
}
else {
im2.SetPixel(x, y,Black);
}
}
im2.Save("Disk_Black.png");
im2.MakeTransparent(Black);
im2.Save("Disk.png");
}
int main()
{
Bitmap^ im = gcnew Bitmap("tiffany511.jpg");
to_Gray(im);
cout << "圖像練習\n";
system("Pause");
return 0;
}
#include
#include
using namespace std;
#using
using namespace System::Drawing;
void to_Gray(Bitmap^im) {
int W = im->Width, H = im->Height;
cout << "w=" << W << "H=" << H << endl;
double c = W / 2.0;
double r = c;
Color p2,Black = Color::FromArgb(0, 0, 0);
Bitmap im2(W, H);
for(int x=0;x GetPixel(x,y);
int R = pixel.R, G = pixel.G, B = pixel.B;
if ((x - c)*(x - c) + (y - c)*(y - c) <= r*r) {
Color p2 = Color::FromArgb(R, G, B);
im2.SetPixel(x, y, p2);
}
else {
im2.SetPixel(x, y,Black);
}
}
im2.Save("Disk_Black.png");
im2.MakeTransparent(Black);
im2.Save("Disk.png");
}
int main()
{
Bitmap^ im = gcnew Bitmap("tiffany511.jpg");
to_Gray(im);
cout << "圖像練習\n";
system("Pause");
return 0;
}
#include
#include
using namespace std;
#using
using namespace System::Drawing;
void to_Gray(Bitmap^im) {
int W = im->Width, H = im->Height;
cout << "w=" << W << "H=" << H << endl;
double c = W / 2.0;
double r = c;
Color p2,Black = Color::FromArgb(0, 0, 0);
Bitmap im2(W, H);
for(int x=0;x GetPixel(x,y);
int R = pixel.R, G = pixel.G, B = pixel.B;
if ((x - c)*(x - c) + (y - c)*(y - c) <= r*r) {
Color p2 = Color::FromArgb(R, G, B);
im2.SetPixel(x, y, p2);
}
else {
im2.SetPixel(x, y,Black);
}
}
im2.Save("Disk_Black.png");
im2.MakeTransparent(Black);
im2.Save("Disk.png");
}
int main()
{
Bitmap^ im = gcnew Bitmap("tiffany511.jpg");
to_Gray(im);
cout << "圖像練習\n";
system("Pause");
return 0;
}
#include
#include
using namespace std;
#using
using namespace System::Drawing;
void to_Gray(Bitmap^im) {
int W = im->Width, H = im->Height;
cout << "w=" << W << "H=" << H << endl;
double c = W / 2.0;
double r = c;
Color p2,Black = Color::FromArgb(0, 0, 0);
Bitmap im2(W, H);
for(int x=0;x GetPixel(x,y);
int R = pixel.R, G = pixel.G, B = pixel.B;
if ((x - c)*(x - c) + (y - c)*(y - c) <= r*r) {
Color p2 = Color::FromArgb(R, G, B);
im2.SetPixel(x, y, p2);
}
else {
im2.SetPixel(x, y,Black);
}
}
im2.Save("Disk_Black.png");
im2.MakeTransparent(Black);
im2.Save("Disk.png");
}
int main()
{
Bitmap^ im = gcnew Bitmap("tiffany511.jpg");
to_Gray(im);
cout << "圖像練習\n";
system("Pause");
return 0;
}
void to_Gray(Bitmap^im)
{
int W = im->Width, H = im->Height;
cout << "W=" << W << "H=" << H << endl;
Bitmap im2(W, H);
for (int x = 0; xGetPixel(x, y);
int R = pixel.R, G = pixel.G, B = pixel.B;
int Gray = (R * 313524 + G * 615514 + B * 119538) >> 20;
Color p2 = Color::FromArgb(Gray, Gray, Gray);
im2.SetPixel(x, y, p2);
}
im2.Save("Gray.png");
}
void to_CC(Bitmap^im)
{
int W = im->Width, H = im->Height;
cout << "W=" << W << "H=" << H << endl;
Bitmap im2(W, H);
for (int x = 0; xGetPixel(x, y);
int R = 255 - pixel.R, G = 255 - pixel.G, B =255- pixel.B;
Color p2 = Color::FromArgb(R, G, B);
im2.SetPixel(x, y, p2);
}
im2.Save("G.png");
}
void to_Disk(Bitmap^im) {
int W = im->Width, H = im->Height;
if (W != H) {
cout << "非方圖\n";
return;
}
double c = W / 2.0;
double r = c;
Bitmap im2(W, H);
Color p2, Black = Color::FromArgb(0, 0, 0);
for (int x = 0; x < W; x++)
for (int y = 0; y < H; y++) {
Color pixel = im->GetPixel(x, y);
int R = pixel.R, G = pixel.G, B = pixel.B;
if ((x - c)*(x - c) + (y - c)*(y - c) <= r*r) {
p2 = Color::FromArgb(R, G, B);
im2.SetPixel(x, y, p2);
}
else {
im2.SetPixel(x, y, Black);
}
}
im2.Save("Disk_Black.png");
im2.MakeTransparent(Black);
im2.Save("Disk.png");
cout << "圖圓好了\n";
}
void to_Gray(Bitmap^im)
{
int W = im->Width, H = im->Height;
cout << "W=" << W << "H=" << H << endl;
Bitmap im2(W, H);
for (int x = 0; xGetPixel(x, y);
int R = pixel.R, G = pixel.G, B = pixel.B;
int Gray = (R * 313524 + G * 615514 + B * 119538) >> 20;
Color p2 = Color::FromArgb(Gray, Gray, Gray);
im2.SetPixel(x, y, p2);
}
im2.Save("Gray.png");
}
void to_CC(Bitmap^im)
{
int W = im->Width, H = im->Height;
cout << "W=" << W << "H=" << H << endl;
Bitmap im2(W, H);
for (int x = 0; xGetPixel(x, y);
int R = 255 - pixel.R, G = 255 - pixel.G, B =255- pixel.B;
Color p2 = Color::FromArgb(R, G, B);
im2.SetPixel(x, y, p2);
}
im2.Save("G.png");
}
void to_Disk(Bitmap^im) {
int W = im->Width, H = im->Height;
if (W != H) {
cout << "非方圖\n";
return;
}
double c = W / 2.0;
double r = c;
Bitmap im2(W, H);
Color p2, Black = Color::FromArgb(0, 0, 0);
for (int x = 0; x < W; x++)
for (int y = 0; y < H; y++) {
Color pixel = im->GetPixel(x, y);
int R = pixel.R, G = pixel.G, B = pixel.B;
if ((x - c)*(x - c) + (y - c)*(y - c) <= r*r) {
p2 = Color::FromArgb(R, G, B);
im2.SetPixel(x, y, p2);
}
else {
im2.SetPixel(x, y, Black);
}
}
im2.Save("Disk_Black.png");
im2.MakeTransparent(Black);
im2.Save("Disk.png");
cout << "圖圓好了\n";
}
void to_Disk(Bitmap^ im) {
int W = im->Width, H = im->Height;
if (W != H) {
cout << "非方圖\n";
return;
}
double c = W / 2.0;
double r = c;
Bitmap im2(W, H);
Color p2, Black = Color::FromArgb(0, 0, 0);
for (int x = 0; x < W; x++)
for (int y = 0; y < H; y++) {
Color pixel = im->GetPixel(x, y);
int R = pixel.R, G = pixel.G, B = pixel.B;
if ((x - c)*(x - c) + (y - c)*(y - c) <= r*r) {
p2 = Color::FromArgb(R, G, B);
im2.SetPixel(x, y, p2);
}
else {
im2.SetPixel(x, y, Black);
}
}
im2.Save("Disk_Black.png");
im2.MakeTransparent(Black);
im2.Save("Disk.png");
cout << "圓圖\n";
}
#include
#include
using namespace std;
#using
using namespace System::Drawing;
void to_Gray(Bitmap^im) {
int W = im->Width, H = im->Height;
cout << "w=" << W << "H=" << H << endl;
double c = W / 2.0;
double r = c;
Color p2,Black = Color::FromArgb(0, 0, 0);
Bitmap im2(W, H);
for(int x=0;x GetPixel(x,y);
int R = pixel.R, G = pixel.G, B = pixel.B;
if ((x - c)*(x - c) + (y - c)*(y - c) <= r*r) {
Color p2 = Color::FromArgb(R, G, B);
im2.SetPixel(x, y, p2);
}
else {
im2.SetPixel(x, y,Black);
}
}
im2.Save("Disk_Black.png");
im2.MakeTransparent(Black);
im2.Save("Disk.png");
}
int main()
{
Bitmap^ im = gcnew Bitmap("tiffany511.jpg");
to_Gray(im);
cout << "圖像練習\n";
system("Pause");
return 0;
}
#include
#include
using namespace std;
#using
using namespace System::Drawing;
void to_Gray(Bitmap^ im)
{
cout << "W=" << im->Width << "H=" << im->Height << endl;
Bitmap im2(im->Width, im->Height);
for(int x=0; xWidth;x++)
for (int y= 0; y < im->Height; y++) {
Color pixel = im->GetPixel(x, y);
int R = pixel.R, G = pixel.G, B = pixel.B;
int Gray = (R * 313524 + G * 615514 + B * 119538) >> 20;
Color p2 = Color::FromArgb(Gray, Gray, Gray);
im2.SetPixel(x, y,p2);
}
im2.Save("Gray.png");
}
void to_CC(Bitmap^ im)
{
cout << "W=" << im->Width << "H=" << im->Height << endl;
Bitmap im2(im->Width, im->Height);
for (int x = 0; xWidth; x++)
for (int y = 0; y < im->Height; y++) {
Color pixel = im->GetPixel(x, y);
int R = 255 - pixel.R, G = 255 - pixel.G, B = 255 - pixel.B;
Color p2 = Color::FromArgb(R, G, B);
im2.SetPixel(x, y, p2);
}
im2.Save("G.png");
}
void to_Disk(Bitmap^ im) {
int W = im->Width, H = im->Height;
if (W != H) {
cout << "非方圖\n";
return;
}
double c = W / 2.0;
double r = c;
Bitmap im2(W, H);
Color p2, Black = Color::FromArgb(0, 0, 0);
for (int x = 0; x < W; x++)
for (int y = 0; y < H; y++) {
Color pixel = im->GetPixel(x, y);
int R = pixel.R, G = pixel.G, B = pixel.B;
if ((x - c)*(x - c) + (y - c)*(y - c) <= r*r) {
p2 = Color::FromArgb(R, G, B);
im2.SetPixel(x, y, p2);
}
else {
im2.SetPixel(x, y, Black);
}
}
im2.Save("Disk_Black.png");
im2.MakeTransparent(Black);
im2.Save("Disk.png");
cout << "圓圖\n";
}
int main()
{
Bitmap^ im = gcnew Bitmap("2.jpg");
to_Gray(im);
to_CC(im);
to_Disk(im);
cout << "圖檔練習。\n";
system("Pause");
return 0;
}
void to_Disk(Bitmap^ im) {
int W = im->Width, H = im->Height;
if (W != H) {
cout << "非方圖\n";
return;
}
double c = W / 2.0;
double r = c;
Bitmap im2(W, H);
Color p2, Black = Color::FromArgb(0, 0, 0);
for (int x = 0; x < W; x++)
for (int y = 0; y < H; y++) {
Color pixel = im->GetPixel(x, y);
int R = pixel.R, G = pixel.G, B = pixel.B;
if ((x - c)*(x - c) + (y - c)*(y - c) <= r*r) {
p2 = Color::FromArgb(R, G, B);
im2.SetPixel(x, y, p2);
}
else {
im2.SetPixel(x, y, Black);
}
}
im2.Save("Disk_Black.png");
im2.MakeTransparent(Black);
im2.Save("Disk.png");
cout << "圓圖\n";
}
張貼留言