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
using System; | |
using System.Linq; | |
namespace Rextester | |
{ | |
// See https://csharp.2000things.com/tag/captured-variable/ | |
internal static class Program | |
{ | |
public static void Main(string[] args) | |
{ |
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
using System; | |
using System.Runtime.InteropServices; | |
// https://stackoverflow.com/questions/66002667/pinvoking-user32-dll-setwindowcompositionattribute-via-powershell | |
public static class NativeMethods | |
{ | |
[DllImport("user32.dll")] | |
public static extern bool SetForegroundWindow(IntPtr hWnd); | |
[DllImport("user32.dll")] |
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
#if !IMAGESHARP_V2 | |
using System; | |
using System.Collections.Generic; | |
using System.Numerics; | |
#endif | |
using SixLabors.ImageSharp; | |
using SixLabors.ImageSharp.Drawing; | |
namespace RoundedRectangleTest | |
{ |
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
// First attempt | |
public static Bitmap GetBitmapFromHBitmap_1(IntPtr nativeHBitmap) | |
{ | |
var bitmapSource = Imaging.CreateBitmapSourceFromHBitmap( | |
nativeHBitmap, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); | |
// There were missing parentheses here (they are important because this is integer arithmetic. | |
// Also worth noting, the code below only supports 32bpp images. In this case, stride | |
// is always equal to width, so a micro-optim would be to not compute the stride. | |
var stride = 4 * ((bitmapSource.PixelWidth * bitmapSource.Format.BitsPerPixel + 31) / 32); |
OlderNewer