This is what i did. I was saving it to a webservice as a byte[] and then saving the byte array to sql. I also flattened the image first, which was the same way the current save works. This was all done in a dialog box, as i wanted the code to be eay to upgrade later on. All i have to do it create a new save item and call the dialog passing the document to it.
I also have code to get a picture from SQL and place it into a new document. The way the paint.net guys have done the code makes it really easy to move the images in and out of sql.
private void SaveWSImage()
{
try
{
// flatten the document
Document mydoc = privDoc;
System.IO.MemoryStream myoutput = new System.IO.MemoryStream();
using (Surface surface = new Surface(mydoc.Width, mydoc.Height))
{
surface.Clear(ColorBgra.FromBgra(255, 255, 255, 0));
using (RenderArgs ra = new RenderArgs(surface))
{
mydoc.Render(ra, true);
}
using (Bitmap bitmap = surface.CreateAliasedBitmap())
{
//LoadProperties(bitmap, myinput);
bitmap.Save(myoutput, System.Drawing.Imaging.ImageFormat.Png);
}
}
WebService1.Images ws = new WebService1.Images();
byte[] oFileByte = myoutput.ToArray();
ws.SaveImage(oFileByte, System.Convert.ToString(oFileByte.Length));
//
}
catch
{ }
}