Slightly faster blu-ray sup generation...

git-svn-id: https://subtitleedit.googlecode.com/svn/trunk@2076 99eadd0c-20b8-1223-b5c4-2a2b2df33de2
This commit is contained in:
niksedk 2013-09-11 18:47:20 +00:00
parent 675a9b7c3d
commit 9f07a8114d

View File

@ -191,13 +191,12 @@ namespace Nikse.SubtitleEdit.Logic.BluRaySup
/// </summary> /// </summary>
/// <param name="bm">bitmap to compress</param> /// <param name="bm">bitmap to compress</param>
/// <returns>RLE buffer</returns> /// <returns>RLE buffer</returns>
private static byte[] EncodeImage(Bitmap bm, Dictionary<Color, int> palette) private static byte[] EncodeImage(NikseBitmap bm, Dictionary<Color, int> palette)
{ {
var bytes = new List<Byte>(); var bytes = new List<Byte>();
byte color = 0; byte color = 0;
int ofs = 0; int ofs = 0;
int len = 0; int len = 0;
//boolean eol;
for (int y = 0; y < bm.Height; y++) for (int y = 0; y < bm.Height; y++)
{ {
ofs = y * bm.Width; ofs = y * bm.Width;
@ -289,7 +288,7 @@ namespace Nikse.SubtitleEdit.Logic.BluRaySup
return (byte)smallestDiffIndex; return (byte)smallestDiffIndex;
} }
private static Dictionary<Color, int> GetBitmapPalette(Bitmap bitmap) private static Dictionary<Color, int> GetBitmapPalette(NikseBitmap bitmap)
{ {
var pal = new Dictionary<Color, int>(); var pal = new Dictionary<Color, int>();
for (int y = 0; y < bitmap.Height; y++) for (int y = 0; y < bitmap.Height; y++)
@ -334,8 +333,9 @@ namespace Nikse.SubtitleEdit.Logic.BluRaySup
/// <param name="fps">frames per second</param> /// <param name="fps">frames per second</param>
/// <param name="bottomMargin">image bottom margin</param> /// <param name="bottomMargin">image bottom margin</param>
/// <returns>byte buffer containing the binary stream representation of one caption</returns> /// <returns>byte buffer containing the binary stream representation of one caption</returns>
public static byte[] CreateSupFrame(BluRaySupPicture pic, Bitmap bm, double fps, int bottomMargin, ContentAlignment alignment) public static byte[] CreateSupFrame(BluRaySupPicture pic, Bitmap bmp, double fps, int bottomMargin, ContentAlignment alignment)
{ {
var bm = new NikseBitmap(bmp);
var colorPalette = GetBitmapPalette(bm); var colorPalette = GetBitmapPalette(bm);
var pal = new BluRaySupPalette(colorPalette.Count); var pal = new BluRaySupPalette(colorPalette.Count);
int k = 0; int k = 0;