coding Shift_JIS; // 文字コードの明示(文字化け予防) import Graphics; // 画像処理に必要なライブラリの読み込み // ユーザーに画像ファイルを選択してもらい、それを開いてグラフィックスリソースを生成 string inputFilePath = choose("変換したい画像ファイルを選んでください。", "./"); int inputGraphics = newGraphics(inputFilePath); // 透明化したい色のRGB値をユーザーに入力してもらう int fromRed = input("透明化する色の赤成分 ( 0〜255 ) は?", "0"); int fromGreen = input("透明化する色の緑成分 ( 0〜255 ) は?", "255"); int fromBlue = input("透明化する色の青成分 ( 0〜255 ) は?", "0"); int fromAlpha = 255; // 透明化したい元の色の不透明度(0で完全な透明、255で完全な不透明) // 変換後の色を定義(透明以外の色にしたい場合はここを書き換える) int toRed = 0; // 赤成分 int toGreen = 0; // 青成分 int toBlue = 0; // 緑成分 int toAlpha = 0; // 不透明度(0で完全な透明、255で完全な不透明) // 色を変換したグラフィックスリソースを生成 int outputGraphics = newGraphics( inputGraphics, // 元の画像を保持するグラフィックスリソース fromRed, fromGreen, fromBlue, fromAlpha, // 変換したい色(ユーザーが選んだ色) toRed, toGreen, toBlue, toAlpha // 変換後の色(透明) ); // 別のファイル名をつけて保存 string outputFilePath = inputFilePath + "_clear.png"; // 保存ファイル名=元の名前+_clear.png exportGraphics(outputGraphics, outputFilePath, "PNG"); // PNG形式のファイルとして保存 pop("変換しました。保存ファイル: " + outputFilePath); // 完了メッセージをユーザーに表示 // リソースを破棄してプログラム終了 deleteGraphics(inputGraphics); deleteGraphics(outputGraphics); exit();