Beispiel #1
0
        //============================================================
        // <T>格式化数字为颜色字符串。</T>
        //
        // @param value 数字
        // @param length 长度
        // @return 字符串
        //============================================================
        public static string FormatHex(int value, int length = 8)
        {
            string source = String.Format("{0:X}", value);

            source = RString.PadLeft(source, length, '0');
            return(source);
        }
Beispiel #2
0
        //============================================================
        // <T>导出多个打包到目录。</T>
        //
        // @param fileName 文件名称
        // @param widthCount 横向分割个数
        // @param hightCount 纵向分割个数
        //============================================================
        public void ExportPath(string path, int tileWidth, int tileHight, int colorCount, int widthCount, int hightCount)
        {
            // 计算分割数量
            int tileCx = _bitmap.Width / tileWidth;
            int tileCy = _bitmap.Height / tileHight;

            // 分割图片
            for (int y = 0; y < tileCy; y++)
            {
                for (int x = 0; x < tileCx; x++)
                {
                    // 绘制局部图形
                    FBitmap bitmap = new FBitmap(tileWidth, tileHight);
                    bitmap.Fill(_bitmap, tileWidth * x, tileHight * y);
                    // 存储索引图片
                    string fileName = path + "_" + RString.PadLeft(y.ToString(), 2, '0') + "_" + RString.PadLeft(x.ToString(), 2, '0') + "." + EXTEND_NAME;
                    _logger.Debug(this, "ExportPath", "Export path file. (file_name={0}, color_count={1}, width_count={2}, hight_count={3})",
                                  fileName, colorCount, widthCount, hightCount);

                    FLzmaFile file = new FLzmaFile();
                    file.EnsureSize(tileWidth * tileHight);
                    StoreCompress(file, bitmap.Native, colorCount, widthCount, hightCount);
                    file.Compress(fileName);
                    file.Reset();
                }
            }
        }