New SDK for image filters

Scripts and programs to automate Astroart
Post Reply
fabdev
Posts: 495
Joined: 03 Dec 2018, 21:43

New SDK for image filters

Post by fabdev » 15 May 2023, 15:29

Hello, Astroart 8 SP4 includes a new SDK to easily develop image processing filters.
Using a built-in dialog window, Astroart will manage automatically:
  • Preview
  • Real-time preview
  • Comparison with the original image
  • Undo
  • Documentation
so, the programmer only needs to code the filter itself.

The parameters of the dialog window are prepared as a multiline text, for example:

Code: Select all

NUMBER "High pass" 70 0 100 5
NUMBER "Opacity" 100 0 100 5
BOOLEAN "Adaptive" 1
HELP "HighPassDemo.htm"
will create the following dialog window:
The SDK contains an example (for Visual Studio, Codeblocks GCC, Lazarus, Delphi), which creates a different dialog window, with an option to flip the image:

Code: Select all

void WINAPI pi_process(void *pimage, HWND whandle)
{
 double *pv1,*pv2;
 double vnew,vori,c1,c2;
 int x,y,ix,iy,r;
 bool cflip;

 pv1 = (double*)fcallback(ac_getdialogparam, DLG_NAME, (void*)1, NULL);
 c1 = *pv1 / 100.0;
 c2 = 1.0 - c1;
 pv2 = (double*)fcallback(ac_getdialogparam, DLG_NAME, (void*)2, NULL);
 cflip = *pv2 != 0.0;

 fcallback(ac_getsize, pimage, &dimx, &dimy);
 r = fcallback(ac_getbuffer, pimage, &newbuffer,(void*)PC_GREEN);
 if (r != 2) return;
 r = fcallback(ac_getundobuffer, pimage, &undobuffer,(void*)PC_GREEN);
 if (r != 2) return;
 
 for (iy=0; iy<dimy; iy++) {
   y = iy;
   if (cflip)
     y = dimy-1-iy;
   for (ix=0; ix<dimx; ix++) {
     x = ix;
     vnew = getPixel(x,y)*5.0 - getPixel(x+1,y) - getPixel(x,y+1) - getPixel(x-1,y) - getPixel(x,y-1);
     vori = getPixel(x,y);
     setPixel(ix, iy, vnew*c1 + vori*c2);
   }
 }
}
The first section reads the parameters from the dialog window.
The second section prepares the buffers.
The third section is the actual code of the filter. Just modify this section to experiment with your own filters.

nmac
Posts: 15
Joined: 15 Jan 2019, 14:53

Re: New SDK for image filters

Post by nmac » 19 May 2023, 19:16

Hi!
I have been developing some plugins for Astroart (ex: ArcSin and GHS) and I was trying to find a way to preview the plugins before applying them.
This is just what I need! Thank you very much, for the SP4 but specially for the SDK update! This is a very important milestone for plugin development.

Just a question, to expand current dialog options (number,boolean,string), would it be possible to implement at least a dropdown/pulldown values/text selection and eventually value sliders?
Also, the help button option is not working for me as given by plugin example.

Post Reply