Writing an Image to a Linq to Sql (SQL CE) Database on Windows Phone 7


hi guys,

i unable post anything on create.msdn.com forums trying luck here...

i trying write image captured to a sql ce database , read in image on control, getting black image. help?

here did far

[column]         public byte[] itemimage         {             { return _itemimage; }             set             {                 if (_itemimage != value)                 {                     _itemimage = value;                     notifypropertychanging("itemimage");                     notifypropertychanged("itemimage");                 }             }         }

public void addnewitem(stream image, string url)         {             byte[] bytearray = null;             using (memorystream ms = new memorystream())             {                 writeablebitmap wb = new writeablebitmap(200, 200);                 wb.savejpeg(ms, 200, 200, 0, 60);                 bytearray = ms.toarray();             }              shopitem item = new shopitem { count = 1, itemimageurl = url, itemimage = bytearray };             shopitemmodel.add(item);             shopitemdb.shopitems.insertonsubmit(item);             savedata();         }

public class imageconverter: ivalueconverter     {         public object convert(object value, type targettype, object parameter, system.globalization.cultureinfo culture)         {             if (value byte[])             {                 bitmapimage image = new bitmapimage();                 writeablebitmap writebitmap = new writeablebitmap(200, 200);                 memorystream memorystream = new memorystream(value byte[]);                 writebitmap.loadjpeg(memorystream);                  image.setsource(memorystream);                 return image;             }             else                 return null;              //bitmapimage image = new bitmapimage();             //string s = system.convert.tostring(value);             //image.urisource = new uri(s, urikind.relative);             //return value;         }          public object convertback(object value, type targettype, object parameter, system.globalization.cultureinfo culture)         {             throw new notimplementedexception();         }     }

<image source="{binding itemimage, converter={staticresource imageconverter}}" stretch="uniformtofill"/>

hi anton. think converter code has error in it:

writeablebitmap writebitmap = new writeablebitmap(200, 200); memorystream memorystream = new memorystream(value byte[]); writebitmap.loadjpeg(memorystream);  image.setsource(memorystream); return image;

here using "memorystream" source image, should return "writebitmap" variable result of converter.



Silverlight  >  Silverlight for Windows Phone



Comments

Popular posts from this blog

Conditional formatting a graph vertical axis in SSRS 2012 charts

Register with Power BI failed

SQL server replication error Cannot find the dbo or user defined function........