본문 바로가기

전체 글

(86)
C# HttpClient RestAPI Patch C# HttpClient RestAPI Patch public static async Task WDDCAsync(string bearer, string id, string val, bool isReturnResponseMessage = false) { //ServicePointManager.ServerCertificateValidationCallback = delegate { return true; }; // 인증 try { var cl = new HttpClient(); cl.BaseAddress = new Uri(BaseUrl); cl.Timeout = TimeSpan.FromSeconds(3); cl.DefaultRequestHeaders.Add("authorization", "Bearer " + ..
C# HttpClient RestAPI Get C# HttpClient RestAPI Get 비동기 HttpClient public static async Task AlarmAsync(string bearer, string id, bool isReturnResponseMessage = false) { //ServicePointManager.ServerCertificateValidationCallback = delegate { return true; }; // 인증 string result = string.Empty; try { var cl = new HttpClient(); cl.BaseAddress = new Uri(BaseUrl); cl.Timeout = TimeSpan.FromSeconds(3); cl.DefaultRequestHeaders.A..
C# QR/Barcode 생성 C# QR/Barcode 생성 1. zen barcode QR코드 생성 NuGet -> 검색 ( zen barcode ) -> Zen.Barcode.Rendering.Framework 설치 public static class CQRGenerator { public static void Make(string uri, string savePath, int height = 50) { Zen.Barcode.CodeQrBarcodeDraw qrcode = Zen.Barcode.BarcodeDrawFactory.CodeQr; // 바코드 : Code128WithChecksum, QR : CodeQr var qrImage = qrcode.Draw(uri, height); qrImage.Save(savePath); }..
C# Byte To ImageSource C# Byte To ImageSource public static ImageSource ByteToImage(byte[] imageData) { BitmapImage biImg = new BitmapImage(); MemoryStream ms = new MemoryStream(imageData); biImg.BeginInit(); biImg.StreamSource = ms; biImg.EndInit(); ImageSource imgSrc = biImg as ImageSource; return imgSrc; }
C# byte 압축 / 해제 C# byte 압축 / 해제 // byte 압축하기 byte[] originByte; byte[] compressedByte; using (MemoryStream ms = new MemoryStream()) { using (DeflateStream ds = new DeflateStream(ms, CompressionMode.Compress)) { ds.Write(originByte, 0, originByte.Length); } compressedByte = ms.ToArray(); } // byte 압축풀기 byte[] originByte; byte[] deCompressedByte; using (MemoryStream ms = new MemoryStream(compressedByte)) { using ..
C# Byte Array에 Byte Array 합치기 C# Byte Array에 Byte Array 합치기 Byte array / Add / Combine / Sum private static byte[] Combine(byte[] first, byte[] second) { byte[] ret = new byte[first.Length + second.Length]; Buffer.BlockCopy(first, 0, ret, 0, first.Length); Buffer.BlockCopy(second, 0, ret, first.Length, second.Length); return ret; }
이미지 EXIF 정보 가져오기, 이미지 회전 후 저장 이미지 EXIF 정보 가져오기, 이미지 회전 후 저장 Get Image EXIF Information / Rotate Image and Save public ActionResult Pictures(string id) { PictureModel pictureModel = new PictureModel(); pictureModel._ID = id; pictureModel._Images = new List(); pictureModel._ImagesOrigin = new List(); if (id == null) { return View(pictureModel); } // 웹 서버 실제 파일 경로 // Server.MapPath(".") .이 늘어날 수록 부모 디렉토리를 반환한다. var pictureDirPa..
C# Image To Byte C# Image To Byte public static byte[] ImageToByte(System.Drawing.Image img) { ImageConverter converter = new ImageConverter(); return (byte[])converter.ConvertTo(img, typeof(byte[])); }