1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

cscの作法 その537

Posted at

概要

cscの作法、調べてみた。
練習問題やってみた。

練習問題

grayscaleなpngを作れ。

参考にしたページ

サンプルコード



using System;
using System.Drawing;
using System.IO;
using System.Drawing.Imaging;

namespace app
{
	class test0 {
		static void Main() {
			int width = 1600;
			int height = 900;
			Bitmap img = new Bitmap(width, height);
			for (int i = 0; i < width; i++)
			{
				for (int j = 0; j < height; j++)
				{
					float posX = width * 1 / 4;
					float posY = height * 2 / 3;
					float f = (float) Math.Pow(Math.Pow(posX - i, 2) + Math.Pow(posY - j, 2), 0.5f);
					f = Math.Min(255, f / 5);
					int num = (int) f;
					Color c = Color.FromArgb(num, num, num);
					img.SetPixel(i, height - j - 1, c);
				}
			}
			img.Save("gr1.png", ImageFormat.Png);
			Console.WriteLine("ok");
		}
	}
}






実行結果

gr1.png

以上。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?