Page 1 of 3
Color Quantizing Image Editor
Posted: Mon May 26, 2014 2:16 am
by BasicallyPure
This tool is an image editor with special emphasis on various methods of color quantization.
Some of the procedures used in this program are borrowed from this forum.
I would like to give thanks to luis and wilbert for the NeuQuant module,
netmaestro for the ADAPTIVE_PALETTE procedure.
Wilbert for the Count colors, Gaussian blur, and the Sierra Lite dither procedure.
If I am not mistaken the remainder of the code is mine.
Tested on Windows 7 and Linux Mint
version 2.0 | 01/13/2016
Download for Windows
CQ_ImageEditor_2.0_x86.zip
CQ_ImageEditor_2.0_x64.zip
Download for Linux
CQ_ImageEditor_2.0_x64.tar.gz
Download for Mac
CQ_ImageEditor_2.0_x64.zip
older versions
Download CQ_ImageEditor_V1.37
Download CQ_ImageEditor_V1.33
Download CQ_ImageEditor_V1.1
Download CQ_ImageEditor_V1.0
Re: Color Quantizing Image Editor
Posted: Mon May 26, 2014 9:39 am
by davido
@
BasicallyPure,
Very nice! Thank you for sharing.
Also looks nice on my MacBook Pro. Have
not found any problems so far.
Re: Color Quantizing Image Editor
Posted: Mon May 26, 2014 10:08 am
by davido
@BasicallyPure,
On the Mac there are a few very minor cosmetic issues with the floating windows, in that some of the text on buttons is truncated.
Even so there is no ambiguity due to aforementioned truncation.
Works really well on the Mac.
Would you consider adding a resize option?
Re: Color Quantizing Image Editor
Posted: Mon May 26, 2014 11:58 am
by luis
Nice tool BP !
1) If you start the program and don't load an image but just paste one, the histogram option is not selectable.
2) if the canvas is smaller than the image pasted, maybe you should enlarge the canvas or at least let move the pasted image on the surface of the canvas to let the user decide where to drop it and consequently crop it. Right now it's not clear what's happening, and since moving the mouse has no effect it's not clear you have to right click it to exit paste mode.
I was a little confused initially until I pasted an image smaller than the canvas and I saw what was supposed to happen.
Just what I noticed after testing it for 10 minutes, so maybe there is more
A couple of things I'm missing:
the ability to have a large image to "fit" to the window size (not vital, but that's the norm and it can be handy to have a full view)
a preview (real time best or with a click in the dialog window) while you are changing brightness and contrast, else is just a cycle of trial and error to get the value right, but you can just do these things in an another program after you played with quantization with yours.
BTW: thank you for thanking me even if your work it's in no way based on my original code now probably superseded by the ASM port made by wilbert.
Bye!
Re: Color Quantizing Image Editor
Posted: Tue May 27, 2014 2:07 am
by BasicallyPure
davido wrote:On the Mac there are a few very minor cosmetic issues with the floating windows, in that some of the text on buttons is truncated.
Should be fixed in the next version.
davido wrote:Would you consider adding a resize option?
Yes, it is a possibility in a future version.
luis wrote:1) If you start the program and don't load an image but just paste one, the histogram option is not selectable.
Fixed for the next version. There is no longer any need to ever have histogram option disabled.
luis wrote:2) if the canvas is smaller than the image pasted, ...
A workaround can be to first use the 'New Image' option from the popup menu and create a blank image sized large enough to contain the pasted image.
I'm going to change the cursor to the 'hand' variation while paste is in progress to give some indication to the user.
luis wrote:the ability to have a large image to "fit" to the window size (not vital, but that's the norm and it can be handy to have a full view)
I am considering adding various zoom options including zoom to fit.
luis wrote:a preview (real time best or with a click in the dialog window) while you are changing brightness and contrast, ...
The TrackBarGadget really needs a 'mouse up' event to make this work as I would like. Updating the image as the track bar moves along is too much
computation time for larger images, that is why I chose the 'Apply' button approach. I do have another idea I'm going to try for this so wait and see.
If not for your original code luis, I doubt if wilbert would have ever written the ASM NeuQuant module.
BP
Re: Color Quantizing Image Editor
Posted: Tue May 27, 2014 2:16 am
by BasicallyPure
Davido,
On the Mac, do the keyboard shortcuts work; (ctrl + C) copy, (ctrl + V) paste, (ctrl + Z) undo, and (ctrl + Y) redo.
I ask because I notice they do not work with Linux. I think I may have uncovered a bug with the Linux version of PureBasic.
I should say they do work with Linux if the caps lock is activated but then the arrow keys no longer function when using a
floating selection.
BP
Re: Color Quantizing Image Editor
Posted: Tue May 27, 2014 8:12 am
by davido
BasicallyPure wrote:On the Mac, do the keyboard shortcuts work; (ctrl + C) copy, (ctrl + V) paste, (ctrl + Z) undo, and (ctrl + Y) redo.
Unfortunately these keys don't work on the Mac.
On the Mac the keys 'Command-c etc. are generally used by programs.
I think the way you deal with rotating text by 90º using the arrow keys is excellent. These keys work on the Mac.
Re: Color Quantizing Image Editor
Posted: Tue May 27, 2014 8:19 am
by BasicallyPure
davido wrote:Unfortunately these keys don't work on the Mac.
On the Mac the keys 'Command-c etc. are generally used by programs.
I think the way you deal with rotating text by 90º using the arrow keys is excellent. These keys work on the Mac.
OK davido, thanks for the information.
Re: Color Quantizing Image Editor
Posted: Tue May 27, 2014 10:03 pm
by said
Very nice

thanks for sharing both the tool and the source
And by the way, i love your signature this is so true and deep

Re: Color Quantizing Image Editor
Posted: Tue May 27, 2014 11:04 pm
by J. Baker
If you're going to make shortcut keys on Mac, don't use spaces between the "+" sign. For example...
Code: Select all
MenuItem( 0, "Copy" + Chr(9) + "Ctrl + C") ;Windows
...would be...
Code: Select all
MenuItem( 0, "Copy" + Chr(9) + "Cmd+C") ;OS X
Cool app by the way!

Re: Color Quantizing Image Editor
Posted: Tue May 27, 2014 11:47 pm
by BasicallyPure
To any Mac user, Please try this:
Replace the CANVAS_EVENT_HANDLER() procedure with this one.
Then try shortcuts for copy, paste, undo, and redo.
Code: Select all
Procedure CANVAS_EVENT_HANDLER()
CompilerIf #PB_Compiler_OS = #PB_OS_MacOS
Static keyModifier = #PB_Canvas_Command ; for MAC
CompilerElse
Static keyModifier = #PB_Canvas_Control
CompilerEndIf
Select EventType()
Case #PB_EventType_LeftButtonDown
If GetGadgetAttribute(#Canvas,#PB_Canvas_Modifiers) = keyModifier
ControlKey_Down = #True
EndIf
PostEvent(#CanvasMouseDown)
Case #PB_EventType_LeftButtonUp : PostEvent(#CanvasMouseUP)
Case #PB_EventType_RightClick : PostEvent(#CanvasRightClick)
Case #PB_EventType_KeyUp
If GetGadgetAttribute(#Canvas,#PB_Canvas_Modifiers) = keyModifier
Select GetGadgetAttribute(#Canvas,#PB_Canvas_Key)
Case #PB_Shortcut_C : PostEvent(#CanvasCopy)
Case #PB_Shortcut_V : PostEvent(#CanvasPaste)
Case #PB_Shortcut_Z : PostEvent(#CanvasUndo)
Case #PB_Shortcut_Y : PostEvent(#CanvasRedo)
EndSelect
EndIf
EndSelect
EndProcedure
Re: Color Quantizing Image Editor
Posted: Wed May 28, 2014 7:19 am
by davido
Hi BP,
Tried you procedure but unfortunately it didn't work - on the Mac.
It looks as if the MacOS doesn't recognise the key modifiers.
It looks as if there might be a bug here. Perhaps another Mac user could confirm or otherwise.
As a work-around I simply removed the If GetGadgetAttribute(#Canvas,#PB_Canvas_Modifiers) = keyModifier and used the keys cvzy.
It didn't interfere with entering text.
Re: Color Quantizing Image Editor
Posted: Fri Jun 20, 2014 4:30 am
by BasicallyPure
Version 1.1 is now available.
See first post for download link.
1. Added resize option for image and canvas.
2. Fixed cosmetic issues.
3. Added option to paste as new image.
4. Histogram is now always available.
5. Keyboard shortcuts should now work on Mac.
6. Added help, press F1 to activate.
7. Rearranged menus and added more shortcuts.
Please report any problems.
thanks,
BP
Re: Color Quantizing Image Editor
Posted: Mon Oct 06, 2014 9:12 pm
by BasicallyPure
Version 1.33 is now available.
See first post for download link.
Many code changes in this version.
Some notable changes are:
1. Text can now have transparent background.
2. Black and White and BW dither have been combined as 'Two Color' option.
..... Threshold adjustment added.
..... Any two colors can be selected, not just black and white.
..... 4x4 dither and Sierra Lite dither added as an option
3. Brightness and contrast adjustments now automatically update preview.
4. Updated help document.
5. Automatic window resize when using undo/redo if needed.
6. New GUI color theme.
If anyone knows of a faster way to apply a defined palette to an image please help.
The method I am now using, procedure 'ASSEMBLE_TO_PALETTE()' is a very brute force method and is slow for larger palettes.
It would need to be cross platform.
If anyone has any image editing effects they would like to share I would consider adding them to the editor.
BP.
Re: Color Quantizing Image Editor
Posted: Tue Oct 07, 2014 6:05 am
by wilbert
BasicallyPure wrote:If anyone knows of a faster way to apply a defined palette to an image please help.
The method I am now using, procedure 'ASSEMBLE_TO_PALETTE()' is a very brute force method and is slow for larger palettes.
It would need to be cross platform.
I think the easiest way would be to extend the NeuQuant module with a procedure that can set a custom palette.
Once set, you could use the InxBuild and InxSearch procedures from the NeuQuant module after that.