It is currently Sun Nov 19, 2017 7:05 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 35 posts ]  Go to page 1, 2, 3  Next
Author Message
 Post subject: Color Quantizing Image Editor
PostPosted: Mon May 26, 2014 2:16 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Thu Mar 24, 2011 12:40 am
Posts: 518
Location: Iowa, USA
This tool is an image editor with special emphasis on various methods of color quantization.

Image

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

_________________
BasicallyPure
Until you know everything you know nothing, all you have is what you believe.


Last edited by BasicallyPure on Fri Jan 15, 2016 5:42 pm, edited 12 times in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Color Quantizing Image Editor
PostPosted: Mon May 26, 2014 9:39 am 
Offline
Addict
Addict

Joined: Fri Nov 09, 2012 11:04 pm
Posts: 1459
Location: Uttoxeter, UK
@BasicallyPure,

Very nice! Thank you for sharing. :D

Also looks nice on my MacBook Pro. Have not found any problems so far.

_________________
DE AA EB


Top
 Profile  
Reply with quote  
 Post subject: Re: Color Quantizing Image Editor
PostPosted: Mon May 26, 2014 10:08 am 
Offline
Addict
Addict

Joined: Fri Nov 09, 2012 11:04 pm
Posts: 1459
Location: Uttoxeter, UK
@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?

_________________
DE AA EB


Top
 Profile  
Reply with quote  
 Post subject: Re: Color Quantizing Image Editor
PostPosted: Mon May 26, 2014 11:58 am 
Offline
Addict
Addict
User avatar

Joined: Wed Aug 31, 2005 11:09 pm
Posts: 3625
Location: Italy
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 :mrgreen:

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. :wink:

Bye!

_________________
[ My little PureBasic review ]


Top
 Profile  
Reply with quote  
 Post subject: Re: Color Quantizing Image Editor
PostPosted: Tue May 27, 2014 2:07 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Thu Mar 24, 2011 12:40 am
Posts: 518
Location: Iowa, USA
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

_________________
BasicallyPure
Until you know everything you know nothing, all you have is what you believe.


Top
 Profile  
Reply with quote  
 Post subject: Re: Color Quantizing Image Editor
PostPosted: Tue May 27, 2014 2:16 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Thu Mar 24, 2011 12:40 am
Posts: 518
Location: Iowa, USA
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

_________________
BasicallyPure
Until you know everything you know nothing, all you have is what you believe.


Top
 Profile  
Reply with quote  
 Post subject: Re: Color Quantizing Image Editor
PostPosted: Tue May 27, 2014 8:12 am 
Offline
Addict
Addict

Joined: Fri Nov 09, 2012 11:04 pm
Posts: 1459
Location: Uttoxeter, UK
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.

_________________
DE AA EB


Top
 Profile  
Reply with quote  
 Post subject: Re: Color Quantizing Image Editor
PostPosted: Tue May 27, 2014 8:19 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Thu Mar 24, 2011 12:40 am
Posts: 518
Location: Iowa, USA
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.

_________________
BasicallyPure
Until you know everything you know nothing, all you have is what you believe.


Top
 Profile  
Reply with quote  
 Post subject: Re: Color Quantizing Image Editor
PostPosted: Tue May 27, 2014 10:03 pm 
Offline
Enthusiast
Enthusiast

Joined: Thu Apr 14, 2011 6:07 pm
Posts: 313
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 :idea:


Top
 Profile  
Reply with quote  
 Post subject: Re: Color Quantizing Image Editor
PostPosted: Tue May 27, 2014 11:04 pm 
Offline
Addict
Addict
User avatar

Joined: Sun Apr 27, 2003 8:12 am
Posts: 1948
Location: USA
If you're going to make shortcut keys on Mac, don't use spaces between the "+" sign. For example...

Code:
MenuItem( 0, "Copy" + Chr(9) + "Ctrl + C") ;Windows


...would be...

Code:
MenuItem( 0, "Copy" + Chr(9) + "Cmd+C") ;OS X


Cool app by the way! ;)

_________________
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef

Mac: 10.6.8 / 1.4GHz Core 2 Duo / 2GB DDR3 / Nvidia 320M
PC: XP SP3 / AMD 64 4000+ / 1GB DDR / ATI 9250


Even the vine knows it surroundings but the man with eyes does not.


Top
 Profile  
Reply with quote  
 Post subject: Re: Color Quantizing Image Editor
PostPosted: Tue May 27, 2014 11:47 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Thu Mar 24, 2011 12:40 am
Posts: 518
Location: Iowa, USA
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:
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


_________________
BasicallyPure
Until you know everything you know nothing, all you have is what you believe.


Top
 Profile  
Reply with quote  
 Post subject: Re: Color Quantizing Image Editor
PostPosted: Wed May 28, 2014 7:19 am 
Offline
Addict
Addict

Joined: Fri Nov 09, 2012 11:04 pm
Posts: 1459
Location: Uttoxeter, UK
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.

_________________
DE AA EB


Top
 Profile  
Reply with quote  
 Post subject: Re: Color Quantizing Image Editor
PostPosted: Fri Jun 20, 2014 4:30 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Thu Mar 24, 2011 12:40 am
Posts: 518
Location: Iowa, USA
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

_________________
BasicallyPure
Until you know everything you know nothing, all you have is what you believe.


Top
 Profile  
Reply with quote  
 Post subject: Re: Color Quantizing Image Editor
PostPosted: Mon Oct 06, 2014 9:12 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Thu Mar 24, 2011 12:40 am
Posts: 518
Location: Iowa, USA
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.

_________________
BasicallyPure
Until you know everything you know nothing, all you have is what you believe.


Top
 Profile  
Reply with quote  
 Post subject: Re: Color Quantizing Image Editor
PostPosted: Tue Oct 07, 2014 6:05 am 
Offline
PureBasic Expert
PureBasic Expert

Joined: Sun Aug 08, 2004 5:21 am
Posts: 3002
Location: Netherlands
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.

_________________
MacOS 10.13.1 High Sierra, PB 5.60 x64


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 35 posts ]  Go to page 1, 2, 3  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye