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
This commit is contained in:
Yves Rizoud
2010-07-14 19:33:53 +00:00
parent e6ced5f6a0
commit d5ecba7b6c
5 changed files with 62 additions and 32 deletions

View File

@@ -1641,10 +1641,10 @@ void Button_Palette(void)
= Requester_window("Enter the max. number of colors",
reduce_colors_number);
if (reduce_colors_number < 2 || reduce_colors_number >= 256)
reduce_colors_number = -1;
reduce_colors_number = 256;
break;
}
if (reduce_colors_number > 0)
if (reduce_colors_number != 256)
{
if (!image_is_backed_up)
{
@@ -2089,6 +2089,9 @@ void Button_Palette(void)
byte remap_table[256];
byte inverted_table[256];
byte begin, end;
long lightness;
long old_lightness;
if(block_start==block_end)
{
@@ -2112,7 +2115,7 @@ void Button_Palette(void)
}
if(Window_attribute1==LEFT_SIDE)
// Laft click on button: Sort by Hue (H) and Lightness (L)
// Left click on button: Sort by Hue (H) and Lightness (L)
while(swap==1)
{
swap=0;
@@ -2143,19 +2146,17 @@ void Button_Palette(void)
}
}
else // Right click > Sort only on L
else // Right click > Sort only on perceived lightness
while(swap==1)
{
swap=0;
l=255;
for(temp_color=begin;temp_color<=end;temp_color++)
lightness=Perceptual_lightness(working_palette+begin);
for(temp_color=begin+1;temp_color<=end;temp_color++)
{
ol=l;
RGB_to_HSL(working_palette[temp_color].R,
working_palette[temp_color].G,
working_palette[temp_color].B,&h,&s,&l);
old_lightness=lightness;
lightness=Perceptual_lightness(working_palette+temp_color);
if(l>ol)
if(lightness>old_lightness)
{
// Swap color with the previous one
SWAP_BYTES(working_palette[temp_color].R, working_palette[temp_color-1].R)