/// <summary> /// 导入图片 /// </summary> /// <param name="index">导入图片在Grid的位置</param> /// <param name="filePath">图片的存放位置</param> /// <param name="rotateFlipType">是否翻转</param> private void ImportImgByIndex(int index, string filePath, RotateFlipType rotateFlipType) { ImageHeader headerInfo = this.tplImageInfo[index]; Bitmap importImg = new Bitmap(filePath); importImg.RotateFlip(rotateFlipType); byte[] byImg; List <byte> byPalette = new List <byte>(); if (headerInfo.Format.Equals("C4_CI4") || headerInfo.Format.Equals("C8_CI8") || headerInfo.Format.Equals("C14X2_CI14x2")) { byImg = Util.PaletteImageEncode(importImg, headerInfo.Format, byPalette, headerInfo.PaletteFormat); } else { byImg = Util.ImageEncode(importImg, headerInfo.Format); } // 替换Tpl文件数据 TplFileManager tplEditor = new TplFileManager(); this.byOldData = tplEditor.TplImgImport(this.byOldData, index, byImg, byPalette.ToArray()); // 更新图片 Image img; if ("CMPR".Equals(headerInfo.Format)) { img = Util.CmprImageDecode( new Bitmap(importImg.Width, importImg.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb), byImg); } else if (headerInfo.Format.Equals("C4_CI4") || headerInfo.Format.Equals("C8_CI8") || headerInfo.Format.Equals("C14X2_CI14x2")) { img = Util.PaletteImageDecode( new Bitmap(importImg.Width, importImg.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb), byImg, headerInfo.Format, byPalette.ToArray(), headerInfo.PaletteFormat); } else { img = Util.ImageDecode( new Bitmap(importImg.Width, importImg.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb), byImg, headerInfo.Format); } this.tplImageView.Rows[index].Cells[0].Value = img; }
/// <summary> /// 显示节点信息 /// </summary> private void ShowTreeNodeInfo(TreeNode treeNode) { if (treeNode.Tag != null) { // 解析双击的文件 RarcNode fileInfo = (RarcNode)treeNode.Tag; if (string.IsNullOrEmpty(fileInfo.FileType) || fileInfo == null || fileInfo.FileData == null || fileInfo.FileData.Length == 0) { return; } try { switch (fileInfo.FileType.ToLower()) { case "bti": this.imgViewer.Image = Util.BtiDecode(fileInfo.FileData); this.ShowPanelRight(this.imgViewer); break; case "bmg": //this.txtFileInfo.Text = Util.DecodeByteArray(fileInfo.FileData, Encoding.GetEncoding(932).GetDecoder()); this.txtFileInfo.Text = Util.BmgDecode(fileInfo.FileData); this.ShowPanelRight(this.txtFileInfo); break; case "bfn": NgcFontEditer ngcFontView = new NgcFontEditer(fileInfo.FileData); ngcFontView.Show(); break; case "brfnt": WiiFontEditer wiiFontView = new WiiFontEditer(); wiiFontView.Show(); this.Do(wiiFontView.ViewFontInfo, fileInfo.FileData); break; case "tpl": List <ImageHeader> tplImageInfo = new List <ImageHeader>(); Image[] tplImages = new TplFileManager().TplDecode(fileInfo.FileData, tplImageInfo); this.viewDataStartPos = fileInfo.DataStartPos; this.nodeFileName = fileInfo.FileName; this.ucImageViewer.strFileOpen = fileInfo.FileName; this.ucImageViewer.OutSaveFunc += this.SaveTpl; this.ucImageViewer.OutSetText += this.SetTplInfo; this.ucImageViewer.ViewImage(tplImages, tplImageInfo, fileInfo.FileData); this.ShowPanelRight(this.ucImageViewer); break; default: //MessageBox.Show("不支持的格式 : " + fileInfo.FileType); break; } } catch (Exception me) { MessageBox.Show(me.Message + "\n" + me.StackTrace); } } }