tags:

views:

15

answers:

0

Hi,

We load an image from file and display it in PictureEdit(devexpress control).Then,user clicks a button to embed some text on the image(customer name).When we try to save to file(PictureEditProduct.Image.Save),we get an error "a generic error occurred in GDI+". The code

       Dim bm As Bitmap = CType(PictureEditProduct.Image, Bitmap)
        If bm Is Nothing Then
            Return
        End If
        Dim g As Graphics = Graphics.FromImage(bm)
        Dim f As New Font("Arial", 22)
        Dim b As Brush = New SolidBrush(Color.Black)
        g.DrawString(customer.Name, f, b, 5, 5)

        Me.PictureEditProduct.Image = bm
        Me.PictureEditProduct.Refresh()
        Dim ms As MemoryStream = New MemoryStream()
        PictureEditProduct.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg) 

        Dim imageBinary As New System.Data.Linq.Binary(ms.ToArray())

        customer.Photo = imageBinary

        ms.Dispose()
        ms.Close()