private void trackBarAlpha_Scroll(object sender, EventArgs e) { Factor = trackBarAlpha.Value / 100.0m; labelChangeAlpha.Text = string.Format(LanguageSettings.Current.BinEdit.AlphaX, trackBarAlpha.Value); var bmp = ChangeAlpha(_bitmap, Factor); if (_backgroundImage == null) { const int rectangleSize = 9; _backgroundImage = TextDesigner.MakeBackgroundImage(pictureBoxPreview.Width, pictureBoxPreview.Height, rectangleSize, _backgroundImageDark); } var finalBitmap = new Bitmap(bmp.Width, bmp.Height); using (var gfx = Graphics.FromImage(finalBitmap)) { gfx.DrawImage(_backgroundImage, new Point(0, 0)); gfx.DrawImage(bmp, new Point(0, 0)); } bmp.Dispose(); pictureBoxPreview.Image?.Dispose(); pictureBoxPreview.Image = finalBitmap; }
protected override void GeneratePreviewReal() { if (_backgroundImage == null) { const int rectangleSize = 9; _backgroundImage = TextDesigner.MakeBackgroundImage(pictureBoxPreview.Width, pictureBoxPreview.Height, rectangleSize, _backgroundImageDark); } var outlineWidth = (float)numericUpDownOutline.Value; var shadowWidth = (float)numericUpDownShadowWidth.Value; var outlineColor = _isSubStationAlpha ? panelBackColor.BackColor : panelOutlineColor.BackColor; Font font; try { font = new Font(comboBoxFontName.Text, (float)numericUpDownFontSize.Value * 1.1f, checkBoxFontBold.Checked ? FontStyle.Bold : FontStyle.Regular); } catch { font = new Font(Font, FontStyle.Regular); } var measureBmp = TextDesigner.MakeTextBitmapAssa( Configuration.Settings.General.PreviewAssaText, 0, 0, font, pictureBoxPreview.Width, pictureBoxPreview.Height, outlineWidth, shadowWidth, null, panelPrimaryColor.BackColor, outlineColor, panelBackColor.BackColor, radioButtonOpaqueBox.Checked); var nBmp = new NikseBitmap(measureBmp); var measuredWidth = nBmp.GetNonTransparentWidth(); var measuredHeight = nBmp.GetNonTransparentHeight(); float left; if (radioButtonTopLeft.Checked || radioButtonMiddleLeft.Checked || radioButtonBottomLeft.Checked) { left = (float)numericUpDownMarginLeft.Value; } else if (radioButtonTopRight.Checked || radioButtonMiddleRight.Checked || radioButtonBottomRight.Checked) { left = pictureBoxPreview.Width - (measuredWidth + (float)numericUpDownMarginRight.Value); } else { left = (pictureBoxPreview.Width - measuredWidth) / 2.0f; } float top; if (radioButtonTopLeft.Checked || radioButtonTopCenter.Checked || radioButtonTopRight.Checked) { top = (float)numericUpDownMarginVertical.Value; } else if (radioButtonMiddleLeft.Checked || radioButtonMiddleCenter.Checked || radioButtonMiddleRight.Checked) { top = (pictureBoxPreview.Height - measuredHeight) / 2.0f; } else { top = pictureBoxPreview.Height - measuredHeight - (int)numericUpDownMarginVertical.Value; } var designedText = TextDesigner.MakeTextBitmapAssa( Configuration.Settings.General.PreviewAssaText, (int)Math.Round(left), (int)Math.Round(top), font, pictureBoxPreview.Width, pictureBoxPreview.Height, outlineWidth, shadowWidth, _backgroundImage, panelPrimaryColor.BackColor, panelOutlineColor.BackColor, panelBackColor.BackColor, radioButtonOpaqueBox.Checked); pictureBoxPreview.Image?.Dispose(); pictureBoxPreview.Image = designedText; font.Dispose(); }