//============================================================ // <T>打开数据内容。</T> //============================================================ public void Open() { if (null != _image) { _image.Dispose(); _image = null; } _image = new FBitmap(); _image.LoadFile(_fileName); _size.Set(_image.Width, _image.Height); _length = new FileInfo(_fileName).Length; }
//============================================================ // <T>序列化数据。</T> //============================================================ public void Export() { // 加载高度图 _heightData.LoadFile(_path + "/texture/" + _textureHeight); _colorData.LoadFile(_path + "/texture/" + _textureColor); for (int n = 1; n <= _layerCount; n++) { FBitmap layerBitmap = _layers[n - 1].Bitmap; layerBitmap.LoadFile(_path + "/texture/level-" + n + ".jpg"); } //............................................................ FCompressFile file = new FCompressFile(); // 存储编号 file.WriteUint32((uint)_id); // 存储层数 file.WriteUint16((ushort)_layerCount); // 当前地图的宽度和高度 file.WriteUint16((ushort)_size.Width); file.WriteUint16((ushort)_size.Height); // 当前范围的宽度和高度 file.WriteUint16((ushort)_range.Width); file.WriteUint16((ushort)_range.Height); file.WriteFloat(_deep); // 存储材质列表 file.WriteInt16((short)_layers.Count); foreach (FDrMapLayer layer in _layers) { string materialCode = RDrUtil.FormatPathToCode(layer.MaterialName); file.WriteInt16((short)layer.Index); file.WriteString(materialCode); FDrMaterialGroup material = RContent3dManager.MaterialConsole.FindGroup(layer.MaterialName); material.Serialize(file); } // 输出文件 file.SaveFile(_exportFilePath + "\\config.swf"); //............................................................ // 导出地图块 int cx = _size.Width / _range.Width; int cy = _size.Height / _range.Height; for (int y = 0; y < cy; y++) { for (int x = 0; x < cx; x++) { ExportRange(x, y); } } // RangeIncise(); _logger.Debug(this, "Export", "Export template success. (file_name={0})", _exportFileName); }
//============================================================ // <T>打开资源。</T> //============================================================ public override void Open() { if (!_statusOpen) { base.Open(); // 打开图片资源 _bitmap.LoadFile(_fileName); int length = (int)RFile.GetFileLength(_fileName); _size.Width = _bitmap.Width; _size.Height = _bitmap.Height; // 测试有效区域 RBitmap.TestValidRectangle(_bitmap.Native, _validRectangle, _qualityAlpha); } }