![]() |
C# Bitmap To Byte Array |
Yanıt Yaz ![]() |
Yazar | |
murat turan ![]() Üye Profili
Özel Mesaj Yolla
Bu kullanıcıya ait mesajları bul
Üyenin Web Sitesie Git
Arkadaş Listeme Ekle
Admin Group ![]() ![]() Datakent Kayıt Tarihi: 01.Ekim.2003 Bulundugu Yer: Turkey Online: Sitede Değil Gönderilenler: 1797 |
![]() ![]() ![]() Gönderim Zamanı: 19.Nisan.2015 Saat 10:19 |
C# Bitmap To Byte Array private byte[] BitmapToByteArray(Bitmap xtmpBmp, bool addHader = false) { //byte donusumu sonrasi resim tam ters dondugu icin, onceden resmi ters donduruyorum //haliyle islem sonrasi resim duz gelmis oluyor ;) //ayrica >> addHader ile byte diziye BMP nin fiziksel diskteki header kismi ekleniyor ! xtmpBmp.RotateFlip(RotateFlipType.Rotate180FlipX); byte[] _bmpHeader = new byte[]{66, 77, 166, 229, 63, 0, 0, 0, 0, 0, 54, 0, 0, 0, 40, 0, 0, 0, 174, 8, 0, 0, 116, 2, 0, 0, 1, 0, 24, 0, 0, 0, 0, 0, 112, 229, 63, 0, 196, 14, 0, 0, 196, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; BitmapData bmpdata = xtmpBmp.LockBits(new Rectangle(0, 0, xtmpBmp.Width, xtmpBmp.Height), ImageLockMode.ReadOnly, xtmpBmp.PixelFormat); int numbytes = bmpdata.Stride * xtmpBmp.Height; byte[] bytedata = new byte[numbytes]; IntPtr ptr = bmpdata.Scan0; Marshal.Copy(ptr, bytedata, 0, numbytes); xtmpBmp.UnlockBits(bmpdata); if (addHader) { byte[] tmpbytedata = new byte[bytedata.Length + _bmpHeader.Length]; _bmpHeader.CopyTo(tmpbytedata, 0); bytedata.CopyTo(tmpbytedata, 54);//header bolumunun uzerine yazmamak icin 54 de basla ! return tmpbytedata; } else { return bytedata; } }
|
|
![]() |
Yanıt Yaz ![]() |
Forum Atla | Forum İzinleri ![]() Kapalı Foruma Yeni Konu Gönderme Kapalı Forumdaki Konulara Cevap Yazma Kapalı Forumda Cevapları Silme Kapalı Forumdaki Cevapları Düzenleme Kapalı Forumda Anket Açma Kapalı Forumda Anketlerde Oy Kullanma |