open System
open System.IO
open System.Drawing
open System.Drawing.Imaging
let sourceImage = Image.FromFile(@".\lizard01.png")
let sourceBitmap = new Bitmap(sourceImage)
let PatternBitmap = new Bitmap(1024, 768, sourceBitmap.PixelFormat)
let g = Graphics.FromImage(PatternBitmap);
let shift = sourceImage.Width / 3
for x in [-13..15] do
for y in [0..15] do
g.DrawImage(sourceBitmap, x * (sourceImage.Width - shift) - shift + y * shift, y * sourceImage.Height,
sourceImage.Width, sourceImage.Height);
PatternBitmap.Save(@".\colorpattern.png", ImageFormat.Png)
g.Dispose()
open System.IO
open System.Drawing
open System.Drawing.Imaging
// ソース読み込み
let sourceImage = Image.FromFile(@".\lizard02.png")
let sourceBitmap = new Bitmap(sourceImage)
let w, h = sourceBitmap.Width, sourceBitmap.Height
// ソースを三つ組み合わせてp1相当の繰り返し(ただし六角形)を作成
let PatternBitmap = new Bitmap(1024, 768, sourceBitmap.PixelFormat)
let tempBitmap = new Bitmap(w * 2, h + w)
let tg = Graphics.FromImage(tempBitmap);
let drawOne x y sx sy a =
tg.ResetTransform();
tg.TranslateTransform(sx, sy);
tg.RotateTransform(a);
tg.DrawImage(sourceBitmap, x, y, w, h);
drawOne w 0 0.0f 0.0f 0.0f
drawOne 0 0 1.0f (float32 (h + 1)) -120.0f
drawOne 0 0 (float32 (2 * w)) (float32 h) 120.0f
tg.Dispose()
// 壁紙全体を作成
let g = Graphics.FromImage(PatternBitmap);
for x in [0..10] do
for y in [0..10] do
let zx, zy = x * w * 2 + (y % 2) * w - w, y * h - ( h / 3 * 2)
g.DrawImage(tempBitmap, zx, zy, w * 2, h + w);
PatternBitmap.Save(@".\monopattern.png", ImageFormat.Png)
g.Dispose()