http://social.msdn.microsoft.com/Forums/en/csharpgeneral/thread/1cab307d-2f5a-489f-8653-f5a9e86a6146
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.Runtime.InteropServices;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
Bitmap bmp = new Bitmap("C:\\Temp\\Sample Pictures\\Tree.jpg");
byte[] b = new byte[bmp.Width * bmp.Height * 2];
GCHandle gch = GCHandle.Alloc(b, GCHandleType.Pinned);
IntPtr scan0 = gch.AddrOfPinnedObject();
Bitmap dest = new Bitmap(bmp.Width, bmp.Height,4 * ((bmp.Width * 16 + 31) / 32), PixelFormat.Format16bppRgb565, scan0);
using (Graphics g = Graphics.FromImage(dest))
{
g.DrawImage(bmp, 0, 0);
}
gch.Free();
dest.Save("C:\\Temp\\WFConv.bmp", ImageFormat.Bmp);
}
}
}
'소스코드' 카테고리의 다른 글
| 24 bit bmp to rGB565 file conversion[c#] (0) | 2012/05/08 |
|---|---|
| c#, wpf 에서 파일 주소를 브러쉬 데이터로 만들자. (0) | 2012/05/03 |
| SHGetFolderPath (0) | 2012/04/25 |
| ffmpeg (0) | 2012/04/25 |
| The script on this page appears to have a problem. do you want to stop the script? (0) | 2012/04/13 |
| 파일의 소유자 찾는 코드 (0) | 2012/04/12 |




