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
7 +#define AVAILABLE_FORMATS 6
8 +Tk_PhotoImageFormat cximageFormats[] = {
11 + (Tk_ImageFileMatchProc *) ChanMatch,
12 + (Tk_ImageStringMatchProc *) ObjMatch,
13 + (Tk_ImageFileReadProc *) ChanRead,
14 + (Tk_ImageStringReadProc *) ObjRead,
15 + (Tk_ImageFileWriteProc *) ChanWrite,
16 + (Tk_ImageStringWriteProc *) StringWrite
20 + (Tk_ImageFileMatchProc *) ChanMatch,
21 + (Tk_ImageStringMatchProc *) ObjMatch,
22 + (Tk_ImageFileReadProc *) ChanRead,
23 + (Tk_ImageStringReadProc *) ObjRead,
24 + (Tk_ImageFileWriteProc *) ChanWrite,
25 + (Tk_ImageStringWriteProc *) StringWrite
29 + (Tk_ImageFileMatchProc *) ChanMatch,
30 + (Tk_ImageStringMatchProc *) ObjMatch,
31 + (Tk_ImageFileReadProc *) ChanRead,
32 + (Tk_ImageStringReadProc *) ObjRead,
33 + (Tk_ImageFileWriteProc *) ChanWrite,
34 + (Tk_ImageStringWriteProc *) StringWrite
38 + (Tk_ImageFileMatchProc *) ChanMatch,
39 + (Tk_ImageStringMatchProc *) ObjMatch,
40 + (Tk_ImageFileReadProc *) ChanRead,
41 + (Tk_ImageStringReadProc *) ObjRead,
42 + (Tk_ImageFileWriteProc *) ChanWrite,
43 + (Tk_ImageStringWriteProc *) StringWrite
47 + (Tk_ImageFileMatchProc *) ChanMatch,
48 + (Tk_ImageStringMatchProc *) ObjMatch,
49 + (Tk_ImageFileReadProc *) ChanRead,
50 + (Tk_ImageStringReadProc *) ObjRead,
51 + (Tk_ImageFileWriteProc *) ChanWrite,
52 + (Tk_ImageStringWriteProc *) StringWrite
56 + (Tk_ImageFileMatchProc *) ChanMatch,
57 + (Tk_ImageStringMatchProc *) ObjMatch,
58 + (Tk_ImageFileReadProc *) ChanRead,
59 + (Tk_ImageStringReadProc *) ObjRead,
60 + (Tk_ImageFileWriteProc *) ChanWrite,
61 + (Tk_ImageStringWriteProc *) StringWrite
66 int RGB2BGR(Tk_PhotoImageBlock *data, BYTE * pixelPtr) {
68 int size = data->height * data->width * data->pixelSize;
71 LOG("---------------------------------"); //
74 - int AvailableFromats = 6;
75 - const char *KnownFormats[] = {"cximage", "cxgif", "cxpng", "cxjpg", "cxtga", "cxbmp"};
77 //Check Tcl version is 8.3 or higher
78 if (Tcl_InitStubs(interp, TCL_VERSION, 1) == NULL) {
82 LOG("Tk stub initialized"); //
84 - Tk_PhotoImageFormat cximageFormats = {
86 - (Tk_ImageFileMatchProc *) ChanMatch,
87 - (Tk_ImageStringMatchProc *) ObjMatch,
88 - (Tk_ImageFileReadProc *) ChanRead,
89 - (Tk_ImageStringReadProc *) ObjRead,
90 - (Tk_ImageFileWriteProc *) ChanWrite,
91 - (Tk_ImageStringWriteProc *) StringWrite
94 LOG("Creating commands"); //
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); //
113 // end of Initialisation