LS,
I am building an application in LightSwitch (LightSwitch uses SilverLight)
As I am printing invoices I want to place a logo on the paper. And my problem is how can I load an image to XImage. XImage.FromFile is depreciated and doesn't work so I tried:
string LogoFile = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\RawoLogo.jpg"; FileStream file = new FileStream(LogoFile, FileMode.Open); int BitsLength = (int)file.Length; byte[] Bits = new byte[BitsLength]; file.Read(Bits, 0, BitsLength); XImage image = XImage.FromStream(file); file.Close();
I do not get any compinling errors, but when the program get to XImage image = XImage.FromStream(file) there is an error: The byte array is not a recognized imageformat.
It doesn't matter if I use a JPG or PNG, both report the same error. The file exists on disc, it is loaded the amount of bytes correspond with the size of the image.
Am I missing something, is there something I am doing wrong??
I hope someone can help me and tell me how I can get my logo-image in my XImage.
Kind regards,
Clemens Linders
|