private void Import_Palette_By_Address(uint palette_address) { Bitmap bitmap = ImageFormRef.ImportFilenameDialog(this); if (bitmap == null) { return; } int palette_count = 1; int bitmap_palette_count = ImageUtil.GetPalette16Count(bitmap); if (bitmap_palette_count > palette_count) { R.ShowStopError("パレット数が正しくありません。\r\n{1}種類以下(16色*{1}種類) でなければなりません。\r\n\r\n選択された画像のパレット種類:{0}種類", bitmap_palette_count, palette_count); return; } //パレット byte[] palette = ImageUtil.ImageToPalette(bitmap, palette_count); Program.Undo.Push(this.Text + "_unit_icon", palette_address, 0x20); Program.ROM.write_range(palette_address, palette); IconRedraw(); InputFormRef.ShowWriteNotifyAnimation(this, palette_address); }
private void ImportButton_Click(object sender, EventArgs e) { Bitmap bitmap = ImageFormRef.ImportFilenameDialog(this); if (bitmap == null) { return; } int width = 2 * 8; int height = 2 * 8; if (bitmap.Width != width || bitmap.Height != height) { R.ShowStopError("画像サイズが正しくありません。\r\nWidth:{2} Height:{3} でなければなりません。\r\n\r\n選択された画像のサイズ Width:{0} Height:{1}", bitmap.Width, bitmap.Height, width, height); return; } uint skillPaletteAddress = GetSkillPaletteAddress((uint)W2.Value); //check palette { string palette_error = ImageUtil.CheckPalette(bitmap.Palette , Program.ROM.Data , skillPaletteAddress , U.NOT_FOUND ); if (palette_error != "") { ErrorPaletteShowForm f = (ErrorPaletteShowForm)InputFormRef.JumpFormLow <ErrorPaletteShowForm>(); f.SetErrorMessage(palette_error); f.SetOrignalImage(ImageUtil.OverraidePalette(bitmap, Program.ROM.Data, skillPaletteAddress)); f.SetReOrderImage1(ImageUtil.ReOrderPalette(bitmap, Program.ROM.Data, skillPaletteAddress)); f.ShowForceButton(); f.ShowDialog(); bitmap = f.GetResultBitmap(); if (bitmap == null) { return; } } } uint index = (uint)this.AddressList.SelectedIndex; uint iconbaseaddr = Program.ROM.p32(Program.ROM.RomInfo.icon_pointer()); uint size = 16 * 16 / 2; // /2しているのは16色のため uint addr = iconbaseaddr + (size * (0x100 + index)); byte[] image = ImageUtil.ImageToByte16Tile(bitmap, width, height); //画像等データの書き込み Undo.UndoData undodata = Program.Undo.NewUndoData(this); Program.ROM.write_range(U.toOffset(addr), image, undodata); Program.Undo.Push(undodata); InputFormRef.ReloadAddressList(); InputFormRef.ShowWriteNotifyAnimation(this, addr); }
private void ImportButton_Click(object sender, EventArgs e) { Bitmap bitmap = ImageFormRef.ImportFilenameDialog(this); if (bitmap == null) { return; } int width = MAP_X * 8; int height = MAP_Y * 8; int palette_count = 4; if (bitmap.Width != width || bitmap.Height != height) { R.ShowStopError("画像サイズが正しくありません。\r\nWidth:{2} Height:{3} でなければなりません。\r\n\r\n選択された画像のサイズ Width:{0} Height:{1}", bitmap.Width, bitmap.Height, width, height); return; } int bitmap_palette_count = ImageUtil.GetPalette16Count(bitmap); if (bitmap_palette_count > palette_count) { R.ShowStopError("パレット数が正しくありません。\r\n{1}種類以下(16色*{1}種類) でなければなりません。\r\n\r\n選択された画像のパレット種類:{0}種類", bitmap_palette_count, palette_count); return; } //元画像 this.IsNotUseList = new List <int>(); this.HeightList = new List <int>(); Bitmap orignalBitmap = GetChipImage(this.IsNotUseList, this.HeightList); byte[] orignalImage = ImageUtil.ImageToByte16Tile(orignalBitmap, orignalBitmap.Width, orignalBitmap.Height); orignalBitmap.Dispose(); //TSAを維持して、元画像に最小限の変化を加えたもの. byte[] saveImage = ImageUtil.ImageToByteKeepTSA(bitmap, width, height, this.Map, orignalImage); //画像等データの書き込み Undo.UndoData undodata = Program.Undo.NewUndoData(this); using (InputFormRef.AutoPleaseWait pleaseWait = new InputFormRef.AutoPleaseWait(this)) { //画像データを5分割して書き込み RevChipImage(saveImage, undodata); //パレットデータの書き込み byte[] paletteData = ImageUtil.ImageToPalette(bitmap, palette_count); uint newPaletteAddr = ImageFormRef.WriteImageData(this , Program.ROM.p32(Program.ROM.RomInfo.battle_screen_palette_pointer()) , Program.ROM.RomInfo.battle_screen_palette_pointer() , paletteData, false, undodata); Program.Undo.Push(undodata); PALETTE_ADDRESS.Value = newPaletteAddr; this.PaletteIndexComboBox.SelectedIndex = 0; } LoadChipsetInfo(); //チップセット関係の読込 LoadBattleScreen(); //ROM TSAをメモリに読み込んで MakeBattleScreen(); //TSA描画 }
private void ObjImportButton_Click(object sender, EventArgs e) { if (this.MapStyle.SelectedIndex < 0) { return; } Bitmap bitmap = ImageFormRef.ImportFilenameDialog(this); if (bitmap == null) { return; } MapStyleEditorImportImageOptionForm f = (MapStyleEditorImportImageOptionForm)InputFormRef.JumpFormLow <MapStyleEditorImportImageOptionForm>(); DialogResult dr = f.ShowDialog(); if (dr != System.Windows.Forms.DialogResult.OK) { return; } if (f.ImportOption == MapStyleEditorImportImageOptionForm.ImportOptionEnum.WithPalette) { ImportObj(bitmap, importObjWithPalette: true); } else if (f.ImportOption == MapStyleEditorImportImageOptionForm.ImportOptionEnum.ImageOnly) { ImportObj(bitmap, importObjWithPalette: false); } else if (f.ImportOption == MapStyleEditorImportImageOptionForm.ImportOptionEnum.OnePicture) { ImportObjOnePicture(bitmap); } }
private void ImportButton3_Click(object sender, EventArgs e) { Bitmap bitmap = ImageFormRef.ImportFilenameDialog(this); if (bitmap == null) { return; } int width = 18 * 8; int height = 2 * 8; if (bitmap.Width != width || bitmap.Height != height) { R.ShowStopError("画像サイズが正しくありません。\r\nWidth:{2} Height:{3} でなければなりません。\r\n\r\n選択された画像のサイズ Width:{0} Height:{1}", bitmap.Width, bitmap.Height, width, height); return; } byte[] image = ImageUtil.ImageToByte16Tile(bitmap, width, height); using (InputFormRef.AutoPleaseWait pleaseWait = new InputFormRef.AutoPleaseWait(this)) { //画像等データの書き込み Undo.UndoData undodata = Program.Undo.NewUndoData(this); this.InputFormRef.WriteImageData(this.P8, image, true, undodata); Program.Undo.Push(undodata); } //ポインタの書き込み this.WriteButton.PerformClick(); }
private void ImportButton_Click(object sender, EventArgs e) { Bitmap bitmap = ImageFormRef.ImportFilenameDialog(this); if (bitmap == null) { return; } int width = 4 * 8; int height = 60 * 8; if (width != bitmap.Width || height > bitmap.Height) { Bitmap newbitmap = ImageUtil.ConvertSizeFormat(bitmap, width, height); if (newbitmap == null) { R.ShowStopError("画像サイズが正しくありません。\r\nWidth:{2} Height:{3} でなければなりません。\r\n\r\n選択された画像のサイズ Width:{0} Height:{1}", bitmap.Width, bitmap.Height, width, height); return; } bitmap.Dispose(); bitmap = newbitmap; } //check palette { string palette_error = ImageUtil.CheckPalette(bitmap.Palette , Program.ROM.Data , (Program.ROM.RomInfo.unit_icon_palette_address()) , (Program.ROM.RomInfo.unit_icon_enemey_palette_address()) ); if (palette_error != "") { ErrorPaletteShowForm f = (ErrorPaletteShowForm)InputFormRef.JumpFormLow <ErrorPaletteShowForm>(); f.SetErrorMessage(palette_error); f.SetOrignalImage(ImageUtil.OverraidePalette(bitmap, Program.ROM.Data, (Program.ROM.RomInfo.unit_icon_palette_address()))); f.SetReOrderImage1(ImageUtil.ReOrderPalette(bitmap, Program.ROM.Data, (Program.ROM.RomInfo.unit_icon_palette_address()))); f.SetReOrderImage2(ImageUtil.ReOrderPalette(bitmap, Program.ROM.Data, (Program.ROM.RomInfo.unit_icon_enemey_palette_address()))); f.ShowForceButton(); f.ShowDialog(); bitmap = f.GetResultBitmap(); if (bitmap == null) { return; } } } byte[] image = ImageUtil.ImageToByte16Tile(bitmap, bitmap.Width, bitmap.Height); //画像等データの書き込み Undo.UndoData undodata = Program.Undo.NewUndoData(this); this.InputFormRef.WriteImageData(this.P0, image, true, undodata); Program.Undo.Push(undodata); //ポインタの書き込み this.WriteButton.PerformClick(); }
private void ImportButton_Click(object sender, EventArgs e) { Bitmap bitmap = ImageFormRef.ImportFilenameDialog(this); if (bitmap == null) { return; } int width = 32 * 8; int height = GetThisImageHeight(); int palette_count = 8; if (bitmap.Width != width || bitmap.Height != height) { if (bitmap.Width != 30 * 8 || bitmap.Height != height) { R.ShowStopError("画像サイズが正しくありません。\r\nWidth:{2} Height:{3} でなければなりません。\r\n\r\n選択された画像のサイズ Width:{0} Height:{1}", bitmap.Width, bitmap.Height, width, height); return; } //右側に余白がない場合、自動的に挿入する bitmap = ImageUtil.Copy(bitmap, 0, 0, width, height); } int bitmap_palette_count = ImageUtil.GetPalette16Count(bitmap); if (bitmap_palette_count > palette_count) { string error = R._("パレット数が正しくありません。\r\n{1}種類以下(16色*{1}種類) でなければなりません。\r\n\r\n選択された画像のパレット種類:{0}種類", bitmap_palette_count, palette_count) + "\r\n" + DecreaseColorTSAToolForm.GetExplainDecreaseColor(); R.ShowStopError(error); return; } byte[] image; //画像 byte[] tsa; //TSA string error_string = ImageUtil.ImageToByteHeaderPackedTSA(bitmap, width, height, out image, out tsa); if (error_string != "") { error_string += "\r\n" + DecreaseColorTSAToolForm.GetExplainDecreaseColor(); R.ShowStopError(error_string); return; } //パレット byte[] palette = ImageUtil.ImageToPalette(bitmap, palette_count); using (InputFormRef.AutoPleaseWait pleaseWait = new InputFormRef.AutoPleaseWait(this)) { //画像等データの書き込み Undo.UndoData undodata = Program.Undo.NewUndoData(this); this.InputFormRef.WriteImageData(this.P0, image, true, undodata); this.InputFormRef.WriteImageData(this.P4, palette, false, undodata); this.InputFormRef.WriteImageData(this.P8, tsa, true, undodata); Program.Undo.Push(undodata); } //ポインタの書き込み this.WriteButton.PerformClick(); }
private void ImportButton3_Click(object sender, EventArgs e) { Bitmap bitmap = ImageFormRef.ImportFilenameDialog(this); if (bitmap == null) { return; } int width = 18 * 8; int height = 2 * 8; if (bitmap.Width != width || bitmap.Height != height) { R.ShowStopError("画像サイズが正しくありません。\r\nWidth:{2} Height:{3} でなければなりません。\r\n\r\n選択された画像のサイズ Width:{0} Height:{1}", bitmap.Width, bitmap.Height, width, height); return; } //check palette { string palette_error = ImageUtil.CheckPalette(bitmap.Palette , Program.ROM.Data , Program.ROM.RomInfo.image_chapter_title_palette() , U.NOT_FOUND ); if (palette_error != "") { ErrorPaletteShowForm f = (ErrorPaletteShowForm)InputFormRef.JumpFormLow <ErrorPaletteShowForm>(); f.SetErrorMessage(palette_error); f.SetOrignalImage(ImageUtil.OverraidePalette(bitmap, Program.ROM.Data, Program.ROM.RomInfo.image_chapter_title_palette())); f.SetReOrderImage1(ImageUtil.ReOrderPalette(bitmap, Program.ROM.Data, Program.ROM.RomInfo.image_chapter_title_palette())); f.ShowForceButton(); f.ShowDialog(); bitmap = f.GetResultBitmap(); if (bitmap == null) { return; } } } byte[] image = ImageUtil.ImageToByte16Tile(bitmap, width, height); using (InputFormRef.AutoPleaseWait pleaseWait = new InputFormRef.AutoPleaseWait(this)) { //画像等データの書き込み Undo.UndoData undodata = Program.Undo.NewUndoData(this); this.InputFormRef.WriteImageData(this.P8, image, true, undodata); Program.Undo.Push(undodata); } //ポインタの書き込み this.WriteButton.PerformClick(); }
private void PaletteImportButton_Click(object sender, EventArgs e) { if (this.MapStyle.SelectedIndex < 0) { return; } uint palette_plist = this.MapEditConf[this.MapStyle.SelectedIndex].palette_plist; uint obj_plist = this.MapEditConf[this.MapStyle.SelectedIndex].obj_plist; Bitmap bitmap = ImageFormRef.ImportFilenameDialog(this); if (bitmap == null) { return; } bool r = MapPaletteImport(bitmap, palette_plist); if (!r) { return; } //パレットの交換 this.MapObjImage = ImageUtilMap.DrawMapChipOnly(obj_plist, palette_plist); if (this.MapObjImage == null) { this.MapObjImage = ImageUtil.BlankDummy(); } U.ForceUpdate(this.PaletteCombo, 0); //チップセットの更新. Chipset_Update(); SelectedChipset_Update(); MapStyle_SelectedIndexChanged(sender, e); InputFormRef.WriteButtonToYellow(this.PaletteWriteButton, false); //マップエディタが開いていれば更新する MapEditorForm.UpdateMapStyleIfOpen(); }
private void DarkMAPImportButton_Click(object sender, EventArgs e) { Bitmap bitmap = ImageFormRef.ImportFilenameDialog(this); if (bitmap == null) { return; } int width = 480; int height = 320; int palette_count = 4; if (bitmap.Width != width || bitmap.Height != height) { R.ShowStopError("画像サイズが正しくありません。\r\nWidth:{2} Height:{3} でなければなりません。\r\n\r\n選択された画像のサイズ Width:{0} Height:{1}", bitmap.Width, bitmap.Height, width, height); return; } int bitmap_palette_count = ImageUtil.GetPalette16Count(bitmap); if (bitmap_palette_count > palette_count) { R.ShowStopError("パレット数が正しくありません。\r\n{1}種類以下(16色*{1}種類) でなければなりません。\r\n\r\n選択された画像のパレット種類:{0}種類", bitmap_palette_count, palette_count); return; } //パレット byte[] palette = ImageUtil.ImageToPalette(bitmap, palette_count); //画像等データの書き込み Undo.UndoData undodata = Program.Undo.NewUndoData(this); ImageFormRef.WriteImageData(this, this.WMdPalette , Program.ROM.RomInfo.worldmap_big_dpalette_pointer() , palette, false, undodata); Program.Undo.Push(undodata); //ポインタの書き込み this.AllWriteButton.PerformClick(); }
private void ImportButton_Click(object sender, EventArgs e) { Bitmap bitmap = ImageFormRef.ImportFilenameDialog(this); if (bitmap == null) { return; } int width = 32 * 8; int height = GetHight((uint)this.W2.Value); int palette_count = 5; if (bitmap.Width != width || bitmap.Height != height) { R.ShowStopError("画像サイズが正しくありません。\r\nWidth:{2} Height:{3} でなければなりません。\r\n\r\n選択された画像のサイズ Width:{0} Height:{1}", bitmap.Width, bitmap.Height, width, height); return; } int bitmap_palette_count = ImageUtil.GetPalette16Count(bitmap); if (bitmap_palette_count > palette_count) { R.ShowStopError("パレット数が正しくありません。\r\n{1}種類以下(16色*{1}種類) でなければなりません。\r\n\r\n選択された画像のパレット種類:{0}種類", bitmap_palette_count, palette_count); return; } byte[] image = ImageUtil.ImageToByte16Tile(bitmap, width, height); using (InputFormRef.AutoPleaseWait pleaseWait = new InputFormRef.AutoPleaseWait(this)) { //画像等データの書き込み Undo.UndoData undodata = Program.Undo.NewUndoData(this); this.InputFormRef.WriteImageData(this.P4, image, false, undodata); Program.Undo.Push(undodata); } //ポインタの書き込み this.WriteButton.PerformClick(); }
private void ImportButton_Click(object sender, EventArgs e) { Bitmap bitmap = ImageFormRef.ImportFilenameDialog(this); if (bitmap == null) { return; } uint b2 = U.NOT_FOUND; if (bitmap.Width == 16) { if (bitmap.Height == 48) { b2 = 0; } else if (bitmap.Height == 96) { b2 = 1; } } else if (bitmap.Width == 32) { if (bitmap.Height == 96) { b2 = 2; } } if (b2 == U.NOT_FOUND) { R.ShowStopError("画像サイズが正しくありません。\r\n以下のどれかにする必要があります。\r\n16x48\r\n16x96\r\n32x96\r\n\r\n選択された画像のサイズ Width:{0} Height:{1}", bitmap.Width, bitmap.Height); return; } //check palette { string palette_error = ImageUtil.CheckPalette(bitmap.Palette , Program.ROM.Data , (Program.ROM.RomInfo.unit_icon_palette_address()) , (Program.ROM.RomInfo.unit_icon_enemey_palette_address()) ); if (palette_error != "") { ErrorPaletteShowForm f = (ErrorPaletteShowForm)InputFormRef.JumpFormLow <ErrorPaletteShowForm>(); f.SetErrorMessage(palette_error); f.SetOrignalImage(ImageUtil.OverraidePalette(bitmap, Program.ROM.Data, (Program.ROM.RomInfo.unit_icon_palette_address()))); f.SetReOrderImage1(ImageUtil.ReOrderPalette(bitmap, Program.ROM.Data, (Program.ROM.RomInfo.unit_icon_palette_address()))); f.SetReOrderImage2(ImageUtil.ReOrderPalette(bitmap, Program.ROM.Data, (Program.ROM.RomInfo.unit_icon_enemey_palette_address()))); f.ShowForceButton(); f.ShowDialog(); bitmap = f.GetResultBitmap(); if (bitmap == null) { return; } } } byte[] image = ImageUtil.ImageToByte16Tile(bitmap, bitmap.Width, bitmap.Height); //画像等データの書き込み Undo.UndoData undodata = Program.Undo.NewUndoData(this); this.InputFormRef.WriteImageData(this.P4, image, true, undodata); Program.Undo.Push(undodata); this.W2.Value = b2; //ポインタの書き込み this.WriteButton.PerformClick(); }
private void ImportButton_Click(object sender, EventArgs e) { Bitmap bitmap = ImageFormRef.ImportFilenameDialog(this); if (bitmap == null) { return; } int width = 1024; int height = 688; int palette_count = 4; if (bitmap.Width != width || bitmap.Height != height) { R.ShowStopError("画像サイズが正しくありません。\r\nWidth:{2} Height:{3} でなければなりません。\r\n\r\n選択された画像のサイズ Width:{0} Height:{1}", bitmap.Width, bitmap.Height, width, height); return; } int bitmap_palette_count = ImageUtil.GetPalette16Count(bitmap); if (bitmap_palette_count > palette_count) { R.ShowStopError("パレット数が正しくありません。\r\n{1}種類以下(16色*{1}種類) でなければなりません。\r\n\r\n選択された画像のパレット種類:{0}種類", bitmap_palette_count, palette_count); return; } List <byte[]> images = new List <byte[]>(); List <byte[]> tsaes = new List <byte[]>(); //データは、1024x688 だが、内部データは 1024x768で計算しているみたいなので、足りないラインを増設します. for (int y = 0; y < 2; y++) { for (int x = 0; x < 4; x++) { Bitmap piece = ImageUtil.Copy( bitmap , x * 256 , y * 256 , 256, 256 ); byte[] image; //画像 byte[] tsa; //TSA string error_string = ImageUtil.ImageToByteHeaderPackedTSA( piece , 256, 256 , out image, out tsa , 0 //余白を作らない , false //同一タイルの最適化をしない ); if (error_string != "") { R.ShowStopError("12分割のx:{0} y:{1} w:256 h:256の部分の中で問題がありました" , x * 256, y * 256 , error_string); return; } images.Add(image); tsaes.Add(tsa); } } { int y = 2; for (int x = 0; x < 4; x++) { //最後のラインは、heightが 176なのだが、TSAを計算するときは 256でやる必要がある. Bitmap piece = ImageUtil.Copy( bitmap , x * 256 , y * 256 , 256, 256); byte[] image; //画像 byte[] tsa; //TSA string error_string = ImageUtil.ImageToByteHeaderPackedTSA(piece , 256, 256 , out image, out tsa , 0 //余白を作らない , false //同一タイルの最適化をしない ); if (error_string != "") { R.ShowStopError("12分割のx:{0} y:{1} w:256 h:256の部分の中で問題がありました" , x * 256, y * 256 , error_string); return; } //imageだけ高さを 176に変更します. image = U.subrange(image, 0, 256 / 2 * 176); images.Add(image); tsaes.Add(tsa); } } //パレット byte[] palette_data = ImageUtil.ImageToPalette(bitmap, palette_count); //画像等データの書き込み Undo.UndoData undodata = Program.Undo.NewUndoData(this); //すべて無圧縮データなのでそのままかけます. 位置の変換は絶対に起きえません. uint imagemap = Program.ROM.p32(Program.ROM.RomInfo.worldmap_big_image_pointer()); uint palette = Program.ROM.p32(Program.ROM.RomInfo.worldmap_big_palette_pointer()); uint tsamap = Program.ROM.p32(Program.ROM.RomInfo.worldmap_big_palettemap_pointer()); Program.ROM.write_range(palette, palette_data, undodata); int index = 0; for (int y = 0; y < 3; y++) { for (int x = 0; x < 4; x++) { uint image = Program.ROM.p32(imagemap); uint tsa = Program.ROM.p32(tsamap); Program.ROM.write_range(image, images[index], undodata); Program.ROM.write_range(tsa, tsaes[index], undodata); imagemap += 4; tsamap += 4; index++; } } Program.Undo.Push(undodata); //ポインタの書き込み this.AllWriteButton.PerformClick(); WMPictureBox.Image = DrawWorldMap(); }
private void ImportButton_Click(object sender, EventArgs e) { Bitmap bitmap = ImageFormRef.ImportFilenameDialog(this); if (bitmap == null) { return; } int width = 480; int height = 320; int palette_count = 4; if (bitmap.Width != width || bitmap.Height != height) { R.ShowStopError("画像サイズが正しくありません。\r\nWidth:{2} Height:{3} でなければなりません。\r\n\r\n選択された画像のサイズ Width:{0} Height:{1}", bitmap.Width, bitmap.Height, width, height); return; } int bitmap_palette_count = ImageUtil.GetPalette16Count(bitmap); if (bitmap_palette_count > palette_count) { R.ShowStopError("パレット数が正しくありません。\r\n{1}種類以下(16色*{1}種類) でなければなりません。\r\n\r\n選択された画像のパレット種類:{0}種類", bitmap_palette_count, palette_count); return; } //画像 byte[] image = ImageUtil.ImageToByte16Tile(bitmap, width, height); //パレットマップの作成 byte[] palettemap; string error_string = ImageUtil.ImageToPaletteMap(bitmap, width, height, palette_count, out palettemap); if (error_string != "") { R.ShowStopError(error_string); return; } //パレット byte[] palette = ImageUtil.ImageToPalette(bitmap, palette_count); using (InputFormRef.AutoPleaseWait pleaseWait = new InputFormRef.AutoPleaseWait(this)) { //画像等データの書き込み Undo.UndoData undodata = Program.Undo.NewUndoData(this); ImageFormRef.WriteImageData(this, this.WMImage , Program.ROM.RomInfo.worldmap_big_image_pointer() , image, false, undodata); ImageFormRef.WriteImageData(this, this.WMPalette , Program.ROM.RomInfo.worldmap_big_palette_pointer() , palette, false, undodata); ImageFormRef.WriteImageData(this, this.WMPaletteMap , Program.ROM.RomInfo.worldmap_big_palettemap_pointer() , palettemap, true, undodata); //パレットマップだけ lz77圧縮 Program.Undo.Push(undodata); } //ポインタの書き込み this.AllWriteButton.PerformClick(); WMPictureBox.Image = DrawWorldMap(); }
private void ObjImportButton_Click(object sender, EventArgs e) { if (this.MapStyle.SelectedIndex < 0) { return; } uint obj_plist = this.MapEditConf[this.MapStyle.SelectedIndex].obj_plist; uint obj2_plist = (obj_plist >> 8) & 0xFF; //FE8にはないが FE7は、 plistを2つ設定できることがある. Bitmap bitmap = ImageFormRef.ImportFilenameDialog(this); if (bitmap == null) { return; } int width = 32 * 8; int height = 32 * 8; int palette_count = MAX_MAP_PALETTE_COUNT; if (bitmap.Width != width || bitmap.Height < 128) { R.ShowStopError("画像サイズが正しくありません。\r\nWidth:{2} Height:{3} でなければなりません。\r\n\r\n選択された画像のサイズ Width:{0} Height:{1}", bitmap.Width, bitmap.Height, width, height); return; } height = ImageUtil.CalcHeight(width, width * bitmap.Height / 2); if (ObjImportOption.SelectedIndex == 1) {//パレットもインポートする場合 パレット数のチェック. int bitmap_palette_count = ImageUtil.GetPalette16Count(bitmap); if (bitmap_palette_count > palette_count) { R.ShowStopError("パレット数が正しくありません。\r\n{1}種類以下(16色*{1}種類) でなければなりません。\r\n\r\n選択された画像のパレット種類:{0}種類", bitmap_palette_count, palette_count); return; } bitmap = PaletteSwapper(bitmap); } //画像 byte[] image = ImageUtil.ImageToByte16Tile(bitmap, width, height); //画像等データの書き込み Undo.UndoData undodata = Program.Undo.NewUndoData(this); if (obj2_plist > 0) {//FE7とかあるフィールド画像分割 byte[] image1 = U.subrange(image, 0, (uint)(image.Length / 2)); byte[] image2 = U.subrange(image, (uint)(image.Length / 2), (uint)image.Length); byte[] image1Z = LZ77.compress(image1); byte[] image2Z = LZ77.compress(image2); uint newaddr = InputFormRef.WriteBinaryData(this, (uint)ObjAddress.Value, image1Z, InputFormRef.get_data_pos_callback_lz77, undodata); if (newaddr == U.NOT_FOUND) { Program.Undo.Rollback(undodata); return; } ObjAddress.Value = newaddr; //拡張領域に書き込んでいる可能性もあるので plstを更新する. MapPointerForm.Write_Plsit(MapPointerForm.PLIST_TYPE.OBJECT, obj_plist, newaddr, undodata); //分割されたデータを書き込み newaddr = InputFormRef.WriteBinaryData(this, (uint)ObjAddress2.Value, image2Z, InputFormRef.get_data_pos_callback_lz77, undodata); if (newaddr == U.NOT_FOUND) { Program.Undo.Rollback(undodata); return; } ObjAddress2.Value = newaddr; //拡張領域に書き込んでいる可能性もあるので plstを更新する. bool r = MapPointerForm.Write_Plsit(MapPointerForm.PLIST_TYPE.OBJECT, obj2_plist, newaddr, undodata); if (!r) { Program.Undo.Rollback(undodata); return; } //書き込んだ通知. InputFormRef.ShowWriteNotifyAnimation(this, newaddr); } else { byte[] imageZ = LZ77.compress(image); uint newaddr = InputFormRef.WriteBinaryData(this, (uint)ObjAddress.Value, imageZ, InputFormRef.get_data_pos_callback_lz77, undodata); if (newaddr == U.NOT_FOUND) { Program.Undo.Rollback(undodata); return; } ObjAddress.Value = newaddr; //拡張領域に書き込んでいる可能性もあるので plstを更新する. bool r = MapPointerForm.Write_Plsit(MapPointerForm.PLIST_TYPE.OBJECT, obj_plist, newaddr, undodata); if (!r) { Program.Undo.Rollback(undodata); return; } //書き込んだ通知. InputFormRef.ShowWriteNotifyAnimation(this, newaddr); } if (ObjImportOption.SelectedIndex == 1) {//パレットもインポートする場合 //パレットの交換 MapObjImage = bitmap; U.ForceUpdate(this.PaletteTypeCombo, 0); U.ForceUpdate(this.PaletteCombo, 0); //パレット情報の書き込み. uint palette_plist = this.MapEditConf[this.MapStyle.SelectedIndex].palette_plist; uint palette_address = MapPointerForm.PlistToOffsetAddr(MapPointerForm.PLIST_TYPE.PALETTE, palette_plist); if (palette_address == 0) {//未割り当てならば新規確保しようか palette_address = InputFormRef.AppendBinaryData(PaletteFormRef.NewNullPalette(palette_count), undodata); } PaletteFormRef.MakePaletteBitmapToROM(this, bitmap, palette_address, palette_count, undodata); //拡張領域に書き込んでいる可能性もあるので plstを更新する. bool r = MapPointerForm.Write_Plsit(MapPointerForm.PLIST_TYPE.PALETTE, palette_plist, palette_address, undodata); if (!r) { Program.Undo.Rollback(undodata); return; } PaletteAddress.Value = palette_address; } else {//パレットはインポートしない場合 //パレット情報の継承. bitmap.Palette = this.MapObjImage.Palette; //obj Bitmap交換 this.MapObjImage = bitmap; } Program.Undo.Push(undodata); //チップセットの更新. Chipset_Update(); SelectedChipset_Update(); MapStyle_SelectedIndexChanged(sender, e); InputFormRef.WriteButtonToYellow(this.PaletteWriteButton, false); //マップエディタが開いていれば更新する MapEditorForm.UpdateMapStyleIfOpen(); }