Merge trunk to the cpcmode5 branch. This gets us a more recent grafx2 with the cpcmode5 drawing. Now to make this mode optional so users can still work in regular mode :)

git-svn-id: svn://pulkomandy.tk/GrafX2/branches/cpcmode5@1719 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
Adrien Destugues
2011-02-13 21:49:31 +00:00
parent 4e60f5ad74
commit eba26aaa96
65 changed files with 8669 additions and 3286 deletions

View File

@@ -2,6 +2,7 @@
*/
/* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2010 Alexander Filyanov
Copyright 2007 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
@@ -30,6 +31,8 @@
#include "op_c.h"
#include "errors.h"
int Convert_24b_bitmap_to_256_fast(T_Bitmap256 dest,T_Bitmap24B source,int width,int height,T_Components * palette);
/// Convert RGB to HSL.
/// Both input and output are in the 0..255 range to use in the palette screen
void RGB_to_HSL(int r,int g,int b,byte * hr,byte * sr,byte* lr)
@@ -165,6 +168,16 @@ void HSL_to_RGB(byte h,byte s,byte l, byte* r, byte* g, byte* b)
*b = bf * (255);
}
///
/// Returns a value that is high when color is near white,
/// and low when it's darker. Used for sorting.
long Perceptual_lightness(T_Components *color)
{
return 26*color->R*26*color->R +
55*color->G*55*color->G +
19*color->B*19*color->B;
}
// Conversion table handlers
// The conversion table is built after a run of the median cut algorithm and is
// used to find the best color index for a given (RGB) color. GIMP avoids
@@ -1342,6 +1355,10 @@ static const byte precision_24b[]=
// Give this one a 24b source, get back the 256c bitmap and its palette
int Convert_24b_bitmap_to_256(T_Bitmap256 dest,T_Bitmap24B source,int width,int height,T_Components * palette)
{
#if defined(__GP2X__) || defined(__gp2x__) || defined(__WIZ__) || defined(__CAANOO__)
return Convert_24b_bitmap_to_256_fast(dest, source, width, height, palette);
#else
T_Conversion_table * table; // table de conversion
int ip; // index de précision pour la conversion
@@ -1363,7 +1380,36 @@ int Convert_24b_bitmap_to_256(T_Bitmap256 dest,T_Bitmap24B source,int width,int
}
else
return 1;
#endif
}
//Really small, fast and ugly converter(just for handhelds)
#include "global.h"
#include "limits.h"
#include "engine.h"
#include "windows.h"
extern void Set_palette_fake_24b(T_Palette palette);
/// Really small, fast and dirty convertor(just for handhelds)
int Convert_24b_bitmap_to_256_fast(T_Bitmap256 dest,T_Bitmap24B source,int width,int height,T_Components * palette)
{
int size;
Set_palette_fake_24b(palette);
size = width*height;
while(size--)
{
//Set palette color index to destination bitmap
*dest = ((source->R >> 5) << 5) |
((source->G >> 5) << 2) |
((source->B >> 6));
source++;
dest++;
}
return 0;
}