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()