10 Commits

Author SHA1 Message Date
Thomas Bernard
92facef46d Convert comments to UTF-8
most were encoded in Latin1 / CP1252
but a few lines in op_c.c were using IBM437/850 !
2018-06-26 11:37:19 +02:00
Thomas Bernard
fb197cc0d9 op_c.c: handle memory allocation errors in CS_Set() 2017-12-25 16:08:29 +01:00
Thomas Bernard
d7179f7cba fix Optimize_palette() for precisions different than 8 8 8
do the right shifts instead of 16 / 8
2017-12-25 15:55:14 +01:00
Thomas Bernard
b9bdf68ee6 Quantization : sort clusters by diagonal and not volume
There is a #define which enables to return to the previous algorithm
2017-12-23 14:53:50 +01:00
Adrien Destugues
ee6ddf139b * Fix issue with the color reduction: the node index was off by one, leading to a write out of the allocated memory, and, of course, strange crashes because of it.
* Add some const in function parameters, just to make sure.
 * Cleanup the comments, because I got lost in my own code...

git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1881 416bcca6-2ee7-4201-b75f-2eb2f807beb1
2011-12-30 23:12:14 +00:00
Adrien Destugues
0236d5342a Rework the color reduction algorithm:
* Split clusters according to their volume (narrow covering) instead of occurence count. This ensures clusters representating a lot 
of colors are split; and a lot of pixels with near colors are grouped together, which is what we want for low-color work.
 * Rework memory management of clusters. Some of them were not malloc'ed but put on the stack, and then inserted in the list. Also 
avoid copying+deleting a cluster in CT_Get, return the original instead.
 * Use an union in the cluster struct to pack it a bit, since some data is used only in the color reduction phase, and some only in 
the palette lookup.

The result is maybe slower, but looks much, much better. Fixes issues 63 and 441.


git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1878 416bcca6-2ee7-4201-b75f-2eb2f807beb1
2011-11-28 22:31:06 +00:00
Adrien Destugues
4813314638 * Remove debug output
* Further optimization to the colortree, now allocated in one single chunk of 4090 bytes (2051 times better than original code!). 
Not doing all the malloc/frees should be slightly faster, and it also helps with cache locality (the whole tree can fit in the 
cache).
 * Remove the useless color "balancing" multipliers that did more harm than good.

We still need some improvements on the median cut, or maybe switch to a smarter algorithm; or add some cheats. See the JFIF quirks 
for an example.


git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1876 416bcca6-2ee7-4201-b75f-2eb2f807beb1
2011-11-23 21:26:43 +00:00
Adrien Destugues
d3a107bb7c Finished working on the new color lookup system.
There is room for optimization and maybe bugfixing.
The cluster table size is now:
511*15 = 7665bytes, this is 1094 times better than the color table.

Please test and report your results !


git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1874 416bcca6-2ee7-4201-b75f-2eb2f807beb1
2011-11-22 21:38:03 +00:00
Yves Rizoud
d5ecba7b6c Palette sort (on brightness) now uses a better formula, provided by DawnBringer. Text tool no longer crashes with some fonts. Added support for bitmap fonts from 'Bitmap Font Writer', such as those from http://www.zone38.net/font/bmpfont.html or http://www.matriaxweb.com/others.htm or http://www.genvid.com/moonstruck/downloads/fonts.html
git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1530 416bcca6-2ee7-4201-b75f-2eb2f807beb1
2010-07-14 19:33:53 +00:00
Yves Rizoud
3ca5322379 Reorganized source code and directory tree.
git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1375 416bcca6-2ee7-4201-b75f-2eb2f807beb1
2010-03-05 02:53:19 +00:00