1. 程式人生 > >unit圖片處理成遊戲角色

unit圖片處理成遊戲角色

eve thread ati each else tex ons void sap

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{

private void Form1_Load(object sender, EventArgs e)
{

}


public Form1()
{
InitializeComponent();


// 獲取當前路徑下全部文件名
//String[] files = Directory.GetFiles("F:\\clo1");

int[] aescs = { 5, 4, 3, 2, 1, 8, 7, 6 };
List<string> files = new List<string>();

for(int j = 0; j < 8; ++j)
{
for (int i = 0; i < 4; ++i)
{
files.Add("F:/clo1/子圖_1_"+ aescs[j] + "_png/" + i + ".png");
}
}

for (int j = 0; j < 8; ++j)
{
for (int i = 0; i < 6; ++i)
{
files.Add("F:/clo1/子圖_2_" + aescs[j] + "_png/" + i + ".png");
}
}

for (int j = 0; j < 8; ++j)
{
for (int i = 0; i < 6; ++i)
{
files.Add("F:/clo1/子圖_5_" + aescs[j] + "_png/" + i + ".png");
}
}
for (int j = 0; j < 8; ++j)
{
for (int i = 0; i < 6; ++i)
{
files.Add("F:/clo1/子圖_6_" + aescs[j] + "_png/" + i + ".png");
}
}


int cur = 0;
foreach (String filename in files)
{
// 最後一個"\"
int lastpath = filename.LastIndexOf("/");
// 最後一個"."
int lastdot = filename.LastIndexOf(".");
// 純文件名字長度
int length = lastdot - lastpath - 1;
// 文件目錄字符串 xx\xx\xx\
String beginpart = filename.Substring(0, lastpath + 1);
// 純文件名字
String namenoext = filename.Substring(lastpath + 1, length);
// 擴展名
String ext = filename.Substring(lastdot);


// 補齊為3位,組成新的文件名
String namenew;
if (cur < 10)
namenew = "22900" + cur;
else if (cur < 100)
namenew = "2290" + cur;
else
namenew = "229" + cur;
String fullnewname = "F:/clo2/" + namenew + ext;
// 改名
File.Move(filename, fullnewname);
++cur;
}
}
}
}

unit圖片處理成遊戲角色