Bonjour,
J'ai effectuer un prog en C (sous linux) qui fait une rotation d'une image , mais ca marche pas voici le code:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
 
#define swap(x,y) {int temp;temp=x;x=y;y=temp;}
/* La fonction Rotate*/
void rotate_picture(GdkPixbuf *pb)
{
int ht,wt,mx,my,bx,by;
int i=0,j=0;
int rowstride=0;
double tcos,tsin;
const float pi = 3.14; 
/////////////
float angle_radian;
angle_radian = (float)(-45 * pi / 180.0);
gchar *pixel;
 
tcos=cos(angle_radian);
tsin=sin(angle_radian);
 
ht=gdk_pixbuf_get_height(pb);
wt=gdk_pixbuf_get_width(pb);
////////////////////////
mx=(int)(wt/2);
my=(int)(ht/2);
 
pixel=gdk_pixbuf_get_pixels(pb);
rowstride=gdk_pixbuf_get_rowstride(pb);
 
 for(i=0;i<ht;i++)//iterate over the height of image.
    for(j=0;j<wt;j++) 
      {	
bx =(int)(tcos * (i - mx) + tsin * (j - my) + mx);
by =(int)(-tsin * (i - mx) + tcos * (j - my) + my);
 
 if (bx>=0 && bx< wt && by>=0 && by< ht)
 	}
		printf("bx   = %i",bx);
		printf("by   = %i",by);
		swap(pixel[i*rowstride+j+0],pixel[bx*rowstride+by+0]);
		swap(pixel[i*rowstride+j+1],pixel[bx*rowstride+by+1]);
		swap(pixel[i*rowstride+j+2],pixel[bx*rowstride+by+2]);
        }
 
  return;
}
Si quelqu'un peut me donne de l'aide , Merci