diff --git a/libse/BluRaySup/BluRaySupPicture.cs b/libse/BluRaySup/BluRaySupPicture.cs index 0009d0eee..91d0d50c9 100644 --- a/libse/BluRaySup/BluRaySupPicture.cs +++ b/libse/BluRaySup/BluRaySupPicture.cs @@ -308,6 +308,7 @@ namespace Nikse.SubtitleEdit.Core.BluRaySup public static byte[] CreateSupFrame(BluRaySupPicture pic, Bitmap bmp, double fps, int bottomMargin, int leftOrRightMargin, ContentAlignment alignment, Point? overridePosition = null) { var bm = new NikseBitmap(bmp); + bm.SetTransparentTo(Color.Transparent); var colorPalette = GetBitmapPalette(bm); var pal = new BluRaySupPalette(colorPalette.Count); for (int i = 0; i < colorPalette.Count; i++) diff --git a/libse/NikseBitmap.cs b/libse/NikseBitmap.cs index e7b603ae8..adf0c351d 100644 --- a/libse/NikseBitmap.cs +++ b/libse/NikseBitmap.cs @@ -1442,14 +1442,14 @@ namespace Nikse.SubtitleEdit.Core return false; } - if (Width == bitmap.Width && Height == bitmap.Height && + if (Width == bitmap.Width && Height == bitmap.Height && Width == 0 && Height == 0) { return true; } - for (int i=0; i<_bitmapData.Length; i++) + for (int i = 0; i < _bitmapData.Length; i++) { if (_bitmapData[i] != bitmap._bitmapData[i]) { @@ -1459,5 +1459,21 @@ namespace Nikse.SubtitleEdit.Core return true; } + + public void SetTransparentTo(in Color transparent) + { + var buffer = new byte[4]; + buffer[0] = transparent.B; + buffer[1] = transparent.G; + buffer[2] = transparent.R; + buffer[3] = transparent.A; + for (var i = 0; i < _bitmapData.Length; i += 4) + { + if (_bitmapData[i + 3] == 0) + { + Buffer.BlockCopy(buffer, 0, _bitmapData, i, 4); + } + } + } } } \ No newline at end of file diff --git a/src/Forms/ExportPngXml.cs b/src/Forms/ExportPngXml.cs index 68d89b1f9..27c63bbeb 100644 --- a/src/Forms/ExportPngXml.cs +++ b/src/Forms/ExportPngXml.cs @@ -1,9 +1,9 @@ using Nikse.SubtitleEdit.Core; using Nikse.SubtitleEdit.Core.BluRaySup; using Nikse.SubtitleEdit.Core.Enums; +using Nikse.SubtitleEdit.Core.Interfaces; using Nikse.SubtitleEdit.Core.SubtitleFormats; using Nikse.SubtitleEdit.Core.VobSub; -using Nikse.SubtitleEdit.Forms.Ocr; using Nikse.SubtitleEdit.Logic; using Nikse.SubtitleEdit.Logic.VideoPlayers; using System; @@ -20,7 +20,6 @@ using System.Text.RegularExpressions; using System.Threading; using System.Windows.Forms; using System.Xml; -using Nikse.SubtitleEdit.Core.Interfaces; namespace Nikse.SubtitleEdit.Forms {