[Mono-list] Question about encoding and tricky stuff.

Ian Norton ian.norton-badrul at thales-esecurity.com
Mon Aug 23 09:47:18 EDT 2010


On Mon, 2010-08-23 at 14:14 +0100, Rampage wrote:
> -----------------------------------------------------------------------------
> string sOutput = StartProcess("cat", picture.png");
> byte[] imagebytes = System.Text.Encoding.Default.GetBytes(sOutput);
> 
> Gdk.Pixbuf pb = new Gdk.PixBuf(imagebytes);
> 
> Image img = new Image(pb);
> --------------------------------------------------------------------------------
> 
> the program returns me with an exception saying that the file format for the
> pixbuf is not valid.

Perhaps this?

Process prc = new Process();
prc.StartInfo.UseShellExecute = false;
prc.StartInfo.FileName = sProgram;
prc.StartInfo.Arguments = sArguments;
prc.StartInfo.RedirectStandardOutput = true;
prc.Start();

bytes[] stdout = new byte[8192*1024];

int len = prc.StandardOutput.BaseStream.Read( stdout, 0, 8192*1024 );
Image img = new Image(stdout);

Ian
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part
Url : http://lists.ximian.com/pipermail/mono-list/attachments/20100823/97b51907/attachment.bin 


More information about the Mono-list mailing list