New SDK for image filters
Posted: 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:
The parameters of the dialog window are prepared as a multiline text, for example:
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:
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.
Using a built-in dialog window, Astroart will manage automatically:
- Preview
- Real-time preview
- Comparison with the original image
- Undo
- Documentation
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"
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 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.