-
-
Notifications
You must be signed in to change notification settings - Fork 191
/
VBP_ProcessorModule.bas
1354 lines (1052 loc) · 54.2 KB
/
VBP_ProcessorModule.bas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
Attribute VB_Name = "Processor"
'***************************************************************************
'Program Sub-Processor and Error Handler
'Copyright ©2001-2014 by Tanner Helland
'Created: 4/15/01
'Last updated: 22/August/13
'Last update: finish organizing processor calls by category. They now match their menu order, and I will try to keep it that way.
'
'Module for controlling calls to the various program functions. Any action the program takes has to pass
' through here. Why go to all that extra work? A couple of reasons:
' 1) a central error handler that works for every sub throughout the program (due to recursive error handling)
' 2) PhotoDemon can run macros by simply tracking the values that pass through this routine
' 3) PhotoDemon can control code flow by delaying requests that pass through here (for example,
' if the program is busy applying a filter, we can wait to process subsequent calls)
' 4) miscellaneous semantic benefits
'
'Due to the nature of this routine, very little of interest happens here - this is primarily a router
' for various functions, so the majority of the routine is a huge Case Select statement.
'
'All source code in this file is licensed under a modified BSD license. This means you may use the code in your own
' projects IF you provide attribution. For more information, please visit http://photodemon.org/about/license/
'
'***************************************************************************
Option Explicit
Option Compare Text
'Data type for tracking processor calls - used for macros (NOTE: this is the 2013 model; older models are no longer supported.)
Public Type ProcessCall
Id As String
Dialog As Boolean
Parameters As String
MakeUndo As Long
Tool As Long
Recorded As Boolean
End Type
'During macro recording, all requests to the processor are stored in this array.
Public Processes() As ProcessCall
'How many processor requests we currently have stored.
Public ProcessCount As Long
'Full processor information of the previous request (used to provide a "Repeat Last Action" feature)
Public LastProcess As ProcessCall
'Track processing (e.g. whether or not the software processor is busy right now)
Public Processing As Boolean
'Elapsed time of this processor request (to enable this, see the top constant in the Public_Constants module)
Private m_ProcessingTime As Double
'PhotoDemon's software processor. (Almost) every action the program takes is first routed through this method. This processor is what
' makes recording and playing back macros possible, as well as a host of other features. (See comment at top of page for more details.)
'
'INPUTS (asterisks denote optional parameters):
' - processID: a string identifying the action to be performed, e.g. "Blur"
' - *showDialog: some functions can be run with or without a dialog; for example, "Blur", "True" will display a blur settings dialog,
' while "Blur", "False" will actually apply the blur. If showDialog is true, no Undo will be created for the action.
' - *processParameters: all parameters for this function, concatenated into a single string. The processor will automatically parse out
' individual parameters as necessary.
' - *createUndo: ID describing what kind of Undo entry to create for this action. 0 prevents Undo creation, while values > 0 correspond
' to a specific type of Undo. (1 = image undo, 2 = selection undo - these values are needed because undoing a selection
' requires completely different code vs undoing an image filter.) This value is set to 1 by default, but some functions
' - like "Count image colors" - may explicitly specify that no Undo is necessary. NOTE: if showDialog is TRUE, this value
' will automatically be set to 0, which means "DO NOT CREATE UNDO", because we never create Undo data when showing a
' dialog (as the user may cancel it).
' - *relevantTool: some Process calls are initiated by a particular tool (for example, "create selection" will be called by one of the
' selection tools). This parameter can contain the relevant tool for a given action. If Undo is used to return to a
' previous state, the relevant tool can automatically be selected, making it much easier for the user to make changes
' to an action using the proper tool.
' - *recordAction: are macros allowed to record this action? Actions are assumed to be recordable. However, some PhotoDemon functions
' are actually several actions strung together; when these are used, subsequent actions are marked as "not recordable"
' to prevent them from being executed twice.
Public Sub Process(ByVal processID As String, Optional showDialog As Boolean = False, Optional processParameters As String = "", Optional createUndo As Long = 1, Optional relevantTool As Long = -1, Optional recordAction As Boolean = True)
'Main error handler for the software processor is initialized by this line
On Error GoTo MainErrHandler
'Mark the software processor as busy
Processing = True
'Disable the main form to prevent the user from clicking additional menus or tools while this action is processing
FormMain.Enabled = False
'If we need to display an additional dialog, restore the default mouse cursor. Otherwise, set the cursor to busy.
If showDialog Then
'If g_OpenImageCount > 0 Then
' If Not (pdImages(g_CurrentImage).containingForm Is Nothing) Then setArrowCursor pdImages(g_CurrentImage).containingForm
'End If
Else
Screen.MousePointer = vbHourglass
End If
'If we are to perform the last command, simply replace all the method parameters using data from the
' LastEffectsCall object, then let the routine carry on as usual
If processID = "Repeat last action" Then
processID = LastProcess.Id
showDialog = LastProcess.Dialog
processParameters = LastProcess.Parameters
createUndo = LastProcess.MakeUndo
relevantTool = LastProcess.Tool
recordAction = LastProcess.Recorded
End If
'If the macro recorder is running and this action is marked as recordable, store it in our array of processor calls
If (MacroStatus = MacroSTART) And recordAction Then
'First things first: if the current action is NOT selection-related, but the last one was, make a backup of all selection settings.
If (createUndo <> 2) And (LastProcess.MakeUndo = 2) And (Not (LastProcess.Id = "Finalize selection for macro")) Then
Process "Finalize selection for macro", False, pdImages(g_CurrentImage).mainSelection.getSelectionParamString, 2, g_CurrentTool, True
End If
'Increase the process count
ProcessCount = ProcessCount + 1
'Copy the current process's information into the tracking array
ReDim Preserve Processes(0 To ProcessCount) As ProcessCall
With Processes(ProcessCount)
.Id = processID
.Dialog = showDialog
.Parameters = processParameters
.MakeUndo = createUndo
.Tool = relevantTool
.Recorded = recordAction
End With
End If
'If a dialog is being displayed, disable Undo creation
If showDialog Then createUndo = 0
'If this action requires us to create an Undo, create it now. (We can also use this identifier to initiate a few
' other, related actions.)
If createUndo <> 0 Then
'Temporarily disable drag-and-drop operations for the main form
g_AllowDragAndDrop = False
FormMain.OLEDropMode = 0
'By default, actions are assumed to want Undo data created. However, there are some known exceptions:
' 1) If a dialog is being displayed
' 2) If recording has been disabled for this action
' 3) If we are in the midst of playing back a recorded macro (Undo data takes extra time to process, so drop it)
If MacroStatus <> MacroBATCH Then
If (Not showDialog) And recordAction Then pdImages(g_CurrentImage).undoManager.createUndoData processID, createUndo, relevantTool
End If
'Save this information in the LastProcess variable (to be used if the user clicks on Edit -> Redo Last Action.
FormMain.MnuEdit(2).Enabled = True
With LastProcess
.Id = processID
.Dialog = showDialog
.Parameters = processParameters
.MakeUndo = createUndo
.Tool = relevantTool
.Recorded = recordAction
End With
'If the user wants us to time how long this action takes, mark the current time now
If Not showDialog Then
If DISPLAY_TIMINGS Then m_ProcessingTime = Timer
End If
End If
'Finally, create a parameter parser to handle the parameter string. This class will parse out individual parameters
' as specific data types when it comes time to use them.
Dim cParams As pdParamString
Set cParams = New pdParamString
If Len(processParameters) > 0 Then cParams.setParamString processParameters
'******************************************************************************************************************
'
'BEGIN PROCESS SORTING
'
'The bulk of this routine starts here. From this point on, the processID string is compared against a hard-coded
' list of every possible PhotoDemon action, filter, or other operation. Depending on the processID, additional
' actions will be performed.
'
'Note that prior to the 6.0 release, this function used numeric identifiers instead of strings. This has since
' been abandoned in favor of a string-based approach, and at present there are no plans to restore the old
' numeric behavior. Strings simplify the code, they make it much easier to add new functions, and they will
' eventually allow for a "filter browser" that allows the user to preview any effect from a single dialog.
' Numeric IDs were much harder to manage in that context, and over time their numbering grew so arbitrary that
' it made maintenance very difficult.
'
'For ease of reference, the various processIDs are divided into categories of similar functions. These categories
' match the organization of PhotoDemon's menus. Please note that such organization (in this function, anyway) is
' simply to improve readability; there is no functional implication.
'
'******************************************************************************************************************
Select Case processID
'FILE MENU FUNCTIONS
' This includes actions like opening or saving images. These actions are never recorded.
Case "Open"
MenuOpen
Case "Close"
MenuClose
Case "Close all"
MenuCloseAll
Case "Save"
MenuSave g_CurrentImage
Case "Save as"
MenuSaveAs g_CurrentImage
Case "Revert"
If FormMain.MnuFile(7).Enabled Then
pdImages(g_CurrentImage).undoManager.revertToLastSavedState
'Also, redraw the current child form icon and the image tab-bar
createCustomFormIcon pdImages(g_CurrentImage)
toolbar_ImageTabs.notifyUpdatedImage g_CurrentImage
End If
Case "Batch wizard"
If showDialog Then
'Because the Batch Wizard window provides a custom drag/drop implementation, we disable regular drag/drop while it's active
g_AllowDragAndDrop = False
showPDDialog vbModal, FormBatchWizard
g_AllowDragAndDrop = True
End If
Case "Print"
If showDialog Then
'As a temporary workaround, Vista+ users are routed through the default Windows photo printing
' dialog. XP users get the old PD print dialog.
If g_IsVistaOrLater Then
printViaWindowsPhotoPrinter
Else
If Not FormPrint.Visible Then showPDDialog vbModal, FormPrint
End If
'In the future, the print dialog will be replaced with this new version. However, there are
' bigger priorities for 6.2, so I'm putting this on hold for now...
'If Not FormPrintNew.Visible Then showPDDialog vbModal, FormPrintNew
End If
Case "Exit program"
Unload FormMain
'If the user does not cancel the exit, we must forcibly exit this sub (otherwise the program will not exit)
If g_ProgramShuttingDown Then Exit Sub
Case "Select scanner or camera"
Twain32SelectScanner
Case "Scan image"
Twain32Scan
Case "Screen capture"
If showDialog Then
showPDDialog vbModal, FormScreenCapture
Else
CaptureScreen cParams.GetBool(1), cParams.GetBool(2), cParams.GetLong(3), cParams.GetBool(4), cParams.GetString(5)
End If
Case "Internet import"
If showDialog Then
showPDDialog vbModal, FormInternetImport
End If
'EDIT MENU FUNCTIONS
' This includes things like copying or pasting an image. These actions are never recorded.
Case "Undo"
If FormMain.MnuEdit(0).Enabled Then
pdImages(g_CurrentImage).undoManager.restoreUndoData
'Also, redraw the current child form icon and the image tab-bar
createCustomFormIcon pdImages(g_CurrentImage)
toolbar_ImageTabs.notifyUpdatedImage g_CurrentImage
End If
Case "Redo"
If FormMain.MnuEdit(1).Enabled Then
pdImages(g_CurrentImage).undoManager.RestoreRedoData
'Also, redraw the current child form icon and the image tab-bar
createCustomFormIcon pdImages(g_CurrentImage)
toolbar_ImageTabs.notifyUpdatedImage g_CurrentImage
End If
Case "Copy"
ClipboardCopy False
Case "Copy merged"
ClipboardCopy True
Case "Paste as new layer"
ClipboardPaste True
Case "Paste as new image"
ClipboardPaste False
Case "Empty clipboard"
ClipboardEmpty
'TOOLS MENU FUNCTIONS
' This includes things like macro recording. These actions are never recorded.
Case "Start macro recording"
StartMacro
Case "Stop macro recording"
StopMacro
Case "Play macro"
PlayMacro
'IMAGE MENU FUNCTIONS
' This includes all actions that can only operate on a full image (never selections). These actions are recorded.
'Duplicate image
Case "Duplicate image"
'It may seem odd, but the Duplicate function can be found in the "Loading" module; I do this because
' we effectively LOAD a copy of the original image, so all loading operations (create a form, catalog
' metadata, initialize properties) have to be repeated.
DuplicateCurrentImage
'Alpha channel addition/removal
Case "Add alpha channel"
If showDialog Then
showPDDialog vbModal, FormTransparency_Basic
Else
FormTransparency_Basic.simpleConvert32bpp cParams.GetLong(1)
End If
Case "Color to alpha"
If showDialog Then
showPDDialog vbModal, FormTransparency_FromColor
Else
FormTransparency_FromColor.colorToAlpha cParams.GetLong(1), cParams.GetDouble(2), cParams.GetDouble(3)
End If
Case "Remove alpha channel"
If showDialog Then
showPDDialog vbModal, FormConvert24bpp
Else
ConvertImageColorDepth 24, cParams.GetLong(1)
End If
'Resize operations
Case "Resize"
If showDialog Then
showPDDialog vbModal, FormResize
Else
FormResize.ResizeImage cParams.GetDouble(1), cParams.GetDouble(2), cParams.GetLong(3), cParams.GetLong(4), cParams.GetLong(5), cParams.GetLong(6, MU_PIXELS), cParams.GetLong(7, 96)
End If
Case "Content-aware resize"
If showDialog Then
showPDDialog vbModal, FormResizeContentAware
Else
FormResizeContentAware.SmartResizeImage cParams.GetLong(1), cParams.GetLong(2), cParams.GetLong(3, MU_PIXELS), cParams.GetLong(4, 96)
End If
Case "Canvas size"
If showDialog Then
showPDDialog vbModal, FormCanvasSize
Else
FormCanvasSize.ResizeCanvas cParams.GetLong(1), cParams.GetLong(2), cParams.GetLong(3), cParams.GetLong(4), cParams.GetLong(5, MU_PIXELS), cParams.GetLong(6, 96)
End If
'Crop operations
Case "Crop"
MenuCropToSelection
Case "Autocrop"
AutocropImage
'Rotate operations
Case "Rotate 90° clockwise"
MenuRotate90Clockwise
Case "Rotate 180°"
MenuRotate180
Case "Rotate 90° counter-clockwise"
MenuRotate270Clockwise
Case "Arbitrary rotation"
If showDialog Then
showPDDialog vbModal, FormRotate
Else
FormRotate.RotateArbitrary cParams.GetLong(1), cParams.GetDouble(2)
End If
'Other coordinate transforms
Case "Flip vertical"
MenuFlip
Case "Flip horizontal"
MenuMirror
Case "Isometric conversion"
FilterIsometric
Case "Tile"
If showDialog Then
showPDDialog vbModal, FormTile
Else
FormTile.GenerateTile cParams.GetByte(1), cParams.GetLong(2), cParams.GetLong(3)
End If
'Other miscellaneous image-only items
Case "Count image colors"
MenuCountColors
Case "Reduce colors"
If showDialog Then
showPDDialog vbModal, FormReduceColors
Else
FormReduceColors.ReduceImageColors_Auto cParams.GetLong(2)
End If
'LAYER FUNCTIONS
' Any action triggered from the Layer menu, or the Layer toolbox - creating layers, moving them, etc
'Add an image file to the current image (as a new layer)
Case "New Layer from File"
Layer_Handler.loadImageAsNewLayer showDialog, processParameters
'Duplicate a given layer
Case "Duplicate Layer"
Layer_Handler.duplicateLayerByIndex cParams.GetLong(1)
'Delete a layer
Case "Delete layer"
Layer_Handler.deleteLayer cParams.GetLong(1)
'Merge a layer up or down
Case "Merge layer down"
Layer_Handler.mergeLayerAdjacent cParams.GetLong(1), True
Case "Merge layer up"
Layer_Handler.mergeLayerAdjacent cParams.GetLong(1), False
'Raise a layer up or down
Case "Raise layer"
Layer_Handler.moveLayerAdjacent cParams.GetLong(1), True
Case "Lower layer"
Layer_Handler.moveLayerAdjacent cParams.GetLong(1), False
'Flatten image
Case "Flatten image"
Layer_Handler.flattenImage
'Merge visible layers
Case "Merge visible layers"
Layer_Handler.mergeVisibleLayers
'SELECTION FUNCTIONS
' Any action that operates on selections - creating them, moving them, erasing them, etc
'Create/remove selections
Case "Create selection"
CreateNewSelection cParams.getParamString
Case "Remove selection"
RemoveCurrentSelection cParams.getParamString
'Backup selection settings during a recorded macro (required to avoid "lazy" tracking method used on selection changes)
Case "Finalize selection for macro"
backupSelectionSettingsForMacro cParams.getParamString
'Modify the existing selection in some way
Case "Invert selection"
invertCurrentSelection
Case "Grow selection"
If showDialog Then
growCurrentSelection True
Else
growCurrentSelection False, cParams.GetDouble(1)
End If
Case "Shrink selection"
If showDialog Then
shrinkCurrentSelection True
Else
shrinkCurrentSelection False, cParams.GetDouble(1)
End If
Case "Feather selection"
If showDialog Then
featherCurrentSelection True
Else
featherCurrentSelection False, cParams.GetDouble(1)
End If
Case "Sharpen selection"
If showDialog Then
sharpenCurrentSelection True
Else
sharpenCurrentSelection False, cParams.GetDouble(1)
End If
Case "Border selection"
If showDialog Then
borderCurrentSelection True
Else
borderCurrentSelection False, cParams.GetDouble(1)
End If
'Load/save selection from/to file
Case "Load selection"
If showDialog Then
LoadSelectionFromFile True
Else
LoadSelectionFromFile False, cParams.getParamString
End If
Case "Save selection"
SaveSelectionToFile
'Export selected area as image (defaults to PNG, but user can select the actual format)
Case "Export selected area as image"
ExportSelectedAreaAsImage
'Export selection mask as image (defaults to PNG, but user can select the actual format)
Case "Export selection mask as image"
ExportSelectionMaskAsImage
' This is a dummy entry; it only exists so that Undo/Redo data is correctly generated when a selection is moved
Case "Move selection"
CreateNewSelection cParams.getParamString
' This is a dummy entry; it only exists so that Undo/Redo data is correctly generated when a selection is moved
Case "Resize selection"
CreateNewSelection cParams.getParamString
Case "Select all"
SelectWholeImage
'ADJUSTMENT FUNCTIONS
' Any action that is used to fix or correct problems with an image, including basic color space transformations (e.g. grayscale/sepia)
'Luminance adjustment functions
Case "Brightness and contrast"
If showDialog Then
showPDDialog vbModal, FormBrightnessContrast
Else
FormBrightnessContrast.BrightnessContrast cParams.GetLong(1), cParams.GetDouble(2), cParams.GetBool(3)
End If
Case "Curves"
If showDialog Then
showPDDialog vbModal, FormCurves
Else
FormCurves.ApplyCurveToImage cParams.getParamString
End If
Case "Exposure"
If showDialog Then
showPDDialog vbModal, FormExposure
Else
FormExposure.Exposure cParams.GetDouble(1)
End If
Case "Gamma"
If showDialog Then
showPDDialog vbModal, FormGamma
Else
FormGamma.GammaCorrect cParams.GetDouble(1), cParams.GetDouble(2), cParams.GetDouble(3)
End If
Case "Levels"
If showDialog Then
showPDDialog vbModal, FormLevels
Else
FormLevels.MapImageLevels cParams.GetLong(1), cParams.GetDouble(2), cParams.GetLong(3), cParams.GetLong(4), cParams.GetLong(5)
End If
Case "Shadows and highlights"
If showDialog Then
showPDDialog vbModal, FormShadowHighlight
Else
FormShadowHighlight.ApplyShadowHighlight cParams.GetDouble(1), cParams.GetDouble(2), cParams.GetLong(3)
End If
Case "White balance"
If showDialog Then
showPDDialog vbModal, FormWhiteBalance
Else
FormWhiteBalance.AutoWhiteBalance cParams.GetDouble(1)
End If
'Color adjustments
Case "Color balance"
If showDialog Then
showPDDialog vbModal, FormColorBalance
Else
FormColorBalance.ApplyColorBalance cParams.GetLong(1), cParams.GetLong(2), cParams.GetLong(3), cParams.GetBool(4)
End If
Case "Hue and saturation"
If showDialog Then
showPDDialog vbModal, FormHSL
Else
FormHSL.AdjustImageHSL cParams.GetDouble(1), cParams.GetDouble(2), cParams.GetDouble(3)
End If
Case "Photo filter"
If showDialog Then
showPDDialog vbModal, FormPhotoFilters
Else
FormPhotoFilters.ApplyPhotoFilter cParams.GetLong(1), cParams.GetDouble(2), cParams.GetBool(3)
End If
Case "Replace color"
If showDialog Then
showPDDialog vbModal, FormReplaceColor
Else
FormReplaceColor.ReplaceSelectedColor cParams.GetLong(1), cParams.GetLong(2), cParams.GetDouble(3), cParams.GetDouble(4)
End If
Case "Temperature"
If showDialog Then
showPDDialog vbModal, FormColorTemp
Else
FormColorTemp.ApplyTemperatureToImage cParams.GetLong(1), cParams.GetBool(2), cParams.GetDouble(3)
End If
Case "Vibrance"
If showDialog Then
showPDDialog vbModal, FormVibrance
Else
FormVibrance.Vibrance cParams.GetDouble(1)
End If
'Miscellaneous adjustments
Case "Colorize"
If showDialog Then
showPDDialog vbModal, FormColorize
Else
FormColorize.ColorizeImage cParams.GetDouble(1), cParams.GetBool(2)
End If
'Grayscale conversions
Case "Black and white"
If showDialog Then
showPDDialog vbModal, FormGrayscale
Else
FormGrayscale.masterGrayscaleFunction cParams.GetLong(1), cParams.GetString(2), cParams.GetLong(3, 256), cParams.GetLong(4, 0)
End If
'Invert operations
Case "Invert RGB"
MenuInvert
Case "Compound invert"
MenuCompoundInvert cParams.GetLong(1)
Case "Film negative"
MenuNegative
Case "Invert hue"
MenuInvertHue
'Monochrome conversion
' (Note: all monochrome conversion operations are condensed into a single function. (Past versions spread them across multiple functions.))
Case "Color to monochrome"
If showDialog Then
showPDDialog vbModal, FormMonochrome
Else
FormMonochrome.masterBlackWhiteConversion cParams.GetLong(1), cParams.GetLong(2), cParams.GetLong(3), cParams.GetLong(4)
End If
Case "Monochrome to grayscale"
If showDialog Then
showPDDialog vbModal, FormMonoToColor
Else
FormMonoToColor.ConvertMonoToColor cParams.GetLong(1)
End If
Case "Sepia"
MenuSepia
'Channel operations
Case "Channel mixer"
If showDialog Then
showPDDialog vbModal, FormChannelMixer
Else
FormChannelMixer.ApplyChannelMixer cParams.getParamString
End If
Case "Rechannel"
If showDialog Then
showPDDialog vbModal, FormRechannel
Else
FormRechannel.RechannelImage cParams.GetByte(1)
End If
Case "Shift colors (left)"
MenuCShift 1
Case "Shift colors (right)"
MenuCShift 0
Case "Maximum channel"
FilterMaxMinChannel True
Case "Minimum channel"
FilterMaxMinChannel False
'Histogram functions
Case "Display histogram"
showPDDialog vbModal, FormHistogram
Case "Stretch histogram"
FormHistogram.StretchHistogram
Case "Equalize"
If showDialog Then
showPDDialog vbModal, FormEqualize
Else
FormEqualize.EqualizeHistogram cParams.GetBool(1), cParams.GetBool(2), cParams.GetBool(3), cParams.GetBool(4)
End If
'EFFECT FUNCTIONS
'Sometimes fun, sometimes practical, no real unifying factor to these.
'Artistic
Case "Comic book"
MenuComicBook
Case "Figured glass"
If showDialog Then
showPDDialog vbModal, FormFiguredGlass
Else
FormFiguredGlass.FiguredGlassFX cParams.GetDouble(1), cParams.GetDouble(2), cParams.GetLong(3), cParams.GetBool(4)
End If
Case "Film noir"
MenuFilmNoir
Case "Kaleidoscope"
If showDialog Then
showPDDialog vbModal, FormKaleidoscope
Else
FormKaleidoscope.KaleidoscopeImage cParams.GetDouble(1), cParams.GetDouble(2), cParams.GetDouble(3), cParams.GetDouble(4), cParams.GetBool(5), cParams.GetDouble(6), cParams.GetDouble(7)
End If
Case "Modern art"
If showDialog Then
showPDDialog vbModal, FormModernArt
Else
FormModernArt.ApplyModernArt cParams.GetLong(1)
End If
Case "Oil painting"
If showDialog Then
showPDDialog vbModal, FormOilPainting
Else
FormOilPainting.ApplyOilPaintingEffect cParams.GetLong(1), cParams.GetDouble(2)
End If
Case "Posterize"
If showDialog Then
showPDDialog vbModal, FormPosterize
Else
FormPosterize.ReduceImageColors_BitRGB cParams.GetByte(1), cParams.GetByte(2), cParams.GetByte(3), cParams.GetBool(4)
End If
Case "Posterize (dithered)"
FormPosterize.ReduceImageColors_BitRGB_ErrorDif cParams.GetByte(1), cParams.GetByte(2), cParams.GetByte(3), cParams.GetBool(4)
Case "Pencil drawing"
FilterPencil
Case "Relief"
FilterRelief
'Blur
Case "Box blur"
If showDialog Then
showPDDialog vbModal, FormBoxBlur
Else
FormBoxBlur.BoxBlurFilter cParams.GetLong(1), cParams.GetLong(2)
End If
Case "Chroma blur"
If showDialog Then
showPDDialog vbModal, FormChromaBlur
Else
FormChromaBlur.ChromaBlurFilter cParams.GetDouble(1), cParams.GetLong(2)
End If
Case "Gaussian blur"
If showDialog Then
showPDDialog vbModal, FormGaussianBlur
Else
FormGaussianBlur.GaussianBlurFilter cParams.GetDouble(1), cParams.GetLong(2)
End If
Case "Grid blur"
FilterGridBlur
Case "Motion blur"
If showDialog Then
showPDDialog vbModal, FormMotionBlur
Else
FormMotionBlur.MotionBlurFilter cParams.GetDouble(1), cParams.GetLong(2), cParams.GetBool(3), cParams.GetBool(4)
End If
Case "Pixelate"
If showDialog Then
showPDDialog vbModal, FormPixelate
Else
FormPixelate.PixelateFilter cParams.GetLong(1), cParams.GetLong(2)
End If
Case "Radial blur"
If showDialog Then
showPDDialog vbModal, FormRadialBlur
Else
FormRadialBlur.RadialBlurFilter cParams.GetDouble(1), cParams.GetBool(2), cParams.GetBool(3)
End If
Case "Smart blur"
If showDialog Then
showPDDialog vbModal, FormSmartBlur
Else
FormSmartBlur.SmartBlurFilter cParams.GetDouble(1), cParams.GetByte(2), cParams.GetBool(3)
End If
Case "Zoom blur"
If showDialog Then
showPDDialog vbModal, FormZoomBlur
Else
FormZoomBlur.ZoomBlurWrapper cParams.GetBool(1), cParams.GetLong(2)
End If
'Distort filters
Case "Apply lens distortion"
If showDialog Then
showPDDialog vbModal, FormLens
Else
FormLens.ApplyLensDistortion cParams.GetDouble(1), cParams.GetDouble(2), cParams.GetBool(3), cParams.GetDouble(4), cParams.GetDouble(5)
End If
Case "Correct lens distortion"
If showDialog Then
showPDDialog vbModal, FormLensCorrect
Else
FormLensCorrect.ApplyLensCorrection cParams.GetDouble(1), cParams.GetDouble(2), cParams.GetDouble(3), cParams.GetLong(4), cParams.GetBool(5)
End If
Case "Miscellaneous distort"
If showDialog Then
showPDDialog vbModal, FormMiscDistorts
Else
FormMiscDistorts.ApplyMiscDistort cParams.GetString(1), cParams.GetLong(2), cParams.GetLong(3), cParams.GetBool(4)
End If
Case "Pan and zoom"
If showDialog Then
showPDDialog vbModal, FormPanAndZoom
Else
FormPanAndZoom.PanAndZoomFilter cParams.GetDouble(1), cParams.GetDouble(2), cParams.GetDouble(3), cParams.GetLong(4), cParams.GetBool(5)
End If
Case "Perspective"
If showDialog Then
showPDDialog vbModal, FormPerspective
Else
FormPerspective.PerspectiveImage cParams.getParamString
End If
Case "Pinch and whirl"
If showDialog Then
showPDDialog vbModal, FormPinch
Else
FormPinch.PinchImage cParams.GetDouble(1), cParams.GetDouble(2), cParams.GetDouble(3), cParams.GetLong(4), cParams.GetBool(5), cParams.GetDouble(6), cParams.GetDouble(7)
End If
Case "Poke"
If showDialog Then
showPDDialog vbModal, FormPoke
Else
FormPoke.ApplyPokeDistort cParams.GetDouble(1), cParams.GetLong(2), cParams.GetBool(3), cParams.GetDouble(4), cParams.GetDouble(5)
End If
Case "Polar conversion"
If showDialog Then
showPDDialog vbModal, FormPolar
Else
FormPolar.ConvertToPolar cParams.GetLong(1), cParams.GetBool(2), cParams.GetDouble(3), cParams.GetLong(4), cParams.GetBool(5)
End If
Case "Ripple"
If showDialog Then
showPDDialog vbModal, FormRipple
Else
FormRipple.RippleImage cParams.GetDouble(1), cParams.GetDouble(2), cParams.GetDouble(3), cParams.GetDouble(4), cParams.GetLong(5), cParams.GetBool(6), cParams.GetDouble(7), cParams.GetDouble(8)
End If
Case "Rotate"
If showDialog Then
showPDDialog vbModal, FormRotateDistort
Else
FormRotateDistort.RotateFilter cParams.GetDouble(1), cParams.GetLong(2), cParams.GetBool(3), cParams.GetDouble(4), cParams.GetDouble(5)
End If
Case "Shear"
If showDialog Then
showPDDialog vbModal, FormShear
Else
FormShear.ShearImage cParams.GetDouble(1), cParams.GetDouble(2), cParams.GetLong(3), cParams.GetBool(4)
End If
Case "Spherize"
If showDialog Then
showPDDialog vbModal, FormSpherize
Else
FormSpherize.SpherizeImage cParams.GetDouble(1), cParams.GetDouble(2), cParams.GetDouble(3), cParams.GetBool(4), cParams.GetLong(5), cParams.GetBool(6)
End If
Case "Squish"
If showDialog Then
showPDDialog vbModal, FormSquish
Else
FormSquish.SquishImage cParams.GetDouble(1), cParams.GetDouble(2), cParams.GetLong(3), cParams.GetBool(4)
End If
Case "Swirl"
If showDialog Then
showPDDialog vbModal, FormSwirl
Else
FormSwirl.SwirlImage cParams.GetDouble(1), cParams.GetDouble(2), cParams.GetLong(3), cParams.GetBool(4)
End If
Case "Waves"
If showDialog Then
showPDDialog vbModal, FormWaves
Else
FormWaves.WaveImage cParams.GetDouble(1), cParams.GetDouble(2), cParams.GetDouble(3), cParams.GetDouble(4), cParams.GetLong(5), cParams.GetBool(6)
End If
'Edge filters
Case "Emboss or engrave"
showPDDialog vbModal, FormEmbossEngrave
Case "Emboss"
FormEmbossEngrave.FilterEmbossColor cParams.GetLong(1)
Case "Engrave"
FormEmbossEngrave.FilterEngraveColor cParams.GetLong(1)
Case "Edge enhance"
FilterEdgeEnhance
Case "Find edges"
showPDDialog vbModal, FormFindEdges
Case "Artistic contour"
FormFindEdges.FilterSmoothContour cParams.GetBool(1)
Case "Find edges (Prewitt horizontal)"
FormFindEdges.FilterPrewittHorizontal cParams.GetBool(1)
Case "Find edges (Prewitt vertical)"
FormFindEdges.FilterPrewittVertical cParams.GetBool(1)
Case "Find edges (Sobel horizontal)"