views:

319

answers:

2

im currently trying out GD-Sharp and wanted to convert the graphic into bitmap without saving it to image file.

GD-Sharp method to save to stream is

bool GB.Save(Stream outStream);

for saving using stream is

using(FileStream fs = File.OpenWrite(@"stream1.jpg")) 
{
 image.Save((System.IO.Stream)fs);
 fs.Close();
}

since bitmap supports stream, how do it convert GD-Sharp to Bitmap ? thanks.

A: 

You can use a MemoryStream, something like

gdsBitmap.Save(memStream);
memStream.Seek(0);
gdiBitmap = Bitmap.FromStream(memStream);
Henk Holterman
A: 

i did something like this.

MemoryStream memStream = new MemoryStream();
gdimg.Save(memStream); 
Bitmap bmp2 = new Bitmap(memStream);
khalil