첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
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
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요