2 pièce(s) jointe(s)
Rotation d'image avec tableau 1D
Bonjour,
Voilà un moment que je bloque sur une ligne de code, avec une erreur que je trouve assez... chelllooouuuu.
Je n'utilise que des images bitmap en 256 couleurs.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
int ix;
int iy;
int xpos;
int ypos;
float xOff;
float yOff;
float x0 = imageWidth/2.0f;
float y0 = imageHeight/2.0f;
for( ix = 0; ix < imageWidth; ix++ ){
for( iy = 0; iy < imageHeight; iy++ )
{
xOff = ix - x0;
yOff = iy - y0;
xpos = (int)(xOff*cos_theta + yOff*sin_theta + x0 );
ypos = (int)(yOff*cos_theta - xOff*sin_theta + y0 );
if(((int)xpos>=0) && ((int)xpos< imageWidth) && ((int)ypos>=0) && ((int)ypos< imageHeight)){
outputImage[iy*imageWidth+ix] = inputImage[ypos*imageWidth+xpos];
}
}
} |
Image obtenue(tout est ok) :
Pièce jointe 319286
ensuite je modifie ça :
Code:
1 2
|
outputImage[iy*imageWidth+ix] = inputImage[ypos*imageWidth+xpos]; |
Par ça :
Code:
1 2
|
outputImage[ypos*imageWidth+xpos] = inputImage[iy*imageWidth+ix]; |
ce qui donne :
Pièce jointe 319291
Les pixels noirs... je ne vois absolument pas... l'erreur, un doigt à couper que c'est une erreur d'index sur un des deux tableau !
(PS : Promis j'ai cherché un long moment)