It is possible create with internal Python a script with window and let's say a simple slider and have
a live preview on image canvas while it is this slider moving?
Live preview while still running script - possible?
Moderator: Kathy_9
-
LeviFiction
- Advisor
- Posts: 6831
- Joined: Thu Oct 02, 2008 1:07 pm
- System_Drive: C
- 32bit or 64bit: 64 Bit
- motherboard: Alienware M17xR4
- processor: Intel Core i7-3630QM CPU - 2_40GH
- ram: 6 GB
- Video Card: NVIDIA GeForce GTX 660M
- sound_card: Sound Blaster Recon3Di
- Hard_Drive_Capacity: 500GB
- Corel programs: PSP: 8-2023
- Location: USA
Re: Live preview while still running script - possible?
Possible? Yes. Depends on the how the effect is supposed to work. Make sure the script does not run "OptimizedUndo" command which treats the effect of the script as a single event. This allows you to use "Undo" in your script to undo the steps of your effect and then re-run them.
Another option is to create a temporary layer and perform the effect on this layer. Every time the slider updates delete the test layer and start over.
Another option is to create a temporary layer and perform the effect on this layer. Every time the slider updates delete the test layer and start over.
https://levifiction.wordpress.com/
-
JoeB
- Posts: 2778
- Joined: Fri Mar 28, 2008 10:04 pm
- System_Drive: C
- 32bit or 64bit: 64 Bit
- motherboard: LENOVO 4524PE4 ThinkCentre M91p
- processor: 3.10 gigahertz Intel Quad Core i5-2400
- ram: 8 GB
- Hard_Drive_Capacity: 4.6 TB
- Corel programs: PSP 9, X7 to 2019, 32 & 64-bit
- Location: Canada
Re: Live preview while still running script - possible?
I admit that I don't have a clue what the OP is trying to achieve, and therefore don't know how the reply works either. Levifiction, could you enlighten me? But only if it is something that another person (like me) might possibly have a use for. An example for the slow learner - again like me - would be appreciated! 
Regards,
JoeB
Using PSP 2019 64bit
JoeB
Using PSP 2019 64bit
-
LeviFiction
- Advisor
- Posts: 6831
- Joined: Thu Oct 02, 2008 1:07 pm
- System_Drive: C
- 32bit or 64bit: 64 Bit
- motherboard: Alienware M17xR4
- processor: Intel Core i7-3630QM CPU - 2_40GH
- ram: 6 GB
- Video Card: NVIDIA GeForce GTX 660M
- sound_card: Sound Blaster Recon3Di
- Hard_Drive_Capacity: 500GB
- Corel programs: PSP: 8-2023
- Location: USA
Re: Live preview while still running script - possible?
As I read Radim's question I'm less convinced of my answer. I think Radim was looking for something closer to a real-time preview which would require much faster processing than is available to python scripting. Especially python scripting that doesn't make use of binaries and some of the more advanced libraries.
My answer revolved around the idea of making your own effect or filter in Python. So, you know how if you turn on the "Preview on Image" option for various filters like brightness/contrast or cuves and you adjust a slider or point the image automatically updates. Some of the ore intense filters will update only after you've let go of the slider or idled for too long.
So I was answering that it would be possible to make a UI with a slider, and then to preview the change on the canvas before the script ended. One example would be the PerlinNoise script I uploaded. If that script took parameters (and was faster) I could have a slider for the parameters, then see the result of those changes directly on the canvas. However, because of how slow and high-level the interaction scripting is with PSP the best you can do is to, in the script, use a bunch of Undo commands or perform all of the changes onto layers deleting and redrawing them each time the parameters changed.
Continuing to use the PerlinNoise as an example.
Right now it saves a file, then loads that file, copies that file to the clipboard, closes that file, and pastes it as a new layer. If I had parameters and a live preview, every time the parameter changed I would have to delete the layer I made, recreate the image, load it, copy it to the clipboard, and paste as a new layer. Every single time.
I can do this another way by taking the bitmap data and instead of saving a file, just pasting it directly to the clipboard (with some intense widows api clipboard coding) and then paste as a new layer into PSP. But I would still have to paste as a new layer, then delete the layer and paste a new layer in every time I wanted to update live to the canvas.
Another example is this. Before we got the Outer Glow layer effect they had a script that used drop shadows to simulate an outerglow effect. But it opened the drop shadow dialog twice to do this. It would be possible to create a custom UI that included size, opacity, and color. Then based on those parameters run the drop-shadow command twice with the parameters set. Since this either creates the shadows on their own layer or destructively effects the current layer it's easier to use two "Undo" commands after each parameter change to undo the two applications of drop-shadow before reapply the drop shadow twice. So here we're undoing our effect every time the parameters change so that we get back to the original state of the image before applying the new parameters.
My answer revolved around the idea of making your own effect or filter in Python. So, you know how if you turn on the "Preview on Image" option for various filters like brightness/contrast or cuves and you adjust a slider or point the image automatically updates. Some of the ore intense filters will update only after you've let go of the slider or idled for too long.
So I was answering that it would be possible to make a UI with a slider, and then to preview the change on the canvas before the script ended. One example would be the PerlinNoise script I uploaded. If that script took parameters (and was faster) I could have a slider for the parameters, then see the result of those changes directly on the canvas. However, because of how slow and high-level the interaction scripting is with PSP the best you can do is to, in the script, use a bunch of Undo commands or perform all of the changes onto layers deleting and redrawing them each time the parameters changed.
Continuing to use the PerlinNoise as an example.
Right now it saves a file, then loads that file, copies that file to the clipboard, closes that file, and pastes it as a new layer. If I had parameters and a live preview, every time the parameter changed I would have to delete the layer I made, recreate the image, load it, copy it to the clipboard, and paste as a new layer. Every single time.
I can do this another way by taking the bitmap data and instead of saving a file, just pasting it directly to the clipboard (with some intense widows api clipboard coding) and then paste as a new layer into PSP. But I would still have to paste as a new layer, then delete the layer and paste a new layer in every time I wanted to update live to the canvas.
Another example is this. Before we got the Outer Glow layer effect they had a script that used drop shadows to simulate an outerglow effect. But it opened the drop shadow dialog twice to do this. It would be possible to create a custom UI that included size, opacity, and color. Then based on those parameters run the drop-shadow command twice with the parameters set. Since this either creates the shadows on their own layer or destructively effects the current layer it's easier to use two "Undo" commands after each parameter change to undo the two applications of drop-shadow before reapply the drop shadow twice. So here we're undoing our effect every time the parameters change so that we get back to the original state of the image before applying the new parameters.
https://levifiction.wordpress.com/
-
Radim
- Posts: 712
- Joined: Mon Nov 01, 2010 5:54 pm
- System_Drive: C
- 32bit or 64bit: 64 Bit
- ram: 4GB
- Monitor/Display Make & Model: 27 inch
Re: Live preview while still running script - possible?
Thank you LeviFiction you understand it perfectly.
I thought use this approach for a simple / low computing things of course.
I thought use this approach for a simple / low computing things of course.
-
JoeB
- Posts: 2778
- Joined: Fri Mar 28, 2008 10:04 pm
- System_Drive: C
- 32bit or 64bit: 64 Bit
- motherboard: LENOVO 4524PE4 ThinkCentre M91p
- processor: 3.10 gigahertz Intel Quad Core i5-2400
- ram: 8 GB
- Hard_Drive_Capacity: 4.6 TB
- Corel programs: PSP 9, X7 to 2019, 32 & 64-bit
- Location: Canada
Re: Live preview while still running script - possible?
Thanks Levi. I actually understood that! 
Regards,
JoeB
Using PSP 2019 64bit
JoeB
Using PSP 2019 64bit
