ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Photoshop plugin host
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

spetric

Croatia
308 Posts

Posted - Aug 04 2020 :  20:12:37  Show Profile  Reply
Hi,

I have managed to rewrite and correct Photoshop plugin host (for 8bf filters) and the source code is available on GitHub:

https://github.com/spetric/Photoshop-Plugin-Host

It works with 32 and 64-bit plugins.

Before I create release (DLLs) and pack it together with source code, it would be nice if someone converts two headers to Pascal. That's only what needs to be converted so that engine can work from Delphi:

https://github.com/spetric/Photoshop-Plugin-Host/blob/master/pspiHost/pspiGlobals.h

and

https://github.com/spetric/Photoshop-Plugin-Host/blob/master/pspiHost/pspiHost.h

You can neglect #include "PITypes.h" in pspiGlobals.h as it's only used for uint32 (unsigned int 32-bit). The second file (pspiHost.h) actually contains APIs specification.

As you can see from description, engine supports ImageEn RGB+A format.

EDIT: #include "PITypes.h" removed from pspiGlobals.h, so only constants, one enum and three typedefs need to be converted. Regarding pspiHost.h, only API calls need to be converted.

TIA,
Siniša

xequte

38619 Posts

Posted - Aug 06 2020 :  19:41:22  Show Profile  Reply
Hi Sinisa

It is mostly done, just need to work out the PSPI_API define.

attach/xequte/202086194115_conv.zip
2.02 KB

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

spetric

Croatia
308 Posts

Posted - Aug 07 2020 :  16:01:55  Show Profile  Reply
Hi Nigel,

Thanks a lot. Ther is no need for cdecl, as the calling convention is stdcall, not cdecl. Also, there is no need for external PSP_API.

You can delete that as complete block. External keyword comes in implementation block. I'll put corrected version on GitHub. besides you, who else needs to be credited for conversion?

Here are converted spEngine headers corrected by William Miller.

attach/spetric/202087153816_spEnginePasheaders.zip
4.76 KB

I have corrected as much as possible and upload it on GitHub (Additional/Delphi).

With best regards,
Siniša



Go to Top of Page

spetric

Croatia
308 Posts

Posted - Aug 07 2020 :  18:17:59  Show Profile  Reply
Hi Nigel,

I thought of creating DLLs today, but I made one oversight.
Unlike OpenCV image Mat which has top-down scanline orientation,
ImageEn TIEBitmap and also ordinary TBitmap has bottom-up scanline orientation, which results in upside-down image in plug-in:



Not a problem, I have to add another parameter when setting image to pspiHost.
I'll add it tomorrow.

BTW, complete test program in Berlin 10.1 has less then 50 lines of C++ code.

With best regards and thanks again for converting header files,
Siniša
Go to Top of Page

xequte

38619 Posts

Posted - Aug 08 2020 :  02:08:09  Show Profile  Reply
Hi Sinisa

There is an option in TIEBitmap to handle that too:

https://www.imageen.com/help/TIEBitmap.Origin.html

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

spetric

Croatia
308 Posts

Posted - Aug 08 2020 :  13:38:55  Show Profile  Reply
Hi Nigel,

Thanks for info. Anyway, I have added one API pspiSetImageOrientation and
before setting image to pspiHost, user can set image orientation (ASIS or INVERTED). It needs to be called only once in application.




However, I've noticed a problem (similar to scanner preview dialog problem I posted about) and that is styling non-VCL windows from VCL-styled application.
I will make a post on StackOverflow if someone can inform me about this strange
behavior.

The same plug-in not only looks different but is also slow, especially when image is zoomed or panned...completely unusable, as it constantly repaints complete plug-in window.

Thanks again,
Siniša
Go to Top of Page

spetric

Croatia
308 Posts

Posted - Aug 08 2020 :  16:39:32  Show Profile  Reply
Hi,

Here is a small demo (C++ source code only) and pspiHost.dll (32-bit).
There is nothing special in source code: loading image, few API calls
and that's it. Filter path is hard-coded. It's easy to convert that in Delphi.

For appropriate Delphi files, jump to: https://github.com/spetric/Photoshop-Plugin-Host/tree/master/Additional/Delphi and download them.

Demo + 32-bit dll:

attach/spetric/202088163743_PluginDemoPlusDll32.zip
74.94 KB

If it works in Delphi, that's it.
If not, I'll change __stdcall to cdecl to avoid MS name mangling/decoration.
Go to Top of Page

spetric

Croatia
308 Posts

Posted - Aug 10 2020 :  04:22:18  Show Profile  Reply
Hi,

__stdcall was definitively a bad idea because of MS name decoration.
Calling convention changed to cdecl, so to avoid decoration of APIs.

Delphi pas files corrected, OMF static libs (for Embarcadero C++) and release DLLs uploaded to GitHub (32 and 64 bit):

https://github.com/spetric/Photoshop-Plugin-Host/tree/master/Additional

Demo code is still the same.
Go to Top of Page

xequte

38619 Posts

Posted - Aug 10 2020 :  22:33:58  Show Profile  Reply
Hi Sinisa

I converted the demo, but wasn't able to get it to work. All the DLL calls get a non-zero result, e.g. pspiSetImage returns 15.

www.imageen.com/temp/PspiPlugin.zip

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

spetric

Croatia
308 Posts

Posted - Aug 11 2020 :  03:16:47  Show Profile  Reply
Hi Nigel,

I've added a log in pspiSetImage API and here are results when loading an image
from PspiDemo.exe you've sent me:

image type: 768
width: 800
height: 600
imageBuff: 0AA9B040
imageStride: 2400
alphaBuff: 00000000
alphaStride: 0

Width, height, buffer and stride are passed correctly, the problem is image type, which is 768 (received by API)!? As TImgType enum ranges from 0 to 5,
pspiSetImage API returns PSPI_ERR_BAD_IMAGE_TYPE which is 15 (pspiGlobals.pas).

For testing purposes I forced correct type in DLL and it works fine:



Can you check what is the value in aType before it's passed to API.
We just need to solve that TImgType enum/type variable passing. The rest is obviously OK.

Thanks,
Siniša

Go to Top of Page

xequte

38619 Posts

Posted - Aug 11 2020 :  19:26:55  Show Profile  Reply
Hi Sinisa

I changed the type of the ImgType parameter to integer rather than TImgType, which seemed to resolve it.

My filters don't seem to work though (get PSPI_ERR_FILTER_INVALID). Can you forward me some filters to try.

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

spetric

Croatia
308 Posts

Posted - Aug 12 2020 :  05:32:12  Show Profile  Reply
Hi Nigel,

Some older plugins may not work. I've tried some in C# PspHost application written for paint.net and it also returned an error.

Here are plugins collection that work:

http://flamingpear.com/free-trials.html#freebies

You can try Kyoto colors an Pixel trash as they have form with preview and controls.

https://www.mehdiplugins.com/

From this collection, you can try Absolute Colors 1.2, Curves 3, Edges Fx, Grain Natural 2.

This site contains some good freeware (at the bottom of the page):
https://www.redfieldplugins.com/Downloads.htm

I would recommend trying 32-bit plugins first, as I did not covered some newest 64-bit plugin formats involving BigDocument structure (prepared but not yet implemented), although most 64-bit filters work OK:




NOTE: Before trying plugins, please download newest DLLs from GitHub as I've corrected some nasty bugs (writing beyond image buffer):
https://github.com/spetric/Photoshop-Plugin-Host/tree/master/Additional

Also, I'll pack some working collection and upload the zip file.

I've also tried about, progress and enumerate APIs and they work correctly. On the upper image you can see how filters from given directory are enumerated: categories in one TListBox and filter names in another TListBox. When category is clicked, filters belonging to current category are put in TListBox.

With best regards,
Siniša
Go to Top of Page

xequte

38619 Posts

Posted - Aug 13 2020 :  02:41:50  Show Profile  Reply
Hi Sinisa

Yes, now it is working well.

I have corrected pspiGlobals.pas and pspiHost.pas. Please update git with these new versions.

The updated demo now enumerates the the \PlugIns\ sub-folder, and also shows progress. You can just double-click a filter to test it.

www.imageen.com/temp/PspiDemo2.zip



Nigel
Xequte Software
www.imageen.com
Go to Top of Page

spetric

Croatia
308 Posts

Posted - Aug 13 2020 :  04:47:24  Show Profile  Reply
Hi Nigel,

Thanks for your time. Glad to see that it works.

I'll put new pas files to GitHub and also correct pspiSetMask API.
Nothing special, just added default arg values to 0, so when pspiSetMask is called without arguments, mask will be cleared. Of course, not mask created in application, just shared scanline pointers inside pspiHost.

As version 0.8 had a bug with setting mask (corrupting internal image scanlines, my fault...one wrong line of code), I'll also update source code and binaries on Github.

So far I've tested masking using Selection mask. Works with SelectionFeather and
also color picker call-back works (for plug-ins that have color picking feature). Only thing left is testing ROI (selection rectangle) in combination with mask.

I'll also add complete NiGulp application source code (NiGulp - opposite of PlugIn) to GitHub when I finish it, so if anyone wants to create wrapper class (C++/Delphi) for TImageEn can do it with minimal efforts.

With best regards,
Siniša

Go to Top of Page

xequte

38619 Posts

Posted - Oct 11 2020 :  23:52:00  Show Profile  Reply
Hi Sinisa

If you are happy with the current state, I will add a link to our download page.

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

Dimon_II

Ukraine
1 Posts

Posted - Jan 07 2021 :  19:11:30  Show Profile  Reply
Hi
I'm trying to use demo (5.0 and 6.3) version of Sattva Descreen.8bf plugin.
Filter works in Photoshop, Irfanview only works fine with version 5, but NiGulp display only "Error executing filter, rc = 5". What does this mean and can it be fixed?

Go to Top of Page

spetric

Croatia
308 Posts

Posted - Jan 09 2021 :  14:16:50  Show Profile  Reply
Hi,

RC=5 means that filter is canceled.
This return code usually means that user has interrupted filter execution.

It also may occur in the first stage of execution (filterSelectorParameters).
It rarely occurs, but it seams that in this case filterSelectorParameters
has failed.

This may occur for several reasons, probably because filter requires
something that pspiHost.dll currently does not support (big document data, padding, etc..).
Go to Top of Page

klausdoege

Germany
389 Posts

Posted - Feb 03 2021 :  04:16:35  Show Profile  Reply
Hi Spetric,
i use nigel's pspihost Demo, but the 64bitt dll work not realy ?
32bit program With 32bit dll

64bit program with 64bit dll

Can you Help ?

Klaus
www.klausdoege.de
Go to Top of Page

yogiyang

India
727 Posts

Posted - Feb 04 2021 :  06:15:15  Show Profile  Reply
Probably you are using 32bit plugins in 64bit version. This will not work.

If your app is 64bit then you will have to use 64bit plugins only.

Yogi Yang
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: