Admin@mbox3.magellan-net.de
alina@yourmx.de
bm@schweinischer-bote.de
boris@cosmeta.de
boss@dan2n.de
btiggemann@mbox3.magellan-net.de
catcher009@blacknbeauty.de
Christopher_Zantopp@web.de
dok123@discardmail.com
dominik.keilbach@rocketmail.com
dominik2712@web.de
einkauf@dan2n.de
elke@kunesch.eu
erik_burgbacher_bi17l4lo@send.electronicmailfor.me.uk
feedme@die-bauer.de
feedme@dog-net.org
feedme@drakensang.de-web.cc
feedme@kraffner.de
feedme@schlaegel.it
feedme@sql-kunesch.de
feedme@wipeout6.de
fetcher@open-host.de
frank@spiracyworld.co.uk
getspam@schlaegel-online.de
harun-ali@web.de
iCollectGarbage@gmx.de
ifyoudone@r0ckt.de
ifyyou@r0ckt.de
info@die-bauer.de
info@mbox3.magellan-net.de
info@r0ckt.de
info@rbcms.de
john.deer@spamreducer.eu
john@cannedmeat.elementfx.com
k.tramm@xspin.de
Karl-Heinz.Becher@gmx.de
Kevin.Becaud@bio-muesli.info
kickers88@live.de
knuddels119k@yahoo.de
loremiosumsitdoloramet@yahoo.de
loremiosumsitdoloramet@yahoo.de
lotharwalter@ymail.com
luna@r0ckt.de
matz0302oyqp@domut.de
mgoessel@gmx.net
michael.k@drakensang.de-web.cc
michael.k@drakensang.de-web.cc
michael.k@sql-kunesch.de
michaknopf@googlemail.com
mk@r0ckt.de
msneijder@mbox3.magellan-net.de
nasti_mkorsa@sql-kunesch.de
newcyborg@gmx.net
schlucks@gmx.net
schwarz@die-bauer.de
service@mbox3.magellan-net.de
sp4mf4ng@j-schmitz.net
spam@teh1.de
spamcatcher@spamtrap.dtdns.net
spamela@spamschlucker.org
spamhog.ihatespam@gmail.com
spamlearn@schlarb-it.de
spamlearn@schlarb-it.de
spamtarget@junge-piraten.de
spamtrap@r0ckt.de
spamtrap@sprachdidaktik.org
spoof@dog-net.org
stephan@spamschlucker.org
support@mbox3.magellan-net.de
thanks@marvin-webservice.net
trap.mitschutz@sprachdidaktik.org
trap@sprachdidakt.de
trap@sprachdidaktik.org
trep@marvin-webservice.net
unwanted@shadowpage.de
vertrieb@dan2n.de
wb@munzinger.de
willmehr@drakensang.de-web.cc
willmehr@drakensang.de-web.cc
willmehr@wipeout6.de
wir@dragoncrew.de
xkbzy@grossermist.de
a Image

Sometimes you won't recreate some code pieces, you already created once.

But in some cases, you need to do some type conversations then. Heres a little example,
how you can translate your ৺System.Drawing.Bitmap to the new System.Windows.Media.Imaging.৺BitmapImage type.

For faster ৺access, i put this lines of code into my own Imaging namespace. (Converter class)

For Converting a ৺System.Drawing.Bitmap to the System.Windows.Media.Imaging.৺BitmapImage, i use a MemoryStream to cache the content information.

The function is static, so you dont need to create an instance of Converter first.

  1.  
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Windows.Media.Imaging;
  7. using System.IO;
  8.  
  9. namespace Dognet.Imaging
  10. {
  11.     partial class Converter
  12.     {
  13.  
  14.         /// <summary>
  15.         /// Converts a System.Drawing.Bitmap to a BitmapImage
  16.         /// </summary>
  17.         /// <param name="bitmap">the Bitmap</param>
  18.         /// <returns>the BitmapImage</returns>
  19.         public static BitmapImage BitmapToBitmapImage(System.Drawing.Bitmap bitmap)
  20.         {
  21.             MemoryStream ms = new MemoryStream();
  22.             bitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
  23.             BitmapImage bImg = new System.Windows.Media.Imaging.BitmapImage();
  24.  
  25.             bImg.BeginInit();
  26.             bImg.StreamSource = new MemoryStream(ms.ToArray());
  27.             bImg.CreateOptions = BitmapCreateOptions.None;
  28.             bImg.CacheOption = BitmapCacheOption.Default;
  29.             bImg.EndInit();
  30.  
  31.             ms.Close();
  32.  
  33.             return bImg;
  34.         }
  35.     }
  36. }
  37.  

Related Tags:

Stay tuned:

r a t y y

Top 25 Tag-Cloud (last 14 days):

Trackbacks on this post:

৺assigning windows.drawing.bitmap to...
৺c# bitmapimage to bitmap - Szukaj w...
৺Google...
৺wpf show bitmap with image - Google...
৺c# draw to bitmap wpf - Google Sear...
৺c# bitmap to bitmapimage - Cerca co...
৺wpf convert bitmapimage to bitmap -...
৺WPF_save - Google ·j´M...
৺casting bitmapimage to bitmap - Goo...
৺coversion of bitmapImage to Bitmap ...
৺name space for ImageSource and bit...
৺bitmap to BitmapImage - Google zoek...
৺c# convert bitmap to bitmapimage - ...
৺bitmapimage from bitmap - Google Se...
৺System.Drawing.Bitmap - Google-haku...
৺system.drawing.bitmap convert to sy...
৺c# bitmap bitmapimage - Google °Ë»ö...
৺system.drawing.bitmap wpf - Google ...
৺How can I convert a Bitmap into Bit...
৺bitmapimage convert bitmap memoryst...
৺wpf draw close button - Google Sear...
৺System.Drawing.Bitmap to Bitmapimag...
৺System.Drawing.Bitmap image = (Bitm...
৺how to copy System.Drawing.Bitmap M...
৺ListBox bitmap wpf - Google Search...
৺wpf vb.net &quot;system.windows...
৺system.drawing.bitmap save - Google...
৺system.drawing.bitmap button - Goog...
৺system.drawing.bitmap to bitmapimag...
৺wpf c# e.result bitmapImage - Googl...
৺convert system.drawing.image to bit...
৺Google...
৺BitmapImage to System.Drawing.image...
৺bitmap bitmapImage - Google-Suche...
৺How to convert bitmapimage to bitma...
৺c# BitmapImage to bitmap - Google-h...
৺convert bitmap to bitmapimage C# - ...
৺c# &quot;BitmapImage&quot; ...
৺wpf draw closebutton - Google ËÑË÷...
৺bitmap to system.windows.media.imag...
৺system.drawing.bitmap to bitmapimag...
৺BitmapImage Cache - Google °Ë»ö...
৺c# BitmapImage to System.Drawing.Im...
৺System.Drawing.Bitmap - Pesquisa Go...
৺c# bitmap to bitmapimage - Vyhledáv...
৺.net c# bitmap to bitmapimage - Goo...
৺bitmap to bitmapimage - Google-Such...

Comments on this post:

Joe
2010-04-04 19:10:11
I see this solution all over the place however i cant get it to work. It gives me \"Object reference not set to an instance of an object.\"

Leave a Comment:

Captcha-Code:        reload
Name:
Captcha:
Comment:

Donate!

Like my stuff? Feel free to donate!
 
Modellbau Forum pspad Browser-Statistiken WhatPulse logo dog-net.org Valid XHTML 1.0 Transitional CSS ist valide!

DevelopmentWPF | 2010-02-02 16:59:13

LeadImage

BitmapSource to/from BitmapImage

Another useful conversion: ৺BitmapSource to/from BitmapImage

read more...
Copyright © 2008 - 2010 | by dog.net Development | Imprint | Load in 1.042254