Tk Img Extensions
Diff
Not logged in
Tcl 2014 Conference, Portland/OR, US, Nov 10-14
Send your abstracts to tclconference@googlegroups.com by Sep 8.

Differences From Artifact [e0fe1bf3f0]:

To Artifact [083b20cb8b]:


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
108
109


110
111
112
113

114
115

116
117
118
119
120
121
122
123
124
125







126
127
128
129
130
131
132
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


108
109
110
111
112

113
114

115
116
117
118







119
120
121
122
123
124
125
126
127
128
129
130
131
132







-
-
+
+








-
+

-
+

-
-
+
+

-
+

-
+

-
+

-
+

-
-
+
+

-
+

-
+


-
-
-
-
-
-
-
+
+
+
+
+
+
+











-
+

-
+



-
-
+
+



-
+

-
+



-
+

-
+



-
-
+
+



-
+

-
+



-
-
-
-
-
-
-
+
+
+
+
+
+
+







#endif

/*
 * Functions exported for package management.
 */


EXTERN int @CPACKAGE@_Init     _ANSI_ARGS_((Tcl_Interp *interp));
EXTERN int @CPACKAGE@_SafeInit _ANSI_ARGS_((Tcl_Interp *interp));
EXTERN int @CPACKAGE@_Init(Tcl_Interp *interp);
EXTERN int @CPACKAGE@_SafeInit(Tcl_Interp *interp);

#undef  TCL_STORAGE_CLASS
#define TCL_STORAGE_CLASS DLLIMPORT

/*
 * Declarations of internal functions.
 */

static int ChnMatch _ANSI_ARGS_((Tcl_Interp *interp, Tcl_Channel chan,
static int ChnMatch(Tcl_Interp *interp, Tcl_Channel chan,
	const char *fileName, Tcl_Obj *format, int *widthPtr,
	int *heightPtr));
	int *heightPtr);

static int ObjMatch _ANSI_ARGS_((Tcl_Interp *interp, Tcl_Obj *dataObj,
	Tcl_Obj *format, int *widthPtr, int *heightPtr));
static int ObjMatch(Tcl_Interp *interp, Tcl_Obj *dataObj,
	Tcl_Obj *format, int *widthPtr, int *heightPtr);

static int ChnRead _ANSI_ARGS_((Tcl_Interp *interp, Tcl_Channel chan,
static int ChnRead(Tcl_Interp *interp, Tcl_Channel chan,
	const char *fileName, Tcl_Obj *format, Tk_PhotoHandle imageHandle,
	int destX, int destY, int width, int height, int srcX, int srcY));
	int destX, int destY, int width, int height, int srcX, int srcY);

static int ObjRead _ANSI_ARGS_((Tcl_Interp *interp, Tcl_Obj *dataObj,
static int ObjRead(Tcl_Interp *interp, Tcl_Obj *dataObj,
	Tcl_Obj *format, Tk_PhotoHandle imageHandle,
	int destX, int destY, int width, int height, int srcX, int srcY));
	int destX, int destY, int width, int height, int srcX, int srcY);

static int ChnWrite _ANSI_ARGS_((Tcl_Interp *interp, const char *filename,
	Tcl_Obj *format, Tk_PhotoImageBlock *blockPtr));
static int ChnWrite(Tcl_Interp *interp, const char *filename,
	Tcl_Obj *format, Tk_PhotoImageBlock *blockPtr);

static int StringWrite _ANSI_ARGS_((Tcl_Interp *interp,
static int StringWrite(Tcl_Interp *interp,
	Tcl_DString *data, Tcl_Obj *format,
	Tk_PhotoImageBlock *blockPtr));
	Tk_PhotoImageBlock *blockPtr);

static Tk_PhotoImageFormat format = {
    "%PHIMGTYPE%",					/* name */
    (Tk_ImageFileMatchProc *)   ChnMatch,	/* fileMatchProc */
    (Tk_ImageStringMatchProc *) ObjMatch,	/* stringMatchProc */
    (Tk_ImageFileReadProc *)    ChnRead,	/* fileReadProc */
    (Tk_ImageStringReadProc *)  ObjRead,	/* stringReadProc */
    (Tk_ImageFileWriteProc *)   ChnWrite,	/* fileWriteProc */
    (Tk_ImageStringWriteProc *) StringWrite	/* stringWriteProc */
	(char *) "%PHIMGTYPE%", /* name */
	(Tk_ImageFileMatchProc *) ChnMatch, /* fileMatchProc */
	(Tk_ImageStringMatchProc *) ObjMatch, /* stringMatchProc */
	(Tk_ImageFileReadProc *) ChnRead, /* fileReadProc */
	(Tk_ImageStringReadProc *) ObjRead, /* stringReadProc */
	(Tk_ImageFileWriteProc *) ChnWrite, /* fileWriteProc */
	(Tk_ImageStringWriteProc *) StringWrite /* stringWriteProc */
};

#ifdef SECOND_FORMAT
/*
 * Declare procedures of the second format as needed. The macro we
 * check for allow us to share code between first and second
 * format. Current user of this feature: The PS/PDF combo handler
 */

#ifndef SECOND_CHNMATCH
#define SECOND_CHNMATCH ChnMatchBeta
static int ChnMatchBeta _ANSI_ARGS_((Tcl_Interp *interp, Tcl_Channel chan,
static int ChnMatchBeta(Tcl_Interp *interp, Tcl_Channel chan,
	const char *fileName, Tcl_Obj *format, int *widthPtr,
	int *heightPtr));
	int *heightPtr);
#endif
#ifndef SECOND_OBJMATCH
#define SECOND_OBJMATCH ObjMatchBeta
static int ObjMatchBeta _ANSI_ARGS_((Tcl_Interp *interp, Tcl_Obj *dataObj,
	Tcl_Obj *format, int *widthPtr, int *heightPtr));
static int ObjMatchBeta(Tcl_Interp *interp, Tcl_Obj *dataObj,
	Tcl_Obj *format, int *widthPtr, int *heightPtr);
#endif
#ifndef SECOND_CHNREAD
#define SECOND_CHNREAD ChnReadBeta
static int ChnReadBeta _ANSI_ARGS_((Tcl_Interp *interp, Tcl_Channel chan,
static int ChnReadBeta(Tcl_Interp *interp, Tcl_Channel chan,
	const char *fileName, Tcl_Obj *format, Tk_PhotoHandle imageHandle,
	int destX, int destY, int width, int height, int srcX, int srcY));
	int destX, int destY, int width, int height, int srcX, int srcY);
#endif
#ifndef SECOND_OBJREAD
#define SECOND_OBJREAD ChnObjReadBeta
static int ObjReadBeta _ANSI_ARGS_((Tcl_Interp *interp, Tcl_Obj *dataObj,
static int ObjReadBeta(Tcl_Interp *interp, Tcl_Obj *dataObj,
	Tcl_Obj *format, Tk_PhotoHandle imageHandle,
	int destX, int destY, int width, int height, int srcX, int srcY));
	int destX, int destY, int width, int height, int srcX, int srcY);
#endif
#ifndef SECOND_CHNWRITE
#define SECOND_CHNWRITE ChnWriteBeta
static int ChnWriteBeta _ANSI_ARGS_((Tcl_Interp *interp, const char *filename,
	Tcl_Obj *format, Tk_PhotoImageBlock *blockPtr));
static int ChnWriteBeta(Tcl_Interp *interp, const char *filename,
	Tcl_Obj *format, Tk_PhotoImageBlock *blockPtr);
#endif
#ifndef SECOND_STRWRITE
#define SECOND_STRWRITE StringWriteBeta
static int StringWriteBeta _ANSI_ARGS_((Tcl_Interp *interp,
static int StringWriteBeta(Tcl_Interp *interp,
	Tcl_DString *data, Tcl_Obj *format,
	Tk_PhotoImageBlock *blockPtr));
	Tk_PhotoImageBlock *blockPtr);
#endif

static Tk_PhotoImageFormat format_beta = {
    "%PHIMGTYPE_BETA%",					/* name */
    (Tk_ImageFileMatchProc *)   SECOND_CHNMATCH,	/* fileMatchProc */
    (Tk_ImageStringMatchProc *) SECOND_OBJMATCH,	/* stringMatchProc */
    (Tk_ImageFileReadProc *)    SECOND_CHNREAD,		/* fileReadProc */
    (Tk_ImageStringReadProc *)  SECOND_OBJREAD,		/* stringReadProc */
    (Tk_ImageFileWriteProc *)   SECOND_CHNWRITE,	/* fileWriteProc */
    (Tk_ImageStringWriteProc *) SECOND_STRWRITE		/* stringWriteProc */
	(char *) "%PHIMGTYPE_BETA%", /* name */
	(Tk_ImageFileMatchProc *) SECOND_CHNMATCH, /* fileMatchProc */
	(Tk_ImageStringMatchProc *) SECOND_OBJMATCH, /* stringMatchProc */
	(Tk_ImageFileReadProc *) SECOND_CHNREAD, /* fileReadProc */
	(Tk_ImageStringReadProc *) SECOND_OBJREAD, /* stringReadProc */
	(Tk_ImageFileWriteProc *) SECOND_CHNWRITE, /* fileWriteProc */
	(Tk_ImageStringWriteProc *) SECOND_STRWRITE /* stringWriteProc */
};

#endif /* SECOND_FORMAT */


/*
 *----------------------------------------------------------------------------
141
142
143
144
145
146
147
148
149


150

151
152
153
154



155
156
157
158
159



160
161
162
163
164



165
166
167

168
169
170
171



172
173

174
175

176
177
178
179
180



181
182
183
184
185




186
187

188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206


207
208


209
210

141
142
143
144
145
146
147


148
149

150
151



152
153
154
155
156



157
158
159
160
161



162
163
164
165
166

167
168



169
170
171
172

173
174

175
176
177



178
179
180
181




182
183
184
185
186

187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204


205
206


207
208
209

210







-
-
+
+
-
+

-
-
-
+
+
+


-
-
-
+
+
+


-
-
-
+
+
+


-
+

-
-
-
+
+
+

-
+

-
+


-
-
-
+
+
+

-
-
-
-
+
+
+
+

-
+

















-
-
+
+
-
-
+
+

-
+
 * Side effects:
 *  Creates commands in the interpreter, loads package.
 *
 *----------------------------------------------------------------------------
 */

int
@CPACKAGE@_Init (interp)
      Tcl_Interp *interp; /* Interpreter to initialise. */
@CPACKAGE@_Init(
	Tcl_Interp *interp /* Interpreter to initialise. */
{
) {
#ifdef USE_TCL_STUBS
    if (Tcl_InitStubs(interp, "8.1", 0) == NULL) {
        return TCL_ERROR;
    }
	if (Tcl_InitStubs(interp, "8.3", 0) == NULL) {
		return TCL_ERROR;
	}
#endif
#ifdef USE_TK_STUBS
    if (Tk_InitStubs(interp, "8.1", 0) == NULL) {
        return TCL_ERROR;
    }
	if (Tk_InitStubs(interp, "8.3", 0) == NULL) {
		return TCL_ERROR;
	}
#endif
#ifdef USE_TKIMG_STUBS
    if (Tkimg_InitStubs(interp, TKIMG_VERSION, 0) == NULL) {
        return TCL_ERROR;
    }
	if (Tkimg_InitStubs(interp, TKIMG_VERSION, 0) == NULL) {
		return TCL_ERROR;
	}
#endif

    MORE_INITIALIZATION;
	MORE_INITIALIZATION;

    /*
     * Register the new photo image type.
     */
	/*
	 * Register the new photo image type.
	 */

    Tk_CreatePhotoImageFormat (&format);
	Tk_CreatePhotoImageFormat (&format);
#ifdef SECOND_FORMAT
    Tk_CreatePhotoImageFormat (&format_beta);
	Tk_CreatePhotoImageFormat (&format_beta);
#endif /* SECOND_FORMAT */

    /*
     * At last provide the package ...
     */
	/*
	 * At last provide the package ...
	 */

    if (Tcl_PkgProvide(interp, PACKAGE_TCLNAME, PACKAGE_VERSION) != TCL_OK) {
        return TCL_ERROR;
    }
    return TCL_OK;
	if (Tcl_PkgProvide(interp, PACKAGE_TCLNAME, PACKAGE_VERSION) != TCL_OK) {
		return TCL_ERROR;
	}
	return TCL_OK;
}


/*
 *----------------------------------------------------------------------------
 *
 * @CPACKAGE@_SafeInit --
 *
 *  Initialisation routine for loadable module in a safe interpreter.
 *
 * Results:
 *  None.
 *
 * Side effects:
 *  Creates commands in the interpreter, loads package.
 *
 *----------------------------------------------------------------------------
 */

int
@CPACKAGE@_SafeInit (interp)
      Tcl_Interp *interp; /* Interpreter to initialise. */
@CPACKAGE@_SafeInit(
	Tcl_Interp *interp /* Interpreter to initialise. */
{
    return @CPACKAGE@_Init (interp);
) {
	return @CPACKAGE@_Init (interp);
}