Download

GDI+ Type Library (GDIPlus.TLB) version 1.31
Updated Wednesday, 01 Sep 2004 20:21:14 UTC

This Type Library (featured on VbAccelerator) provides everything you need to start working with GDI+ in Visual Basic giving you direct access to the native GDI+ functions. The TLB only exposes the Native(Flat) exports from the GDI+ DLL and not the C++ class methods.

Open Gdiplus.tlb with OleView.Exe to see in detail what is available.
   In v1.31 this is correct:
   Dim uClsidEncoder    As CLSID
   Dim uEncParams       As EncoderParameters

 
 GdipSaveImageToFile GpImagePtr, sFileName, uClsidEncoder, VarPtr(uEncParams)
 

GDIPlus.TLB  includes all the Constants, Declares, Enumerations and Structures(UDT) from the Platform SDK as well as some general Win API support:

GDIPlus.TLB Modules

GDI+Constants.inc Gdi32.inc
GDI+Enums.inc Kernel32.inc
GDI+Exports.inc * Ole32.inc
GDI+FunctionNameStrings.inc OleAut32.inc
GDI+PointerNameStrings.inc OlePro32.inc
GDI+Structures.inc * Shell32.inc
GUIDStrings.inc User32.inc
WinMultiMedia.inc  

 

* Addition 11-Sep-2003 GdipAlloc and GdipFree
* Addition 11-Sep-2003 Misc. PointerNameStrings
* Bug Fix 11-Sep-2003 Change EncoderParameter in GdipSaveImageToFile, GdipSaveImageToStream, Long pointer. See note to the right concerning this problem.
* Bug Fix 02-Aug-2003 Fixed Declares which use IStream. Thanks to Zak Benjamin for pointing out this error.
* Bug Fix 03-Jul-2003 Fixed GdipGetImageThumbnail Declare.
* Bug Fix 03-Jul-2003 Updated PictDesc UDT member names to comply with PlatformSDK.

 

You must have the GDIplus.DLL package installed on your machine. See Requirements

To see the library in use, check out:

More related postings although not using this TLB can be found by searching 'GDI+' at http://www.Planet-Source-Code.com/vb
 


Code that works with internal declares may behave differently(even crash) using the Tlb. Most if not all of these problems can be traced to one or more of the following:

  • Incorrect parameter type in the TLB declare. Try a local declare to override the TLB to see if this is true. Please report any problems so we can fix it.
  • Passing illegal parameters.
  • Passing paramaters using the wrong format.
    For example encoderParams needs to be a structure in memory containing first a long variable containing count, followed by an array of arbitrary EncoderParameter structures. This must be laid out as a memory pointer and leads to a thorny coding problem in VB and in the Type Library: How do you declare the parameters you're going to pass if you don't know how many of them there are or anything about how their data is laid out in memory?
    There are no standard answers to these kinds of questions. The only real way around them is to work out what would be expected in memory and build it up as best you can, using a combination of structures, byte arrays, and memory allocations as required.
  • Not deleting objects that you create or trying to create a new object without first releasing the old one. At minimum this will cause a memory leak and quite often a GPF.
     

By using a TLB in lieu of Declares you not only eliminate cut and paste but more important is that your compiled Exe only includes the TLB items that are used.
Type Libraries are usually required only at design and compile time. Once the project that uses it is compiled the type library is not required anymore. So the library size does not matter because you do not have to include it in the installation package.

Another major advantage is that you can pass a Unicode string directly without having to use a Byte Array or StrPtr.


IStream, IPersistStream are not included. TLBs that support these interfaces can be found at:
 
Name URL Comments
OLELIB.TLB www.domaindlx.com/e_morcillo/ Supersedes Strm.Tlb
ISTORAGE.TLB www.vbbyjc.com/  
STRM.TLB www.vbaccelerator.com Now included in OleLib.Tlb
VBACOM.TLB www.vbaccelerator.com  

 

Other Gdiplus TLBs available for Vb

Name URL Comments
gdip.zip www.syix.com/wpsjr1 Type Library and Samples.
gdiplus7.zip http://www.visualbasicforum.com/t98285.html 22 Oct 2003, 06:19 PM

Gdiplus Classes available for Vb

Name URL Comments
gdip.zip www.syix.com/wpsjr1 Bitmap and graphics class wrappers. Latest version includes IStream and initial support for GdiPlus v6.
GpGDIPlus Wrapper v1.0 www.planet-source-code.com/vb 13 Class Wrappers
Genghis Khan
13-May-2003
 GDIPlus Wrapper.zip (57K) VbAcceleratorGDI+ Wrapper Article 13 Class Wrappers
Copyright 2003 Steve McMahon