-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
65 changed files
with
2,686 additions
and
568 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ public enum VideoPixelFormats | |
Gbrp12Le, | ||
Gray, | ||
Gray10Le, | ||
Gray12Le, | ||
Gray16Be, | ||
MonoB, | ||
Nv12, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using System.Globalization; | ||
using System.Windows.Data; | ||
|
||
namespace ScreenToGif.Util.Converters; | ||
|
||
public class TimeSpanToString : IValueConverter | ||
{ | ||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
if (value is not TimeSpan time) | ||
return Binding.DoNothing; | ||
|
||
if (time.Days > 0) | ||
return time.ToString("d\\:hh\\:mm\\:ss", culture); | ||
|
||
if (time.Hours > 0) | ||
return time.ToString("h\\:mm\\:ss", culture); | ||
|
||
return time.ToString("mm\\:ss", culture); | ||
} | ||
|
||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
return Binding.DoNothing; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#region Usings | ||
|
||
#region Used Namespaces | ||
|
||
using System.Windows; | ||
using System.Windows.Media; | ||
using System.Windows.Media.Imaging; | ||
|
||
using KGySoft.Drawing.Imaging; | ||
|
||
#endregion | ||
|
||
#region Used Aliases | ||
|
||
using PixelFormat = System.Drawing.Imaging.PixelFormat; | ||
using Size = System.Drawing.Size; | ||
|
||
#endregion | ||
|
||
#endregion | ||
|
||
namespace ScreenToGif.Util.Extensions; | ||
|
||
/// <summary> | ||
/// Contains extension methods for the <see cref="WriteableBitmap"/> type. | ||
/// </summary> | ||
public static class WriteableBitmapExtensions | ||
{ | ||
#region Methods | ||
|
||
/// <summary> | ||
/// Gets a managed read-write accessor for a <see cref="WriteableBitmapData"/> instance. | ||
/// </summary> | ||
/// <param name="bitmap">The bitmap to get the managed accessor.</param> | ||
/// <returns>An <see cref="IReadWriteBitmapData"/> instance that provides managed access to the specified <see cref="bitmap"/>.</returns> | ||
public static IReadWriteBitmapData GetReadWriteBitmapData(this WriteableBitmap bitmap) | ||
{ | ||
if (bitmap == null) | ||
throw new ArgumentNullException(nameof(bitmap)); | ||
if (bitmap.IsFrozen) | ||
throw new ArgumentException("Bitmap must not be frozen"); | ||
|
||
var format = bitmap.Format; | ||
|
||
// Actually you can support any other formats, including non-natively supported ones by custom PixelFormatInfo and getter/setter delegates | ||
var pixelFormat = format == PixelFormats.Bgra32 ? PixelFormat.Format32bppArgb | ||
: format == PixelFormats.Pbgra32 ? PixelFormat.Format32bppPArgb | ||
: format == PixelFormats.Bgr32 ? PixelFormat.Format32bppRgb | ||
: format == PixelFormats.Bgr24 ? PixelFormat.Format24bppRgb | ||
: throw new NotSupportedException(bitmap.Format.ToString()); | ||
|
||
bitmap.Lock(); | ||
return BitmapDataFactory.CreateBitmapData(bitmap.BackBuffer, new Size(bitmap.PixelWidth, bitmap.PixelHeight), bitmap.BackBufferStride, pixelFormat, | ||
disposeCallback: () => | ||
{ | ||
bitmap.AddDirtyRect(new Int32Rect(0, 0, bitmap.PixelWidth, bitmap.PixelHeight)); | ||
bitmap.Unlock(); | ||
}); | ||
} | ||
|
||
#endregion | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.