static void CreateBitMap2()
{
int width = 1000;
int height = 1000;
int cell = 100;
using (Bitmap bmp = new Bitmap(width, height))
using (Graphics g = Graphics.FromImage(bmp))
{
g.Clear(Color.White);
// =========================
// 100pxチェッカーパターン
// =========================
for (int y = 0; y < height; y += cell)
{
for (int x = 0; x < width; x += cell)
{
bool dark = ((x / cell) + (y / cell)) % 2 == 0;
Brush brush = dark
? new SolidBrush(Color.FromArgb(235, 235, 235))
: new SolidBrush(Color.FromArgb(210, 210, 210));
g.FillRectangle(brush, x, y, cell, cell);
}
}
// =========================
// 10pxグリッド
// =========================
using (Pen pen10 = new Pen(Color.Gray, 1))
{
for (int x = 0; x < width; x += 10)
g.DrawLine(pen10, x, 0, x, height);
for (int y = 0; y < height; y += 10)
g.DrawLine(pen10, 0, y, width, y);
}
// =========================
// 100pxグリッド
// =========================
using (Pen pen100 = new Pen(Color.Red, 2))
{
for (int x = 0; x < width; x += 100)
g.DrawLine(pen100, x, 0, x, height);
for (int y = 0; y < height; y += 100)
g.DrawLine(pen100, 0, y, width, y);
}
// =========================
// 座標表示
// =========================
using (Font font = new Font("Arial", 12))
{
for (int x = 0; x < width; x += 100)
{
g.DrawString($"x={x}", font, Brushes.Blue, x + 5, 5);
}
for (int y = 0; y < height; y += 100)
{
g.DrawString($"y={y}", font, Brushes.Green, 5, y + 5);
}
}
// =========================
// 交点マーカー
// =========================
for (int y = 0; y < height; y += 100)
{
for (int x = 0; x < width; x += 100)
{
g.FillEllipse(Brushes.Red, x - 3, y - 3, 6, 6);
}
}
bmp.Save("debug_test_image.png", ImageFormat.Png);
}
Console.WriteLine("デバッグ画像生成完了");
}