Pour donner des nouvelles (et éventuellement, une idée de solution pour les prochains)
Ne trouvant pas pourquoi je ne pouvais ouvrir mon fichier (maintenant j'ai la réponse, c’était un problème de marshalling des mon char *Profiles)
Je suis passé par ce moyen : dans mon wrapper C#
Cela appelle une fonction que j'ai créé en C et rajoutée dans ma DLL :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
25 [DllImport("lcms2_test.dll", EntryPoint = "rgbToCmyk", CharSet = CharSet.Ansi)] private static extern unsafe double* rgbToCmyk(double[] img, [MarshalAs(UnmanagedType.LPStr)] string iccIn, [MarshalAs(UnmanagedType.LPStr)] string iccOut, int size); public static unsafe double[,] convertImageFromRgbToCmyk(int[,] img, string ICCin, string ICCout, int width, int heigh) { double* inter; double[,] res = new double[heigh, width*4]; for (int a = 0; a < heigh; a++) { double[] temp = createOneLessDimensionArray(img, a); inter = rgbToCmyk(temp, ICCin, ICCout, width); for (int i = 0; i < width * 4; i++) res[a, i] = inter[i]; } return res; } public static double[] createOneLessDimensionArray(int[,] nya, int index) { double[] result = new double[nya.GetLength(1)]; for (int i = 0; i < nya.GetLength(1); i++) result[i] = ((double)(nya[index, i]) / (double)255); return result; }
Du coup merci a ceux qui m'ont aidé et si vous avez des idées pour améliorer, je suis preneur !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
25
26
27
28
29
30
31
32
33
34
35
36 double* rgbToCmyk(double img[], char *iccIn, char *iccOut, int size) { cmsHPROFILE in, out; cmsHTRANSFORM hTransform; double *res; double *base; res = malloc(sizeof(double)*size * 4); base = malloc(sizeof(double)* size * 3); for (int a = 0; a < size * 3; a++) base[a] = img[a]; in = cmsOpenProfileFromFile(iccIn, "r"); if (in == NULL) { res[0] = 0; return res; } out = cmsOpenProfileFromFile(iccOut, "r"); if (out == NULL) { res[0] = 1; return res; } hTransform = cmsCreateTransform(in, TYPE_RGB_DBL, out, TYPE_CMYK_DBL, INTENT_PERCEPTUAL, 0); if (hTransform == NULL) { res[0] = 2; return res; } free(base); cmsCloseProfile(in); cmsCloseProfile(out); cmsDoTransform(hTransform, base, res, size); cmsDeleteTransform(hTransform); return (res); }