;============================================================ ; iron_gdiplus.hsp — GDI+ 高機能グラフィックス (.NET) ; ; hsp3net 専用。グラデーション、パス、変換、画像処理。 ; ; API: #ifndef __iron_gdiplus_hsp__ #define __iron_gdiplus_hsp__ #module iron_gdiplus dim _gdi_cs_loaded, 1 #deffunc _gdi_load_cs if _gdi_cs_loaded : return sdim _cs, 8192 _cs = "using System;using System.Drawing;using System.Drawing.Drawing2D;using System.Drawing.Imaging;" _cs += "public class HspGdi {" _cs += " static ImageFormat GetFmt(string p) {" _cs += " if(p.EndsWith(\".jpg\")||p.EndsWith(\".jpeg\")) return ImageFormat.Jpeg;" _cs += " if(p.EndsWith(\".bmp\")) return ImageFormat.Bmp;" _cs += " if(p.EndsWith(\".gif\")) return ImageFormat.Gif;" _cs += " return ImageFormat.Png;" _cs += " }" _cs += " public static string Screenshot(string path) {" _cs += " var bounds = System.Windows.Forms.Screen.PrimaryScreen.Bounds;" _cs += " var bmp = new Bitmap(bounds.Width, bounds.Height);" _cs += " using(var g = Graphics.FromImage(bmp)) {" _cs += " g.CopyFromScreen(bounds.Location, Point.Empty, bounds.Size);" _cs += " }" _cs += " bmp.Save(path, GetFmt(path)); return \"ok\";" _cs += " }" _cs += " public static string Resize(string src, string dst, int w, int h) {" _cs += " using(var img = Image.FromFile(src)) {" _cs += " var bmp = new Bitmap(w, h);" _cs += " using(var g = Graphics.FromImage(bmp)) {" _cs += " g.InterpolationMode = InterpolationMode.HighQualityBicubic;" _cs += " g.DrawImage(img, 0, 0, w, h);" _cs += " }" _cs += " bmp.Save(dst, GetFmt(dst));" _cs += " } return \"ok\";" _cs += " }" _cs += " public static string Rotate(string src, string dst, int deg) {" _cs += " using(var img = Image.FromFile(src)) {" _cs += " if(deg==90) img.RotateFlip(RotateFlipType.Rotate90FlipNone);" _cs += " else if(deg==180) img.RotateFlip(RotateFlipType.Rotate180FlipNone);" _cs += " else if(deg==270) img.RotateFlip(RotateFlipType.Rotate270FlipNone);" _cs += " img.Save(dst, GetFmt(dst));" _cs += " } return \"ok\";" _cs += " }" _cs += " public static string Grayscale(string src, string dst) {" _cs += " using(var img = new Bitmap(src)) {" _cs += " for(int y=0;y