Image to ByteArray 

 ImageConverter imgcvt = new ImageConverter();
 byte[] imgByte = (byte[])imgcvt.ConvertTo(img, typeof(byte[]));   // image -> byteArray ๋ณ€ํ™˜

 

ByteArray to Image

1. ImageConverter ์ด์šฉํ•˜๊ธฐ

ImageConverter imgcvt = new ImageConverter();
Image img = (Image)imgcvt.ConvertFrom(imgByte);   // byteArray -> image ๋ณ€ํ™˜
img.Save("C:\\imgSave.png");   // ์ด๋ฏธ์ง€ ์ €์žฅ

์ง€์ • ๊ฒฝ๋กœ์— ์ €์žฅ

 

2. FileStream ์ด์šฉํ•˜๊ธฐ

FileStream fs = new FileStream("imgSave.png", FileMode.Create, FileAccess.Write);
fs.Write(imgByte, 0, imgByte.Length);

ํ”„๋กœ์ ํŠธ์˜ bin -> debug ํด๋”์— ์ €์žฅ

728x90

BELATED ARTICLES

more