Using GdPicture.NET in WPF application

Using GdPicture.NET in WPF application.
Post Reply
User avatar
Loïc
Site Admin
Posts: 5570
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Using GdPicture.NET in WPF application

Post by Loïc » Tue Jul 12, 2011 6:25 pm

Here an example that converts a GdPicture image to a BitmapSource object, and uses the JpegBitmapEncoder to subsequently save the BitmapSource to a jpegfile.

Feel free to post any comment, questions about the snippet or request for other scenario support.

Also, you can find a WPF application demo based on GdPicture8 that demonstrate how to use GdPictureImaging & GdViewer class in a WPF windows.

Code: Select all

        Dim oGdPictureImaging As New GdPicture.GdPictureImaging

        oGdPictureImaging.SetLicenseNumber("XXX") 'Please replace XXX by a valid license KEY
        Dim ImageID As Integer = oGdPictureImaging.CreateGdPictureImageFromFile("")
        If ImageID <> 0 Then
            oGdPictureImaging.ConvertTo24BppRGB(ImageID)
            Dim MyBitmapSource As BitmapSource = System.Windows.Media.Imaging.BitmapSource.Create(oGdPictureImaging.GetWidth(ImageID), _
                                                                                                  oGdPictureImaging.GetHeight(ImageID), _
                                                                                                   oGdPictureImaging.GetHorizontalResolution(ImageID), _
                                                                                                   oGdPictureImaging.GetVerticalResolution(ImageID), _
                                                                                                   PixelFormats.Bgr24, _
                                                                                                   Nothing, _
                                                                                                   oGdPictureImaging.GetBits(ImageID), _
                                                                                                   oGdPictureImaging.GetStride(ImageID) * oGdPictureImaging.GetHeight(ImageID), _
                                                                                                   oGdPictureImaging.GetStride(ImageID))
            oGdPictureImaging.ReleaseGdPictureImage(ImageID)
            Dim MyEncoder As New JpegBitmapEncoder()
            MyEncoder.Frames.Add(BitmapFrame.Create(MyBitmapSource))
            Dim MyFileStream As New System.IO.FileStream("c:\test.jpg", System.IO.FileMode.Create)

            MyEncoder.Save(MyFileStream)
            MyFileStream.Close()
Attachments
wpf-demo.zip
GdPicture.NET in WPF demo
(11.08 KiB) Downloaded 391 times

matze
Posts: 1
Joined: Sun Feb 12, 2012 10:02 am

Re: Using GdPicture.NET in WPF application

Post by matze » Mon Feb 13, 2012 3:40 pm

Hi,
the link for the demo doesn't work.

User avatar
Loïc
Site Admin
Posts: 5570
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Using GdPicture.NET in WPF application

Post by Loïc » Mon Feb 13, 2012 3:45 pm

Hello,

Fixed. Please try again.

Kind regards,

Loïc

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest