码迷,mamicode.com
首页 > 其他好文 > 详细

unit图片处理成游戏角色

时间:2018-04-15 12:06:42      阅读:165      评论:0      收藏:0      [点我收藏+]

标签:[]   文件名   list   object   app   window   private   threading   col   

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图片处理成游戏角色

标签:[]   文件名   list   object   app   window   private   threading   col   

原文地址:https://www.cnblogs.com/agchuanqi/p/8836843.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!