herrDeng網內搜尋
自訂搜尋
Ads
訂閱:
張貼留言 (Atom)
熱門文章
-
url="https://www.twse.com.tw/exchangeReport/STOCK_DAY?response=json&date=20220330&stockNo=2330"
-
教育部為提昇全民資安素養與電腦防護能力,本部於101年9月5日至11月5日舉辦「全民資安素養自我評量」活動,請在活動期間內踴躍上網檢測資訊安全素養認知程度,並有機會參與抽獎,詳情請參閱活動網站(網址: https://isafe.moe.edu.tw/event
-
python pandas對黃金、外匯匯率的爬蟲練習,並使用matplotlib.pyplot的函數plot, scatter做資料視覺化處理,採用numpy的統計函數,分析黃金價格波動與歐元走勢的關聯。
-
Python C C++ 2 pointer速解Leetcode 2337 Move Pieces to Obtain a String 多日Leetcode的問題都可用2-pointer法來解,今日2337. Move Pieces to Obtain a String也不例...
-
你會用C的算子sizeof?
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";
}
張貼留言