]>
Commit | Line | Data |
---|---|---|
ca441159 ER |
1 | --- trunk/amsn/utils/TkCximage/src/TkCximage.cpp 2008/12/26 16:39:41 10817 |
2 | +++ trunk/amsn/utils/TkCximage/src/TkCximage.cpp 2008/12/28 21:50:08 10818 | |
3 | @@ -26,6 +26,65 @@ | |
4 | char currenttime[30]; | |
5 | FILE * logfile; | |
6 | ||
7 | +#define AVAILABLE_FORMATS 6 | |
8 | +Tk_PhotoImageFormat cximageFormats[] = { | |
9 | + { | |
10 | + "cximage", | |
11 | + (Tk_ImageFileMatchProc *) ChanMatch, | |
12 | + (Tk_ImageStringMatchProc *) ObjMatch, | |
13 | + (Tk_ImageFileReadProc *) ChanRead, | |
14 | + (Tk_ImageStringReadProc *) ObjRead, | |
15 | + (Tk_ImageFileWriteProc *) ChanWrite, | |
16 | + (Tk_ImageStringWriteProc *) StringWrite | |
17 | + }, | |
18 | + { | |
19 | + "cxgif", | |
20 | + (Tk_ImageFileMatchProc *) ChanMatch, | |
21 | + (Tk_ImageStringMatchProc *) ObjMatch, | |
22 | + (Tk_ImageFileReadProc *) ChanRead, | |
23 | + (Tk_ImageStringReadProc *) ObjRead, | |
24 | + (Tk_ImageFileWriteProc *) ChanWrite, | |
25 | + (Tk_ImageStringWriteProc *) StringWrite | |
26 | + }, | |
27 | + { | |
28 | + "cxpng", | |
29 | + (Tk_ImageFileMatchProc *) ChanMatch, | |
30 | + (Tk_ImageStringMatchProc *) ObjMatch, | |
31 | + (Tk_ImageFileReadProc *) ChanRead, | |
32 | + (Tk_ImageStringReadProc *) ObjRead, | |
33 | + (Tk_ImageFileWriteProc *) ChanWrite, | |
34 | + (Tk_ImageStringWriteProc *) StringWrite | |
35 | + }, | |
36 | + { | |
37 | + "cxjpg", | |
38 | + (Tk_ImageFileMatchProc *) ChanMatch, | |
39 | + (Tk_ImageStringMatchProc *) ObjMatch, | |
40 | + (Tk_ImageFileReadProc *) ChanRead, | |
41 | + (Tk_ImageStringReadProc *) ObjRead, | |
42 | + (Tk_ImageFileWriteProc *) ChanWrite, | |
43 | + (Tk_ImageStringWriteProc *) StringWrite | |
44 | + }, | |
45 | + { | |
46 | + "cxtga", | |
47 | + (Tk_ImageFileMatchProc *) ChanMatch, | |
48 | + (Tk_ImageStringMatchProc *) ObjMatch, | |
49 | + (Tk_ImageFileReadProc *) ChanRead, | |
50 | + (Tk_ImageStringReadProc *) ObjRead, | |
51 | + (Tk_ImageFileWriteProc *) ChanWrite, | |
52 | + (Tk_ImageStringWriteProc *) StringWrite | |
53 | + }, | |
54 | + { | |
55 | + "cxbmp", | |
56 | + (Tk_ImageFileMatchProc *) ChanMatch, | |
57 | + (Tk_ImageStringMatchProc *) ObjMatch, | |
58 | + (Tk_ImageFileReadProc *) ChanRead, | |
59 | + (Tk_ImageStringReadProc *) ObjRead, | |
60 | + (Tk_ImageFileWriteProc *) ChanWrite, | |
61 | + (Tk_ImageStringWriteProc *) StringWrite | |
62 | + } | |
63 | +}; | |
64 | + | |
65 | + | |
66 | int RGB2BGR(Tk_PhotoImageBlock *data, BYTE * pixelPtr) { | |
67 | int i; | |
68 | int size = data->height * data->width * data->pixelSize; | |
69 | @@ -267,10 +326,6 @@ | |
70 | INITLOGS(); // | |
71 | LOG("---------------------------------"); // | |
72 | ||
73 | - | |
74 | - int AvailableFromats = 6; | |
75 | - const char *KnownFormats[] = {"cximage", "cxgif", "cxpng", "cxjpg", "cxtga", "cxbmp"}; | |
76 | - | |
77 | //Check Tcl version is 8.3 or higher | |
78 | if (Tcl_InitStubs(interp, TCL_VERSION, 1) == NULL) { | |
79 | return TCL_ERROR; | |
80 | @@ -285,15 +340,6 @@ | |
81 | ||
82 | LOG("Tk stub initialized"); // | |
83 | ||
84 | - Tk_PhotoImageFormat cximageFormats = { | |
85 | - NULL, | |
86 | - (Tk_ImageFileMatchProc *) ChanMatch, | |
87 | - (Tk_ImageStringMatchProc *) ObjMatch, | |
88 | - (Tk_ImageFileReadProc *) ChanRead, | |
89 | - (Tk_ImageStringReadProc *) ObjRead, | |
90 | - (Tk_ImageFileWriteProc *) ChanWrite, | |
91 | - (Tk_ImageStringWriteProc *) StringWrite | |
92 | - }; | |
93 | ||
94 | LOG("Creating commands"); // | |
95 | ||
96 | @@ -323,14 +369,9 @@ | |
97 | #endif | |
98 | ||
99 | LOG("Adding format : "); // | |
100 | - for (i = 0; i < AvailableFromats; i++) { | |
101 | - delete cximageFormats.name; | |
102 | - cximageFormats.name = new char[strlen(KnownFormats[i]) + 1]; | |
103 | - strcpy(cximageFormats.name, KnownFormats[i]); | |
104 | - Tk_CreatePhotoImageFormat(&cximageFormats); | |
105 | - APPENDLOG(cximageFormats.name); // | |
106 | - delete cximageFormats.name; | |
107 | - cximageFormats.name = NULL; | |
108 | + for (i = 0; i < AVAILABLE_FORMATS; i++) { | |
109 | + Tk_CreatePhotoImageFormat(&cximageFormats[i]); | |
110 | + APPENDLOG(cximageFormats[i].name); // | |
111 | } | |
112 | ||
113 | // end of Initialisation |