예제 #1
0
 //============================================================
 // <T>压缩数据保存为指定文件。</T>
 //
 // @param fileName 文件名称
 //============================================================
 public void Compress(string fileName)
 {
     // 建立目录
     RDirectory.MakeDirectoriesForFile(fileName);
     // 输出文件
     byte[] data = InnerCompress(_memory, 0, _length);
     using (FByteFile file = new FByteFile()) {
         file.Assign(data, 0, data.Length);
         file.SaveFile(fileName);
     }
 }
예제 #2
0
        //============================================================
        // <T>导出资源。</T>
        //============================================================
        public void Merge()
        {
            // 计算范围
            int             clipCount  = ClipNotEmptyCount;
            FRsResourceClip firstClip  = FristClip;
            int             frameCount = 0;

            if (null != firstClip)
            {
                frameCount = firstClip.FrameCount;
            }
            else
            {
                RMoCore.TrackConsole.Write(this, "Merge", "Animatioin is valid, first clip is empty. (code={0})", Code);
                return;
            }
            int width  = _size.Width * frameCount;
            int height = _size.Height * clipCount;

            // 计算是否合并
            using (Bitmap bitmap = new Bitmap(width, height)) {
                // 合并图片
                int y = 0;
                foreach (FRsResourceClip clip in _clips)
                {
                    if (clip != null)
                    {
                        if (!clip.Frames.IsEmpty())
                        {
                            for (int x = 0; x < frameCount; x++)
                            {
                                FRsResourceFrame frame = clip.Frames[x];
                                int cx = _size.Width * x;
                                int cy = _size.Height * y;
                                if (frame.ValidBitmap != null)
                                {
                                    frame.MergeLocation.Set(cx, cy);
                                    RBitmap.Copy(frame.ValidBitmap, new SIntRectangle(0, 0, frame.ValidBitmap.Width, frame.ValidBitmap.Height), bitmap, frame.MergeLocation);
                                }
                            }
                            y++;
                        }
                    }
                }
                // 存储图片
                _mergeFileName = RContent2dManager.ResourceConsole.MergeDirectory + "\\" + Code + ".png";
                RDirectory.MakeDirectoriesForFile(_mergeFileName);
                bitmap.Save(_mergeFileName);
                _mergeSize.Set(bitmap.Width, bitmap.Height);
            }
        }