Пример #1
0
        private static bool QualifiesForMerge(IReadOnlyList <DeleteIndex> arr, IReadOnlyList <PcsData> pcsList, int mergeCount)
        {
            if (Configuration.Settings.SubtitleSettings.BluRaySupForceMergeAll)
            {
                return(false);
            }

            if (mergeCount < 3)
            {
                return(false);
            }

            if (arr.Count != 2)
            {
                return(true);
            }

            var i1   = pcsList[arr[0].Index];
            var i2   = pcsList[arr[1].Index];
            var dur1 = i1.EndTimeCode.TotalMilliseconds - i1.StartTimeCode.TotalMilliseconds;
            var dur2 = i2.EndTimeCode.TotalMilliseconds - i2.StartTimeCode.TotalMilliseconds;

            if (dur1 < 400 || dur2 < 400)
            {
                return(true);
            }

            if (i1.PaletteInfos.Count > 2 || i2.PaletteInfos.Count > 2)
            {
                return(true);
            }

            using (var b1 = i1.GetBitmap())
            {
                var n1     = new NikseBitmap(b1);
                var height = n1.GetNonTransparentHeight();
                var width  = n1.GetNonTransparentWidth();
                if (height > 110 || width > 300)
                {
                    return(true);
                }

                using (var b2 = i2.GetBitmap())
                {
                    var n2       = new NikseBitmap(b2);
                    var areEqual = n1.IsEqualTo(n2);
                    return(areEqual);
                }
            }
        }
        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();
        }