herrDeng網內搜尋

自訂搜尋

Ads

2017年12月6日 星期三

EX10 C++ Bitmap去背或畫圓圖






51 則留言:

B10533015 陳建志 提到...

#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;
}

B10533062 洪尚郁 提到...

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";
}

b10533007魏辰熾 提到...

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";
}

b10533011 江道逸 提到...

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";
}

b10533006 劉純賓 提到...

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";
}

b10533008 張士晟 提到...

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";
}

b10533009 張仲崴 提到...

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";
}

B10533010蕭凱維 提到...

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";
}

b10533018 陳郁傑 提到...

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";
}

B10433065劉勝威 提到...

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";

}

B10433065劉勝威 提到...

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";

}

B10533010蕭凱維 提到...

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";
}

b10433081 巫明芬 提到...

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";
}

b10433081 巫明芬 提到...

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";
}

B10433090蔡語鋐 提到...

{
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";
}

B10533132許敏茹 提到...

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";
}

B10433073何明宗 提到...

{
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";
}

B10433106簡偉佑 提到...

{
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";
}

b10433072 廖翊翔 提到...

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";
}

b10433094 簡筱芸 提到...

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";
}

b10433099 駱婉婷 提到...

#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;
}

B10433107 袁婕寧 提到...

#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;
}

B10537208楊蕊筑 提到...

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";
}

B10533088葉俊江 提到...

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";
}

b10333093徐子軒 提到...

#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;
}

b10433071 雷昕翰 提到...

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";

}

B10533071徐琮淇 提到...

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";
}

b10433088葉凱文 提到...

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";

}

B10533083徐士興 提到...

#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;
}

B10533083徐士興 提到...

#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;
}

B10533083徐士興 提到...

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";
}

B10533083徐士興 提到...

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";
}

B10533083徐士興 提到...

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";
}

b10533004 李登恩 提到...

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";
}

b10533066曾楷杰 提到...

#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;
}

b10533066曾楷杰 提到...

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";
}

B10533076 姜國傑 提到...

#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;
}

B10433102楊婷妤 提到...

#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;
}

b10514033盧昱仁 提到...

#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;
}

b10533017古峻衛 提到...

#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;
}

b10533031沈宏儒 提到...

#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;
}

b10533032程泓瑋 提到...

#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;
}

b10533037張俊為 提到...

#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;
}

b10533032程泓瑋 提到...

#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;
}

B10533093許永炎 提到...

#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;
}

b10533075 陳詔瑋 提到...

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";
}

b10533029 游淑娥 提到...

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";
}

B10433088 葉凱文 提到...

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";
}

B10533064蔡佩芸 提到...

#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;
}

b10533073黃叡哲 提到...

#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;
}

b10533085羅偉辰 提到...

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";
}

Related Posts Plugin for WordPress, Blogger...

熱門文章