Home | About us | Overview | Softwares - Downloads | Evaluate | Order | Support | old forums | Contact | F.A.Q. | Documentations | Search | Sitemap

Exporting a GdPicture Image to a DotNet Image

Support for GdPicture Light Imaging Toolkit and GdPicture Pro Imaging ActiveX/SDK.

Exporting a GdPicture Image to a DotNet Image

Postby Zorbania on Mon Aug 25, 2008 4:08 pm

I'm trying to use Gdimage control to manipulate a picture. and view the image outside the GDViewer.. do to live camera video. Transparency seems to only remove the RGB values not the ALPHA values into any object outisde the gdviewer.. is there a solution for this.. or a way to get the GdImage with transpency to a VB Image object.

Dim vMasterImage as image
GdImage.CreateImageFromFile(vPath)
GdImage.ConvertTo32BppARGB()
GdImage.SetTransparencyColor(GdPicturePro5.Colors.White)
GdImage.SetTransparency(-50)
vMaterImage=GdImage.GetPicture

Please HELP!!
Zorbania
 
Posts: 2
Joined: Mon Aug 25, 2008 3:55 pm

Re: Using Transparency

Postby Loïc on Mon Aug 25, 2008 4:25 pm

Hi,

You are loosing the Alpha channel here:

Code: Select all
vMaterImage=GdImage.GetPicture


The GetPicture() method returns an OLE Picture object wich don't support Alpha Channel.

You can create a DotNet image object from a GdPicture imaging object like this:

Code: Select all
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
   Dim Imaging1 As New GdPicturePro5.cImaging
   Imaging1.CreateImageFromFile("c:\test.jpg")
   Dim GdipImage As IntPtr = New IntPtr(Imaging1.GetGdiplusImage)
   Dim MyImage As Image = GetDotNetBitmap(GdipImage)
End Sub

Public Function GetDotNetBitmap(ByVal GdipImage As IntPtr) As Bitmap
        Dim imageType As Type = GetType(System.Drawing.Bitmap)

        Return DirectCast(imageType.InvokeMember("FromGDIplus", BindingFlags.NonPublic Or BindingFlags.Static Or BindingFlags.InvokeMethod, _
        Nothing, Nothing, New Object() {GdipImage}), Bitmap)
End Function



Note: To be able to run this code you have to import System.Reflection within your module.

Add:

Code: Select all
Imports System.Reflection



Best regards,

Loïc
User avatar
Loïc
Site Admin
 
Posts: 1350
Joined: Tue Oct 17, 2006 11:48 pm
Location: France


Return to GdPicture [Pro] ActiveX

Who is online

Users browsing this forum: No registered users and 0 guests