Makefile: Added missing png library to linker options (issue 141)
Fix the minimum screen size not enforced when resizing window (since r705) Fix the mouse cursor position when changing pixel size (since r705) In fileselector, the image preview now enforces "safe colors". (issue 116) git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@716 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
36
misc.c
36
misc.c
@@ -40,7 +40,7 @@
|
||||
word Count_used_colors(dword* usage)
|
||||
{
|
||||
int nb_pixels=0;
|
||||
Uint8* Pixel_Courant=Main_screen;
|
||||
Uint8* current_pixel=Main_screen;
|
||||
Uint8 color;
|
||||
word nb_colors=0;
|
||||
int i;
|
||||
@@ -53,12 +53,12 @@ word Count_used_colors(dword* usage)
|
||||
// On parcourt l'écran courant pour compter les utilisations des couleurs
|
||||
for(i=0;i<nb_pixels;i++)
|
||||
{
|
||||
color=*Pixel_Courant; //on lit la couleur dans l'écran
|
||||
color=*current_pixel; //on lit la couleur dans l'écran
|
||||
|
||||
usage[color]++; //Un point de plus pour cette couleur
|
||||
|
||||
// On passe au pixel suivant
|
||||
Pixel_Courant++;
|
||||
current_pixel++;
|
||||
}
|
||||
|
||||
//On va maintenant compter dans la table les couleurs utilisées:
|
||||
@@ -71,6 +71,36 @@ word Count_used_colors(dword* usage)
|
||||
return nb_colors;
|
||||
}
|
||||
|
||||
/// Same as ::Count_used_colors, but for a given rectangle.
|
||||
word Count_used_colors_area(dword* usage, word start_x, word start_y, word width, word height)
|
||||
{
|
||||
Uint8 color;
|
||||
word x,y;
|
||||
word nb_colors=0;
|
||||
int i;
|
||||
|
||||
// Init usage table
|
||||
for (i=0;i<256;i++) usage[i]=0;
|
||||
|
||||
// On parcourt l'écran courant pour compter les utilisations des couleurs
|
||||
for(y=0;y<height;y++)
|
||||
{
|
||||
for(x=0;x<width;x++)
|
||||
{
|
||||
color=*(Screen_pixels+((start_x+x)+(start_y+y)*Screen_width*Pixel_height)*Pixel_width); //on lit la couleur dans l'écran
|
||||
usage[color]++; //Un point de plus pour cette couleur
|
||||
}
|
||||
}
|
||||
//On va maintenant compter dans la table les couleurs utilisées:
|
||||
for(i=0;i<256;i++)
|
||||
{
|
||||
if (usage[i]!=0)
|
||||
nb_colors++;
|
||||
}
|
||||
return nb_colors;
|
||||
}
|
||||
|
||||
|
||||
void Set_palette(T_Palette palette)
|
||||
{
|
||||
register int i;
|
||||
|
||||
Reference in New Issue
Block a user