Bonjour,

J'ai écrit une dll pour un autre logiciel et il y a un truc que je n'arrive pas à comprendre, peut-être auriez-vous une idée.

En gros si j'écris la commande rowPtr[q]=I[p-1][o][q]; la dll se construit mais le logiciel plante . Mais si j'effectue une transformation de mon tableau multimensionnel comme suit en conservant la meme taille et que j'ecris rowPtr[q]=J[p-1][o][q]; , alors le logiciel ne plante pas et me donne le resultat avec des matrices transformees.

Ca ne me gene pas pour la suite mais je ne comprends pas. On dirait que puisque j'ai definit mon I en décrémentant mes indices, je ne peux pas le lire ou l'affecter en l'incrémentant. Enfin je sais pas, à partir du moment où j'ai defini mon tableau je devrais pouvoir affecter les valeurs comme bon me semble.
Bref mystère pour moi...




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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
 
uint16_t *** get_Images(uint32_t ImageCount,uint32_t ImHeight, uint32_t ImWidth,FILE* fp)
{
	uint16_t temp;
	uint32_t i,j;
	uint16_t ***I ;
	I = (uint16_t ***)malloc(ImageCount*sizeof(*I));
	for(i = 0; i < ImageCount; i++) 
	{
		I[i] = (uint16_t **)malloc(ImHeight * sizeof(**I));
		for(j = ImHeight; j >0; j--) 
		{
			I[i][j]=(uint16_t *)malloc(ImWidth * sizeof(***I));
		}
	}
	uint16_t tracks[4];
	uint32_t o,p;
	uint32_t q;
	for (p=0;p<ImageCount;p++)
	{
		for(o=ImHeight;o>0;o--)
		{
			for(q=0;q<ImWidth;q++)
			{
				fread(&temp,2,1,fp);
				I[p][o][q]=temp;		
			}
 
		}
		fread(&tracks,sizeof(tracks),1,fp);
	}
 
	return(I);
	for(i=0 ; i < ImageCount ; i++)
	{
		for(j=ImHeight ; j >0 ; j--)
		{
			free(I[i][j]);
		}
	}
	for(i=0 ; i < ImageCount ; i++)
	{
		free(I[i]);
	}
	free(I);
}
 
uint16_t *** transformed_matrix(uint32_t ImageCount,uint32_t ImHeight, uint32_t ImWidth,uint16_t*** I)
{
	uint32_t i,j,k;
	uint16_t ***J ;
	J = (uint16_t ***)malloc(ImageCount*sizeof(*J));
	for(i = 0; i < ImageCount; i++) 
	{
		J[i] = (uint16_t **)malloc(ImHeight * sizeof(**J));
		for(j =0 ; j <ImHeight; j++) 
		{
			J[i][j]=(uint16_t *)malloc(ImWidth * sizeof(***J));
		}
	}
	for(i=0; i<ImageCount; i++) 
	{
		for(j=0;j<ImHeight; j++) 
		{
			for(k=0;k<ImWidth;k++)
			{
				J[i][j][k]=I[i][ImHeight-j][k];		
			}
		}
	}
 
	return(J);
 
	for(i=0 ; i < ImageCount ; i++)
	{
		for(j=0 ; j <ImHeight ; j++)
		{
			free(J[i][j]);
		}
	}
	for(i=0 ; i < ImageCount ; i++)
	{
		free(J[i]);
	}
	free(J);
}
int main()
{
....
I=get_Images(cine_file_header.ImageCount,info_setup.ImHeight,info_setup.ImWidth,fp);
J=transformed_matrix(cine_file_header.ImageCount,info_setup.ImHeight,info_setup.ImWidth,I);
 
for (p=1;p<cine_file_header.ImageCount+1;p++)
{
	SetBufferSize(p,info_setup.ImHeight,info_setup.ImHeight,0);
 
	for(o=0;o<info_setup.ImHeight;o++)
	{
		Word* rowPtr = (Word*)GetBufferRowPtr(p,o);
		for(q=0;q<info_setup.ImWidth;q++)
		{
			rowPtr[q]=J[p-1][o][q];
		}
	}
}
....
}