본문 바로가기

전체 글

(86)
C# 화면 캡쳐 Capture C# 화면 캡쳐 Capture 1. 비트맵으로 byte[] byteArray; public void Capture() { System.Drawing.Rectangle rect = Screen.PrimaryScreen.Bounds; Bitmap tBitmap = new Bitmap(rect.Width, rect.Height); using (Graphics tGraphics = Graphics.FromImage(tBitmap)) { tGraphics.CopyFromScreen(rect.Left, rect.Top, 0, 0, rect.Size); } byteArray = ImageToByte(tBitmap); } public static byte[] ImageToByte(System.Drawing.Image ..
C# lock 없이 비트맵 이미지 픽셀 Get/Set C# lock 없이 비트맵 이미지 픽셀 Get/Set using System; using System.Drawing; using System.Drawing.Imaging; using System.Runtime.InteropServices; public class DirectBitmap : IDisposable { public Bitmap Bitmap { get; private set; } public Int32[] Bits { get; private set; } public bool Disposed { get; private set; } public int Height { get; private set; } public int Width { get; private set; } protected GCHan..
C# OpenFileDialog C# OpenFileDialog OpenFileDialog dlg = new OpenFileDialog(); dlg.Multiselect = true; if (dlg.ShowDialog() == true) { var result = await Upload(new List(dlg.SafeFileNames), new List(dlg.FileNames)); MessageBox.Show(result ? "성공" : "실패"); }
C# Byte Array Compare 바이트 비교 C# Byte Array Compare 바이트 비교 [DllImport("msvcrt.dll", CallingConvention = CallingConvention.Cdecl)] static extern int memcmp(byte[] b1, byte[] b2, long count); static bool ByteArrayCompare(byte[] b1, byte[] b2) { if (b1 == null || b2 == null) { return false; } // Validate buffers are the same length. // This also ensures that the count does not exceed the length of either buffer. return b1.Lengt..
C# 난수 생성 C# 난수 생성 방법1. #region 구글에서 사용하는 난수문자 public static string GenerateCode(uint id) { return ToBase62(PermuteId(id)); } private static double RoundFunction(uint input) { // Must be a function in the mathematical sense (x=y implies f(x)=f(y)) // but it doesn't have to be reversible. // Must return a value between 0 and 1 return ((1369 * input + 150889) % 714025) / 714025.0; } private static uint Perm..
C# 텍스트 (txt) 파일 저장 C# 텍스트 (txt) 파일 저장 public class ErrorLog { public static void WriteLine(string text) { try { var dirName = "ErrorLog"; var fileName = DateTime.Now.ToString("yyyy.MM.dd") + "_Log.txt"; if (!Directory.Exists(dirName)) { Directory.CreateDirectory(dirName); } var fs = new FileStream(Path.Combine(dirName, fileName), FileMode.Append); var sw = new StreamWriter(fs, Encoding.Default, text.Length); sw.Wr..