PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

How to use drawimage (from lightswitch) stream returns error
https://forum.pdfsharp.net/viewtopic.php?f=2&t=1672
Page 1 of 1

Author:  clemenslinders [ Sun May 29, 2011 3:24 pm ]
Post subject:  How to use drawimage (from lightswitch) stream returns error

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

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/