fixed crash when drawing a vertical gradiation or a single-point (nonsense) gradiation.
git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@315 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
parent
cc81845f7b
commit
72c42b92ce
25
graph.c
25
graph.c
@ -5209,33 +5209,40 @@ void Tracer_rectangle_degrade(short RAX,short RAY,short RBX,short RBY,short VAX,
|
||||
RAY = Pos_Y;
|
||||
}
|
||||
|
||||
Degrade_Intervalle_total = sqrt(pow(VBY - VAY,2)+pow(VBX - VAX,2));
|
||||
if(VBX == VAX)
|
||||
{
|
||||
// Le vecteur est vertical, donc on évite la partie en dessous qui foirerait avec une division par 0...
|
||||
if (VBY == VAY) return; // L'utilisateur fait n'importe quoi
|
||||
Degrade_Intervalle_total = abs(VBY - VAY);
|
||||
for(Pos_Y=RAY;Pos_Y<=RBY;Pos_Y++)
|
||||
for(Pos_X=RAX;Pos_X<=RBX;Pos_X++)
|
||||
Traiter_degrade(abs(VBY - Pos_Y),Pos_X,Pos_Y);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Degrade_Intervalle_total = sqrt(pow(VBY - VAY,2)+pow(VBX - VAX,2));
|
||||
short a = (VBY - VAY)/(VBX - VAX);
|
||||
short b = VAY - a*VAX;
|
||||
int Distance_X, Distance_Y;
|
||||
|
||||
DEBUG("inttotal",Degrade_Intervalle_total);
|
||||
|
||||
for (Pos_Y=RAY;Pos_Y<RBY;Pos_Y++)
|
||||
for (Pos_X = RAX;Pos_X<RBX;Pos_X++)
|
||||
for (Pos_Y=RAY;Pos_Y<=RBY;Pos_Y++)
|
||||
for (Pos_X = RAX;Pos_X<=RBX;Pos_X++)
|
||||
{
|
||||
// On calcule ou on en est dans le dégradé
|
||||
Distance_X = pow((int)(Pos_Y - VAY),2)+pow((int)(Pos_X - VAX),2);
|
||||
Distance_Y = pow((int)(-a * Pos_X + Pos_Y - b),2)/(a*a+1);
|
||||
|
||||
printf("%d\t%d\t%d\n",Pos_X,Distance_X,Distance_Y);
|
||||
|
||||
Traiter_degrade(sqrt(Distance_X - Distance_Y),Pos_X,Pos_Y);
|
||||
}
|
||||
|
||||
}
|
||||
Mettre_Ecran_A_Jour(RAX,RAY,RBX,RBY);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// -- Tracer un polygône plein --
|
||||
// -- Tracer un polygône plein --
|
||||
|
||||
typedef struct POLYGON_EDGE /* an active edge */
|
||||
{
|
||||
|
||||
19
op_c.c
19
op_c.c
@ -259,17 +259,6 @@ void TO_Set(Table_occurence * t,int r,int v,int b,int i)
|
||||
t->table[indice]=i;
|
||||
}
|
||||
|
||||
#ifdef OPTIMISATIONS_ASSEMBLEUR
|
||||
|
||||
void TO_Compter_occurences(Table_occurence * t,Bitmap24B image,int taille)
|
||||
{
|
||||
OPASM_Compter_occurences(t->table,image,taille,
|
||||
t->red_r,t->red_v,t->red_b,
|
||||
t->nbb_v,t->nbb_b);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void TO_Inc(Table_occurence * t,int r,int v,int b)
|
||||
{
|
||||
int indice;
|
||||
@ -290,8 +279,6 @@ void TO_Compter_occurences(Table_occurence * t,Bitmap24B image,int taille)
|
||||
TO_Inc(t,ptr->R,ptr->V,ptr->B);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
int TO_Compter_couleurs(Table_occurence * t)
|
||||
{
|
||||
int val; // Valeur de retour
|
||||
@ -1174,6 +1161,7 @@ void Convert_bitmap_24B_to_256_Floyd_Steinberg(Bitmap256 Dest,Bitmap24B Source,i
|
||||
D++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -1181,7 +1169,10 @@ void Convert_bitmap_24B_to_256_Floyd_Steinberg(Bitmap256 Dest,Bitmap24B Source,i
|
||||
|
||||
|
||||
static const byte precision_24b[]=
|
||||
{6,6,5,
|
||||
{
|
||||
8,8,8,
|
||||
6,6,6,
|
||||
6,6,5,
|
||||
5,6,5,
|
||||
5,5,5,
|
||||
5,5,4,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user