Rev 550 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 550 | Rev 555 | ||
---|---|---|---|
Line 45... | Line 45... | ||
45 | PIUNLOCKHANDLE(h); |
45 | PIUNLOCKHANDLE(h); |
46 | } |
46 | } |
47 | return e; |
47 | return e; |
48 | } |
48 | } |
49 | 49 | ||
50 | OSErr saveparams_afs_pff(Handle h){ |
50 | OSErr saveparams_afs_pff(Handle h, Boolean premiereOrder){ |
51 | char outbuf[CHOPLINES * 2 + 2] = ""; |
51 | char outbuf[CHOPLINES * 2 + 2] = ""; |
52 | char *q, * p, * r, * start; |
52 | char *q, * p, * r, * start; |
53 | size_t n, chunk, j; |
53 | size_t n, chunk, j; |
54 | int i; |
54 | int i, k; |
55 | OSErr e; |
55 | OSErr e; |
56 | size_t est; |
56 | size_t est; |
57 | static char afs_sig[] = "%RGB-1.0\r"; |
57 | static char afs_sig[] = "%RGB-1.0\r"; |
58 | 58 | ||
59 | if (!h) return nilHandleErr; |
59 | if (!h) return nilHandleErr; |
Line 70... | Line 70... | ||
70 | /* then slider values, one per line */ |
70 | /* then slider values, one per line */ |
71 | for( i=0 ; i<8 ; ++i ) |
71 | for( i=0 ; i<8 ; ++i ) |
72 | p += sprintf(p, "%d\r", gdata->parm.val[i]); |
72 | p += sprintf(p, "%d\r", gdata->parm.val[i]); |
73 | 73 | ||
74 | /* expressions, broken into lines no longer than CHOPLINES characters */ |
74 | /* expressions, broken into lines no longer than CHOPLINES characters */ |
75 | for( i=0 ; i<4 ; ++i ){ |
75 | for( k=0 ; k<4 ; ++k ){ |
- | 76 | i = k; |
|
- | 77 | if (premiereOrder) { |
|
- | 78 | // Premiere has the order BGRA, while Photoshop (and our internal order) is RGBA |
|
- | 79 | if (k == 0) i = 2; |
|
- | 80 | else if (k == 2) i = 0; |
|
- | 81 | } |
|
76 | if ((r = gdata->parm.szFormula[i])) { |
82 | if ((r = gdata->parm.szFormula[i])) { |
77 | chunk = 0; // to avoid that compiler complains |
83 | chunk = 0; // to avoid that compiler complains |
78 | for (n = strlen(r); n; n -= chunk) { |
84 | for (n = strlen(r); n; n -= chunk) { |
79 | chunk = n > (int)CHOPLINES ? (int)CHOPLINES : n; |
85 | chunk = n > (int)CHOPLINES ? (int)CHOPLINES : n; |
80 | for (j = chunk, q = outbuf; j--; ) |
86 | for (j = chunk, q = outbuf; j--; ) |
Line 261... | Line 267... | ||
261 | e = FSWrite(r,&n,p); |
267 | e = FSWrite(r,&n,p); |
262 | PIUNLOCKHANDLE(h); |
268 | PIUNLOCKHANDLE(h); |
263 | return e; |
269 | return e; |
264 | } |
270 | } |
265 | 271 | ||
266 | Boolean savefile_afs_pff_picotxt_guf(StandardFileReply *sfr){ |
272 | FFSavingResult savefile_afs_pff_picotxt_guf(StandardFileReply *sfr){ |
267 | FILEREF r; |
273 | FILEREF r; |
268 | Handle h; |
274 | Handle h; |
269 | Boolean res = false; |
275 | Boolean bres = false; |
270 | TCHAR* reasonstr = NULL; |
276 | FFSavingResult res = 0; |
271 | 277 | ||
272 | FSpDelete(&sfr->sfFile); |
278 | FSpDelete(&sfr->sfFile); |
273 | if(FSpCreate(&sfr->sfFile,SIG_SIMPLETEXT,TEXT_FILETYPE,sfr->sfScript) == noErr) |
279 | if (FSpCreate(&sfr->sfFile, SIG_SIMPLETEXT, TEXT_FILETYPE, sfr->sfScript) == noErr) { |
274 | if(FSpOpenDF(&sfr->sfFile,fsWrPerm,&r) == noErr){ |
280 | if (FSpOpenDF(&sfr->sfFile, fsWrPerm, &r) == noErr) { |
275 | 281 | ||
276 | if (fileHasExtension(sfr, TEXT(".txt"))) { |
282 | if (fileHasExtension(sfr, TEXT(".txt"))) { |
277 | // PluginCommander .txt |
283 | // PluginCommander .txt |
278 | if ((h = PINEWHANDLE(1))) { // don't set initial size to 0, since some hosts (e.g. GIMP/PSPI) are incompatible with that. |
284 | if ((h = PINEWHANDLE(1))) { // don't set initial size to 0, since some hosts (e.g. GIMP/PSPI) are incompatible with that. |
279 | res = !(saveparams_picotxt(h) || savehandleintofile(h, r)); |
285 | bres = !(saveparams_picotxt(h) || savehandleintofile(h, r)); |
- | 286 | if (!bres) res = MSG_ERROR_GENERATING_DATA_ID; |
|
280 | PIDISPOSEHANDLE(h); |
287 | PIDISPOSEHANDLE(h); |
281 | } |
288 | } |
- | 289 | else res = MSG_OUT_OF_MEMORY_ID; |
|
282 | } |
290 | } |
283 | - | ||
284 | if (fileHasExtension(sfr, TEXT(".guf"))) { |
291 | else if (fileHasExtension(sfr, TEXT(".guf"))) { |
285 | // GIMP UserFilter file |
292 | // GIMP UserFilter file |
286 | if ((h = PINEWHANDLE(1))) { // don't set initial size to 0, since some hosts (e.g. GIMP/PSPI) are incompatible with that. |
293 | if ((h = PINEWHANDLE(1))) { // don't set initial size to 0, since some hosts (e.g. GIMP/PSPI) are incompatible with that. |
287 | res = !(saveparams_guf(h) || savehandleintofile(h, r)); |
294 | bres = !(saveparams_guf(h) || savehandleintofile(h, r)); |
- | 295 | if (!bres) res = MSG_ERROR_GENERATING_DATA_ID; |
|
288 | PIDISPOSEHANDLE(h); |
296 | PIDISPOSEHANDLE(h); |
289 | } |
297 | } |
- | 298 | else res = MSG_OUT_OF_MEMORY_ID; |
|
290 | } |
299 | } |
291 | - | ||
292 | if ((fileHasExtension(sfr, TEXT(".afs"))) || (fileHasExtension(sfr, TEXT(".pff")))) { |
300 | else if ((fileHasExtension(sfr, TEXT(".afs"))) || (fileHasExtension(sfr, TEXT(".pff")))) { |
293 | if (fileHasExtension(sfr, TEXT(".pff"))) { |
- | |
294 | // If it is a Premiere settings file, we need to swap the channels red and blue |
- | |
295 | // We just swap the pointers! |
- | |
296 | char tmp[MAXEXPR]; |
- | |
297 | strcpy(tmp, gdata->parm.szFormula[0]); |
- | |
298 | strcpy(gdata->parm.szFormula[0], gdata->parm.szFormula[2]); |
- | |
299 | strcpy(gdata->parm.szFormula[2], tmp); |
- | |
300 | } |
- | |
301 | - | ||
302 | if ((h = PINEWHANDLE(1))) { // don't set initial size to 0, since some hosts (e.g. GIMP/PSPI) are incompatible with that. |
301 | if ((h = PINEWHANDLE(1))) { // don't set initial size to 0, since some hosts (e.g. GIMP/PSPI) are incompatible with that. |
303 | res = !(saveparams_afs_pff(h) || savehandleintofile(h, r)); |
302 | bres = !(saveparams_afs_pff(h, fileHasExtension(sfr, TEXT(".pff"))) || savehandleintofile(h, r)); |
- | 303 | if (!bres) res = MSG_ERROR_GENERATING_DATA_ID; |
|
304 | PIDISPOSEHANDLE(h); |
304 | PIDISPOSEHANDLE(h); |
305 | } |
305 | } |
306 | - | ||
307 | if (fileHasExtension(sfr, TEXT(".pff"))) { |
- | |
308 | // Swap back so that the other program stuff will work normally again |
- | |
309 | char tmp[MAXEXPR]; |
306 | else res = MSG_OUT_OF_MEMORY_ID; |
310 | strcpy(tmp, gdata->parm.szFormula[0]); |
- | |
311 | strcpy(gdata->parm.szFormula[0], gdata->parm.szFormula[2]); |
- | |
312 | strcpy(gdata->parm.szFormula[2], tmp); |
- | |
313 | } |
307 | } |
- | 308 | else { |
|
- | 309 | res = MSG_UNSUPPORTED_FILE_FORMAT_ID; |
|
314 | } |
310 | } |
315 | 311 | ||
316 | FSClose(r); |
312 | FSClose(r); |
317 | }else reasonstr = FF_GetMsg_Cpy(MSG_CANNOT_OPEN_FILE_ID); |
- | |
318 | else reasonstr = FF_GetMsg_Cpy(MSG_CANNOT_CREATE_FILE_ID); |
- | |
319 | - | ||
320 | if (!res) { |
- | |
321 | alertuser_id(MSG_CANNOT_SAVE_SETTINGS_ID, reasonstr); |
- | |
322 | } |
313 | } |
- | 314 | else res = MSG_CANNOT_OPEN_FILE_ID; |
|
323 | 315 | } |
|
324 | if (reasonstr) FF_GetMsg_Free(reasonstr); |
316 | else res = MSG_CANNOT_CREATE_FILE_ID; |
325 | 317 | ||
326 | return res; |
318 | return res; |
327 | } |
319 | } |