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 ImportButton_Click(object sender, EventArgs e) { int width = 32 * 8; int height = 20 * 8; int palette_count = 8; Bitmap bitmap = ImageUtil.LoadAndConvertDecolorUI(this, null, width, height, true, palette_count); if (bitmap == null) { 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)) { //パレット領域が他の領域を浸食していないか確認する if (IsPaletteDuplicate((uint)this.P8.Value, (uint)this.AddressList.SelectedIndex)) { //FE8のパレットはバグっていて、となりのパレットに浸食している. this.P8.Value = 0; } //画像データの重複を判定する if (IsImageDuplicate((uint)this.P0.Value, (uint)this.AddressList.SelectedIndex)) { this.P0.Value = 0; } //画像等データの書き込み Undo.UndoData undodata = Program.Undo.NewUndoData(this); this.InputFormRef.WriteImageData10(this.P0, image, undodata); this.InputFormRef.WriteImageData(this.P4, tsa, false, undodata); this.InputFormRef.WriteImageData(this.P8, palette, false, undodata); Program.Undo.Push(undodata); } //ポインタの書き込み this.WriteButton.PerformClick(); }
private void ImportButton_Click(object sender, EventArgs e) { if (!CheckDangerUpdate()) { return; } int width = 32 * 8; int height = 20 * 8; int palette_count = 8; Bitmap bitmap = ImageUtil.LoadAndConvertDecolorUI(this, null, width, height, true, palette_count); if (bitmap == null) { 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, tsa, false, undodata); this.InputFormRef.WriteImageData(this.P8, palette, false, undodata); Program.Undo.Push(undodata); } //ポインタの書き込み this.WriteButton.PerformClick(); }
private void DecreaseColorTSAToolButton_Click(object sender, EventArgs e) { DecreaseColorTSAToolForm f = (DecreaseColorTSAToolForm)InputFormRef.JumpForm <DecreaseColorTSAToolForm>(); f.InitMethod(2); }