728x90
반응형
728x170
using System.Drawing;
using System.Drawing.Imaging;
using System.Runtime.InteropServices;
#region 바이트 배열 구하기 - GetByteArray(Bitmap sourceBitmap)
/// <summary>
/// 바이트 배열 구하기
/// </summary>
/// <param name="sourceBitmap">소스 비트맵</param>
/// <returns>바이트 배열</returns>
public byte[] GetByteArray(Bitmap sourceBitmap)
{
BitmapData sourceBitmapData = sourceBitmap.LockBits
(
new Rectangle(0, 0, sourceBitmap.Width, sourceBitmap.Height),
ImageLockMode.ReadOnly,
PixelFormat.Format32bppArgb
);
byte[] targetByteArray = new byte[sourceBitmapData.Stride * sourceBitmapData.Height];
Marshal.Copy(sourceBitmapData.Scan0, targetByteArray, 0, targetByteArray.Length);
sourceBitmap.UnlockBits(sourceBitmapData);
return targetByteArray;
}
#endregion
728x90
반응형
그리드형(광고전용)
'C# > WinForm' 카테고리의 다른 글
[C#/WINFORM] Bitmap 클래스 : 스테인 글라스 필터(Stained Glass Filter) 사용하기 (0) | 2021.01.04 |
---|---|
[C#/WINFORM] Bitmap 클래스 : 경계 추출 필터(Boundary Extraction Filter) 사용하기 (0) | 2021.01.03 |
[C#/WINFORM] Bitmap 클래스 : 카툰 필터(Cartoon Filter) 사용하기 (0) | 2021.01.03 |
[C#/WINFORM] Bitmap 클래스 : 오일 페인트 필터(Oil Paint Filter) 사용하기 (0) | 2021.01.03 |
[C#/WINFORM] Bitmap 클래스 : 이미지 추상 색상 필터 사용하기 (0) | 2021.01.03 |
[C#/WINFORM] Bitmap 클래스 : 정사각형 크기 비트맵에 복사하기 (0) | 2021.01.03 |
[C#/WINFORM] Bitmap 클래스 : 비트맵 일부 오버레이 표시하기 (0) | 2020.12.27 |
[C#/WINFORM] Bitmap 클래스 : 크기 변경 비트맵 구하기 (0) | 2020.12.27 |
[C#/WINFORM] Bitmap 클래스 : 비트맵 파일 로드하기 (0) | 2020.12.27 |
[C#/WINFORM] Application 클래스 : SetSuspendState 정적 메소드를 사용해 절전 모드 만들기 (0) | 2020.12.27 |
댓글을 달아 주세요