Recent

Author Topic: LazPaint (alpha-blending, antialiasing, filters)  (Read 526953 times)

circular

  • Hero Member
  • *****
  • Posts: 3648
    • Personal webpage
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #750 on: May 31, 2015, 01:57:24 pm »
Hi Chronos!

I don't know much about linux packages. Someone made it for me.

No I don't have daily build testing.

How can one set the DPI in the LCL? LazPaint relies on LCL stretching forms.
Conscience is the debugger of the mind

lainz

  • Hero Member
  • *****
  • Posts: 3931
  • Leandro Diaz
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #751 on: June 03, 2015, 06:48:52 am »
Hi, I've updated the setup so now it has new things, see screenshot:
- Quick Edit menu
- Quick Effects menu

It must be translated also, inside the .iss, I've translated this into Spanish (but not translated the QuickEffects items.. you can grab the existing translations from LazPaint and add them all here).

Notes:
By default I've added the new menu items to .png, .bmp and .jpg filetypes. But you can uncomment the code and add to the other file formats too. I've just tested all with .png only but they all share the same code in setup and registry.

Suggestions 1:
I was thinking about adding Quick Resample menu, but of course with the current command line tools I cant resample mantaining the aspect ratio.

I want this to mantain aspect ratio:
/ResampleWidth(Width)
/ResampleHeight(Height)

So we can add a menu:
- Quick Resample
-- 1080p /ResampleHeight(1080)
-- 720p /ResampleHeight(720)
-- etc..

Also that the /ResampleWidthOut and /ResampleHeightOut to automatically include the value in the filename so the output is always:

my_filename.png
my_filename_1080.png
my_filename_720.png

Because I think the user will want to keep the original file when resampling...

Suggestions 2:

Also to create a menu called Quick Convert...

I need something like /Convert("jpg")

So I can add a menu, for example for .png files

my_file.png -> Convert to... -> jpg
out -> my_file.jpg

Suggestions 3:

Save as jpg with compress level
/CompressJPG(90)
/CompressJPGOut(90) -> my_file_compresslevel90.jpg

The thing for all suggestions is:
With the command line used in explorer I can only send a parameter that is %1 to LazPaint that is the full path to filename. The other parameters can be passed but are static and stored in registry. So I cant pass the output filename I want. It must be determined by LazPaint.

This other thing comes to my mind:
Add another menu for png files that call optipng commandline tool. Just "/OptimizePNG(level)" *level can be 0 (fast) to 7 (slow).

Maybe you can hide the commandline window of optipng and optionally show a progress window (with a progress bar that just display "working...", this can be done with the latest changes of the bgraflashprogressbar..)

There is no license problem and that feature is something I and most web developers uses and of course this setup is only for windows. Also this just add some kb to setup that are like nothing.

Bugs:
* The save dialogs of LazPaint for PNG and JPG are not HighDPI (just tested these, don't know if others are).
* The print does not work when printer is power off. CreateDC Exception.. maybe you can put a try...except block and show a message 'printer not ready'..

Suggestion:
* The setup does not contain all the formats supported by LazPaint (missing: XPM, TGA, TIFF).

Download the updated setup file, is attached.
« Last Edit: June 03, 2015, 10:16:02 pm by 007 »

circular

  • Hero Member
  • *****
  • Posts: 3648
    • Personal webpage
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #752 on: June 03, 2015, 11:04:41 am »
Great stuff.  :)

Ok I see. Some commands can be added to make it easier with the command line.
Conscience is the debugger of the mind

lainz

  • Hero Member
  • *****
  • Posts: 3931
  • Leandro Diaz
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #753 on: June 03, 2015, 07:47:29 pm »
Yes, basically to have a nice right click menu for associated file types.

Attached the fix for Windows XP. In XP there is no submenu (you must create a COM .dll to add that feature, and is not so easy...). Submenu was added from Windows 7 and newer.

If you already edited the .iss file with new stuff you must add these lines for each type (if not just replace the .iss with the attached one):
Code: [Select]
; Windows XP compatibility
Root: HKLM; Subkey: "Software\Classes\LazPaint.AssocFile.bmp\Shell\CascadeMenu\Command"; ValueType: String; ValueData: """{app}\{#MyAppExeName}"" ""%1"""; Flags: uninsdeletekey
Root: HKLM; Subkey: "Software\Classes\LazPaint.AssocFile.bmp\Shell\CascadeMenu2\Command"; ValueType: String; ValueData: """{app}\{#MyAppExeName}"" ""%1"""; Flags: uninsdeletekey

Basically instead of throwing an error it will just open the file with LazPaint.
« Last Edit: June 03, 2015, 10:15:57 pm by 007 »

circular

  • Hero Member
  • *****
  • Posts: 3648
    • Personal webpage
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #754 on: June 03, 2015, 07:49:56 pm »
Hmm ok. Not so obvious those shell customizations!
Conscience is the debugger of the mind

lainz

  • Hero Member
  • *****
  • Posts: 3931
  • Leandro Diaz
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #755 on: June 03, 2015, 07:55:54 pm »
Hmm ok. Not so obvious those shell customizations!

Ok. You can read the docs here if you want: https://msdn.microsoft.com/en-us/library/windows/desktop/hh127467%28v=vs.85%29.aspx

Also, If you want an unique menu called
- LazPaint
-- Quick Effects
-- Quick Edit
-- Etc..

Is easy as adding a SubCommands entry in the method definition (dont believe to MSDN article, ExtendedSubCommandsKey does not work...), this is a demo that adds a right click menu to your desktop to open notepad, mspaint and other stuff (found it somewhere), save as .reg file and run it.

Code: [Select]
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\DesktopBackground\Shell\Cascading Menu]
"Icon"="C:\\Windows\\system32\\shell32.dll,-24"
"SubCommands"="A.Winver;A.Graphics.Tools.Menu;A.System.Tools.Menu;A.Text.Tools.Menu"
"Position"="Top"

; Command Store Entries

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\A.Defrag]
"Icon"="dfrgui.exe"
"MUIVerb"="Defragmenter"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\A.Defrag\Command]
@="dfrgui.exe"


[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\A.Disk.Cleanup]
"Icon"="cleanmgr.exe"
"MUIVerb"="Disk Cleanup"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\A.Disk.Cleanup\Command]
@="cleanmgr.exe"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\A.Disk.Tools.Menu]
"Icon"="imageres.dll,-3"
"MUIVerb"="Disk Tools"
"SubCommands"="A.Defrag;A.Disk.Cleanup"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\A.Graphics.Tools.Menu]
"Icon"="imageres.dll,-3"
"MUIVerb"="Graphics"
"SubCommands"="A.Paint;Windows.slideshow"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\A.Msinfo]
"Icon"="msinfo32.exe"
"MUIVerb"="Open MS Info"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\A.Msinfo\Command]
@="msinfo32.exe"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\A.Notepad]
"Icon"="notepad.exe"
"MUIVerb"="Open Notepad"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\A.Notepad\Command]
@="notepad.exe"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\A.Paint]
"Icon"="mspaint.exe"
"MUIVerb"="Open Paint"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\A.Paint\Command]
@="mspaint.exe"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\A.System.Tools.Menu]
"Icon"="imageres.dll,-3"
"MUIVerb"="System"
"SubCommands"="A.Msinfo;A.Disk.Tools.Menu"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\A.Text.Tools.Menu]
"SubCommands"="A.Notepad;A.Wordpad"
"MUIVerb"="Text"
"Icon"="imageres.dll,-3"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\A.Winver]
"Icon"="Winver.exe"
"MUIVerb"="Windows Version"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\A.Winver\Command]
@="winver.exe"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\A.Wordpad]
"MUIVerb"="Open Wordpad"
"Icon"="\"C:\\Program Files\\Windows NT\\Accessories\\wordpad.exe\""

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\A.Wordpad\Command]
@="wordpad.exe"

lainz

  • Hero Member
  • *****
  • Posts: 3931
  • Leandro Diaz
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #756 on: June 03, 2015, 10:15:27 pm »
Ok... I'm learning a lot :)
This is the last .iss you must include if you want this LazPaint setup.

This "final" attached .iss has the ability to:
- Run lazpaint.exe from ShellExecuteEx (For example, you can do Windows+R key to open the Run... window and just type lazpaint.exe or just lazpaint to run it, it does not need the full path), it is done without adding to PATH, is an special registry key for doing this. So you can run command line for lazpaint from the Run... window. No need to run a cmd window!

- Also with this you can create batch files in any place with ease if lazpaint is installed

Code: [Select]
start lazpaint /New(1024,768)
Converting any file to jpg:
Code: [Select]
start lazpaint %1 %~n1.jpgFor example, drag a .png file to the batch file and it will output a .jpg file with the same name in the same directory.

Also I've fixed a spanish translation issue.

Edit:
Seems that is possible to use this command
Code: [Select]
"C:\Program Files\LazPaint\lazpaint.exe" "%1" "%l.jpg"to convert from any to jpg with right click menu with no use of batch files. The main problem is that the output file contains double extension. like myfile.png is converted to myfile.png.jpg

So, the best will be have the command directly from LazPaint.
« Last Edit: June 03, 2015, 10:53:33 pm by 007 »

circular

  • Hero Member
  • *****
  • Posts: 3648
    • Personal webpage
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #757 on: June 04, 2015, 11:47:25 pm »
I understand. I wonder if that would make sense to register from LazPaint application, so that one could change the content of the menu.
Conscience is the debugger of the mind

lainz

  • Hero Member
  • *****
  • Posts: 3931
  • Leandro Diaz
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #758 on: June 05, 2015, 08:12:20 am »
I understand. I wonder if that would make sense to register from LazPaint application, so that one could change the content of the menu.

Ah OK, I see what you think.

The real way of doing this is with a COM .dll, there is something, somewhere, at embarcadero that deals with this, and is compatible with lazarus, so you can handle the menu from a pascal program... And you can manage the things that are shown from code.

But I dont have the link right now, and also I remember you need to be registered in order to download the file.

Try google "COM shell extension pascal"

Ok...

Here it is
https://github.com/RRUZ/delphi-dev-shell-tools

And this
http://cc.embarcadero.com/item/27554

____________

But, of course you can change registry with a pascal program too :) I already made something but does not include this. Check:

http://wiki.lazarus.freepascal.org/FileAssociation

Basically I tested this things with LazPaint setup first :) And also now I'm using it with some of my applications.

The main thing to take into consideration is the user privileges, in order to modify 'HKLM' you must run lazpaint as admin for example..

Or register only for the current user the settings: this is the behavior that is used, for example, by 7zip, VLC and other apps.

____________

Also I 'discovered' a way to register these commands for .png (for example) also if the .png is NOT associated with lazpaint. How it works? There is a subkey:

Software\Classes\SystemFileAssociations

There are stored a set of global menu items that has less visibility but are always displayed does not matter the program is associated with an extension.

Example:
.png always has set as desktop background, edit, print, preview and others (these are called verbs)... but these are displayed at last position where the 'vendor' verbs at top.

So with current setup I made:
.png associated with lazpaint will display "Quick edit" and "Quick effects" and then the other menus. But if I associate .png with Photo Viewer there will NOT be Quick edit and Quick effects.

This can be changed putting the verbs inside the key SystemFileAssociations\.png, so these menus will be always displayed.

For example, recently I've added:
SystemFileAssociations\.png\shell\optimize\command
"C:\optipng-0.7.5-win32\optipng.exe" "%1"

And is always displayed, at last position (I mean after lazpaint commands...) but always, not matter if associated lazpaint or wathever ;)

____________

Too much information to process, the only way to understand it is creating a separate user account (to dont break your current user registry) and start playing with the registry, or even better a virtual machine.
« Last Edit: June 05, 2015, 08:14:44 am by 007 »

circular

  • Hero Member
  • *****
  • Posts: 3648
    • Personal webpage
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #759 on: June 05, 2015, 08:56:17 am »
Well indeed I was thinking about changing the registry. I understand this thing about rights. I suppose if it is possible to register for current user, that's good enough.
Conscience is the debugger of the mind

jamhitz

  • Jr. Member
  • **
  • Posts: 83
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #760 on: June 05, 2015, 11:16:32 am »
I visited http://bgra-controls.sourceforge.net/ and was confronted with the Windows logo on the home page. Isn't LazPaint cross-platform?

DISCLAIMER: I have no problem with Windows, just asking?

lainz

  • Hero Member
  • *****
  • Posts: 3931
  • Leandro Diaz
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #761 on: June 06, 2015, 12:06:20 am »
Well indeed I was thinking about changing the registry. I understand this thing about rights. I suppose if it is possible to register for current user, that's good enough.

Yes, You can.

I visited http://bgra-controls.sourceforge.net/ and was confronted with the Windows logo on the home page. Isn't LazPaint cross-platform?

DISCLAIMER: I have no problem with Windows, just asking?

I will add lazarus logo.

lainz

  • Hero Member
  • *****
  • Posts: 3931
  • Leandro Diaz
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #762 on: June 06, 2015, 06:42:25 am »
Hi, with this you can remove all current registry code from the LazPaint setup and include in LazPaint application.

A good idea to use this is:
- Add -RegisterFileAssociation and -UnRegisterFileAssociation
- Run lazpaint.exe -RegisterFileAssociation [more parameters... (list of extensions to be registered, language selected)] when installing
- Run lazpaint.exe -UnRegisterFileAssociation when uninstalling

This way solves the problem of running as admin, because Inno Setup generated setup program will always run as admin!
This way solves the problem of translations, because you can add new strings to the .po files and use them when -RegisterFileAssociation is called. For example: LazPaint description and extension descriptions can be translated.

This is a working setup for registry. But you can customize it in your own way.

Any questions ask!

v2: Now with right click menu implemented.
- The only one thing left is that values are deleted only, never the keys when unregister is executed. Look at this.
« Last Edit: June 06, 2015, 12:18:15 pm by 007 »

circular

  • Hero Member
  • *****
  • Posts: 3648
    • Personal webpage
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #763 on: June 06, 2015, 12:21:45 pm »
Great stuff!

I suppose that in the following code:
Code: [Select]
  { Add 'App Paths' to run lazpaint quickly from ShellExecuteEx (batch files, run window [Windows + F] and OpenDocument() at lclintf) }
  Assoc.WriteString('SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\lazpaint.exe', '', AppPath + ' "%1"');
  Assoc.WriteString('SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\lazpaint.exe', '', AppPath);
The second Assoc.WriteString cancels the first one, doesn't it?
Conscience is the debugger of the mind

lainz

  • Hero Member
  • *****
  • Posts: 3931
  • Leandro Diaz
Re: LazPaint (alpha-blending, antialiasing, filters)
« Reply #764 on: June 06, 2015, 12:28:10 pm »
Great stuff!

I suppose that in the following code:
Code: [Select]
  { Add 'App Paths' to run lazpaint quickly from ShellExecuteEx (batch files, run window [Windows + F] and OpenDocument() at lclintf) }
  Assoc.WriteString('SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\lazpaint.exe', '', AppPath + ' "%1"');
  Assoc.WriteString('SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\lazpaint.exe', '', AppPath);
The second Assoc.WriteString cancels the first one, doesn't it?

Yes, just noticed it, the right code is:
Code: [Select]
  Assoc.WriteString('SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\lazpaint.exe', '', AppPath + ' "%1"');
  Assoc.WriteString('SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\lazpaint.exe', 'Path', AppPath);     


And also here the command is /Negative not /Grayscale:
Code: [Select]
    Assoc.WriteString('SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\Shell\LazPaint.negative\Command', '', AppPath + ' "%1" /Negative "%1"');

 

TinyPortal © 2005-2018