GDI+ supports a limited range of input file formats. You may wish to combine the import and export facilities of ImageGlue with those of GDI+ for a more comprehensive approach to drawing images.

This example shows how to draw a JPEG file using GDI+ and then export it in Adobe Photoshop format using ImageGlue.

1
Drawing using GDI+

We create our GDI+ Bitmap from our source image.

[C#] string path = Server.MapPath("rez/birds.jpg");
Bitmap bitmap = (Bitmap)Bitmap.FromFile(path);


[Visual Basic] Dim bitmap As Bitmap
bitmap = bitmap.FromFile(Server.MapPath("rez/birds.jpg"))


2
Exporting using ImageGlue

To export using ImageGlue we'll need an XImage which we can obtain using XImage.FromBitmap. After this it's simply a matter of saving the image in Adobe Photoshop format.

[C#] Canvas canvas = new Canvas(XImage.FromBitmap(bitmap));
canvas.SaveAs(Server.MapPath("ImageGlue_Export_NET_10.psd"));


[Visual Basic] Dim canvas As New Canvas(XImage.FromBitmap(bitmap))
canvas.SaveAs(Server.MapPath("ImageGlue_Export_NET_10.psd"))


3
Tidying Up

Finally we release any memory being used by our objects.

[C#] bitmap.Dispose();
canvas.Clear();


[Visual Basic] bitmap.Dispose()
canvas.Clear()


4
Input and Output

Sample input and output images are shown below.


rez/birds.jpg


ImageGlue_Export_NET_10.psd