You are not logged in.
Pages: 1
Hello,
in the synpdf.pas in
initialization
{$ifdef USE_SYNGDIPLUS}
// initialize the Gdi+ library if necessary
if Gdip=nil then
Gdip := TGDIPlus.Create('gdiplus.dll');
{$endif}
the GDIPlus is created when the define is set.
This leads to trouble if the unit is used in a DLL since windows does not allow to initialize and deinitialize the gdiplus in dllmain ("Do not call GdiplusStartup or GdiplusShutdown in DllMain or in any function that is called by DllMain. If you want to create a DLL that uses GDI+, you should use one of the following techniques to initialize GDI+:", https://docs.microsoft.com/en-us/window … usstartup)
Two questions:
1. What is the reason for synpdf to use GDI+? Which functiosn depends on GDI+?
2. If GDI+ is essential needed for some functions then how could the code be changed to allow the usage in a DLL?
Greetings
Stefan
Offline
IIRC, it is for PNG and JPEG support - since it is faster than Delphi's corresponding libraries.
You can disabled GDI+ by defining the NO_USE_SYNGDIPLUS conditional in your project.
As clearly stated by the code, by the way:
{$define USE_SYNGDIPLUS}
{ - if defined, the PDF engine will use SynGdiPlus to handle all
JPG, TIF, PNG and GIF image types (prefered way, but need XP or later OS)
- if you'd rather use the default jpeg unit (and add some more code to your
executable), undefine this conditional }
{$ifdef NO_USE_SYNGDIPLUS}
{ this special conditional can be set globaly for an application which doesn't
need the SynGdiPlus features (like TMetaFile drawing), and would rather
use the default jpeg unit }
{$undef USE_SYNGDIPLUS}
{$endif}
Offline
And the speed of the functions is the only difference? No other functional differences?
If so I comment the usage of GDIPLus out by {.$define USE_SYNGDIPLUS}
But in spite of this I think the way SynPDF initialize the GDI+ should be changed (not inizialize it in initialization-part but when it first uses it)
Offline
I guess https://synopse.info/fossil/info/5daa90cf6a would help.
Offline
But this fix is not enough.
If USE_SYNGDIPLUS is defined in SynPDF then in the uses a
{$ifdef USE_SYNGDIPLUS}
SynGdiPlus, // use our GDI+ library for handling TJpegImage and such
{$else}
is done.
In SynGDIPlus the initialization looks like
initialization
Windows.InitializeCriticalSection(GdipCS);
{$ifndef NOTSYNPICTUREREGISTER}
Gdip.RegisterPictures; // will initialize the Gdip library if necessary
// GdipTest('d:\Data\Pictures\Sample Pictures\Tree.jpg');
{$endif}
and the RegisterPictures Creates the GDIPLus and we have the same problem again (Init of GDIPlus in dllmain).
This must be changed too. How?
Offline
That's a possible solution but this means that I could not use precompiled DCUs in the IDE because I have ActiveX-DLLs, In-Proc-COM-Server-DLLs and normal EXEs.
In my opinion the best solution would be if the component take care of if running in a DLL and do the RegisterPictures somewhere else in code if this would be possible.
Offline
Pages: 1