private void PaletteCombo_SelectedIndexChanged(object sender, EventArgs e) { uint palIndex = CalcPatelleIndex(); if (palIndex == U.NOT_FOUND) { return; } PFR.MakePaletteBitmapToUI(this.MapObjImage, (int)palIndex); PFR.ClearUndoBuffer(); Bitmap newbitmap = ImageUtil.SwapPalette(this.MapObjImage, (int)palIndex); this.MAP.LoadMap(newbitmap); InputFormRef.WriteButtonToYellow(this.PaletteWriteButton, false); }
private void PaletteTypeCombo_SelectedIndexChanged(object sender, EventArgs e) { uint palIndex = CalcPatelleIndex(); if (palIndex == U.NOT_FOUND) { return; } PaletteFormRef.MakePaletteBitmapToUI(this, this.MapObjImage, (int)palIndex); Bitmap newbitmap = ImageUtil.SwapPalette(this.MapObjImage, (int)palIndex); this.MAP.LoadMap(newbitmap); //霧パレットの切り替えは、マップチップも描画しなおす RedrawMAPCHIPLIST(); InputFormRef.WriteButtonToYellow(this.PaletteWriteButton, false); }
public static bool MakePaletteBitmapToUIEx(Form self, int palette_index, Bitmap hintBitmap) { Debug.Assert(ImageUtil.Is16ColorBitmap(hintBitmap)); string imagefilename = ImageFormRef.OpenFilenameDialogFullColor(self); if (imagefilename == "") { return(false); } Bitmap fullColor = ImageUtil.OpenLowBitmap(imagefilename); //bitmapそのものの色で開く. if (fullColor == null) { return(false); } Bitmap bitmap; if (palette_index <= 0) { if (!ImageUtil.Is16ColorBitmap(fullColor)) { R.ShowStopError("パレット数が正しくありません。\r\n{1}種類以下(16色*{1}種類) でなければなりません。\r\n\r\n選択された画像のパレット種類:{0}種類", palette_index, "fullcolor"); fullColor.Dispose(); return(false); } bitmap = ImageUtil.OpenBitmap(imagefilename); //16色に変換して開く. if (bitmap == null) { fullColor.Dispose(); return(false); } if (ImageUtil.IsFullColorBitmap(fullColor) || !ImageUtil.CheckPaletteTransparent(bitmap)) {//パレットではない画像なので何かしらの変換が必要 if (hintBitmap == null || (hintBitmap.Width != fullColor.Width && hintBitmap.Height != fullColor.Height)) { DialogResult dr = R.ShowNoYes("この画像のパレットは破壊されています。\r\n復元しようとしましたが、元画像と異なる画像のため、復元できませんでした。\r\n無視して強引にインポートすることは可能ですが、継続しますか?"); if (dr == DialogResult.No) { fullColor.Dispose(); bitmap.Dispose(); return(false); } } else {//壊れたパレットを復元します. Bitmap recolor = ImageUtil.ReColorPaletteWithHint(bitmap, hintBitmap); ErrorPaletteMissMatchForm f = (ErrorPaletteMissMatchForm)InputFormRef.JumpFormLow <ErrorPaletteMissMatchForm>(); f.SetOrignalImage(bitmap, hintBitmap); f.SetReOrderImage1(recolor, hintBitmap); f.ShowDialog(); bitmap = f.GetResultBitmap(); if (bitmap == null) { fullColor.Dispose(); return(false); } } } } else { //16色以上 bitmap = ImageUtil.OpenBitmap(imagefilename); //16色に変換して開く. if (bitmap == null) { fullColor.Dispose(); return(false); } int bitmap_palette_count = ImageUtil.GetPalette16Count(bitmap); if (bitmap_palette_count > palette_index) { R.ShowStopError("パレット数が正しくありません。\r\n{1}種類以下(16色*{1}種類) でなければなりません。\r\n\r\n選択された画像のパレット種類:{0}種類", bitmap_palette_count, palette_index); fullColor.Dispose(); bitmap.Dispose(); return(false); } if (ImageUtil.IsFullColorBitmap(fullColor)) {//パレットではない画像なので何かしらの変換が必要 if (hintBitmap == null || (hintBitmap.Width != fullColor.Width && hintBitmap.Height != fullColor.Height)) { DialogResult dr = R.ShowNoYes("この画像のパレットは破壊されています。\r\n復元しようとしましたが、元画像と異なる画像のため、復元できませんでした。\r\n無視して強引にインポートすることは可能ですが、継続しますか?"); if (dr == DialogResult.No) { fullColor.Dispose(); bitmap.Dispose(); return(false); } } else {//壊れたパレットを復元します. Bitmap recolor = ImageUtil.ReColorPaletteWithHint(bitmap, hintBitmap); ErrorPaletteMissMatchForm f = (ErrorPaletteMissMatchForm)InputFormRef.JumpFormLow <ErrorPaletteMissMatchForm>(); f.SetOrignalImage(bitmap, hintBitmap); f.SetReOrderImage1(recolor, hintBitmap); f.ShowDialog(); bitmap = f.GetResultBitmap(); if (bitmap == null) { fullColor.Dispose(); return(false); } } } } PaletteFormRef.MakePaletteBitmapToUI(self, bitmap, palette_index); fullColor.Dispose(); bitmap.Dispose(); return(true); }