Skip to content

Instantly share code, notes, and snippets.

View STOL4S's full-sized avatar

STOLAS STOL4S

  • Arizona
View GitHub Profile
@STOL4S
STOL4S / BitmapRotate.cs
Last active November 26, 2023 16:07
Draw a rotated bitmap image in C# and GDI+ using an existing graphics object
View BitmapRotate.cs
using System.Drawing;
namespace GraphicsHelperLibrary
{
public static class GraphicsHelper
{
public static void DrawRotatedImage(this Graphics G, Bitmap _Image, PointF _Position, float _Rotation)
{
PointF Offset = new PointF(_Image.Width / 2 + _Position.X,
_Image.Height / 2 + _Position.Y);
@STOL4S
STOL4S / ClientBounds.cs
Last active November 7, 2023 21:58
Get client bounds of another process running on the same system.
View ClientBounds.cs
using System.Diagnostics;
using System.Drawing;
using System.Runtime.InteropServices;
namespace ClientExtensions
{
public static class ClientBounds
{
[DllImport("user32.dll", CharSet = CharSet.Auto)]
private static extern IntPtr FindWindow(string strClassName, string strWindowName);
@STOL4S
STOL4S / BitmapFromDialog.cs
Created November 7, 2023 21:45
Automatically create a new open file dialog prompting the user to select an image to load and then returns the bitmap to the function. If no bitmap is selected or the operation is cancelled, the function returns null.
View BitmapFromDialog.cs
using System;
using System.Drawing;
namespace GraphicsHelperLibrary
{
public static class BitmapExtensions
{
public static Bitmap FromFileWithDialog()
{
OpenFileDialog OpenDialog = new OpenFileDialog();
@STOL4S
STOL4S / Stopwatch.cs
Created November 7, 2023 21:37
Stopwatch class capable of calculating and displaying the elapsed time between the Start() and Stop() functions. This can be added to any project to easily test the speed of different functions against eachother.
View Stopwatch.cs
using System;
namespace SimpleStopwatch
{
public class Stopwatch
{
private DateTime _Start;
public TimeSpan Time { get { return _Time; } }
private TimeSpan _Time;
@STOL4S
STOL4S / ListStringExtension.cs
Last active November 7, 2023 21:08
This function allows for the input of any IList and outputs a formatted, readable string.
View ListStringExtension.cs
using System;
using System.Collections;
namespace ExtLibrary
{
public static class ListExtensions
{
public static string AsString(this IList _List)
{
string _Buffer = "";