@@ -1157,43 +1157,6 @@ static int _get_snap(GraphicsContext* self, enum e_snap_mode* mode)
1157
1157
return Py_None;
1158
1158
}
1159
1159
1160
- static BOOL _clip (CGContextRef cr, PyObject* object)
1161
- {
1162
- if (object == Py_None) return true ;
1163
-
1164
- PyArrayObject* array = NULL ;
1165
- array = (PyArrayObject*) PyArray_FromObject (object, PyArray_DOUBLE, 2 , 2 );
1166
- if (!array)
1167
- {
1168
- PyErr_SetString (PyExc_ValueError, " failed to read clipping bounding box" );
1169
- return false ;
1170
- }
1171
-
1172
- if (PyArray_NDIM (array)!=2 || PyArray_DIM (array, 0 )!=2 || PyArray_DIM (array, 1 )!=2 )
1173
- {
1174
- Py_DECREF (array);
1175
- PyErr_SetString (PyExc_ValueError, " clipping bounding box should be a 2x2 array" );
1176
- return false ;
1177
- }
1178
-
1179
- const double l = *(double *)PyArray_GETPTR2 (array, 0 , 0 );
1180
- const double b = *(double *)PyArray_GETPTR2 (array, 0 , 1 );
1181
- const double r = *(double *)PyArray_GETPTR2 (array, 1 , 0 );
1182
- const double t = *(double *)PyArray_GETPTR2 (array, 1 , 1 );
1183
-
1184
- Py_DECREF (array);
1185
-
1186
- CGRect rect;
1187
- rect.origin .x = (CGFloat ) l;
1188
- rect.origin .y = (CGFloat ) b;
1189
- rect.size .width = (CGFloat ) (r-l);
1190
- rect.size .height = (CGFloat ) (t-b);
1191
-
1192
- CGContextClipToRect (cr, rect);
1193
-
1194
- return true ;
1195
- }
1196
-
1197
1160
static int _transformation_converter (PyObject* object, void * pointer)
1198
1161
{
1199
1162
CGAffineTransform * matrix = (CGAffineTransform *)pointer;
@@ -3038,9 +3001,6 @@ static void _data_provider_release(void* info, const void* data, size_t size)
3038
3001
const char * data;
3039
3002
int n;
3040
3003
PyObject* image;
3041
- PyObject* cliprect;
3042
- PyObject* clippath;
3043
- PyObject* clippath_transform;
3044
3004
3045
3005
CGContextRef cr = self->cr ;
3046
3006
if (!cr)
@@ -3049,18 +3009,14 @@ static void _data_provider_release(void* info, const void* data, size_t size)
3049
3009
return NULL ;
3050
3010
}
3051
3011
3052
- if (!PyArg_ParseTuple (args, " ffiiOOOO" , &x,
3053
- &y,
3054
- &nrows,
3055
- &ncols,
3056
- &image,
3057
- &cliprect,
3058
- &clippath,
3059
- &clippath_transform)) return NULL ;
3012
+ if (!PyArg_ParseTuple (args, " ffiiO" , &x,
3013
+ &y,
3014
+ &nrows,
3015
+ &ncols,
3016
+ &image)) return NULL ;
3060
3017
3061
3018
CGColorSpaceRef colorspace;
3062
3019
CGDataProviderRef provider;
3063
- double rect[4 ] = {0.0 , 0.0 , self->size .width , self->size .height };
3064
3020
3065
3021
if (!PyBytes_Check (image))
3066
3022
{
@@ -3118,40 +3074,8 @@ static void _data_provider_release(void* info, const void* data, size_t size)
3118
3074
return NULL ;
3119
3075
}
3120
3076
3121
- BOOL ok = true ;
3122
- CGContextSaveGState (cr);
3123
- if (!_clip (cr, cliprect)) ok = false ;
3124
- else if (clippath!=Py_None)
3125
- {
3126
- int n;
3127
- void * iterator = get_path_iterator (clippath,
3128
- clippath_transform,
3129
- 0 ,
3130
- 0 ,
3131
- rect,
3132
- SNAP_AUTO,
3133
- 1.0 ,
3134
- 0 );
3135
- if (iterator)
3136
- {
3137
- n = _draw_path (cr, iterator);
3138
- free_path_iterator (iterator);
3139
- if (n > 0 ) CGContextClip (cr);
3140
- }
3141
- else
3142
- {
3143
- PyErr_SetString (PyExc_RuntimeError,
3144
- " draw_image: failed to obtain path iterator for clipping" );
3145
- ok = false ;
3146
- }
3147
- }
3148
-
3149
- if (ok) CGContextDrawImage (cr, CGRectMake (x,y,ncols,nrows), bitmap);
3150
-
3077
+ CGContextDrawImage (cr, CGRectMake (x,y,ncols,nrows), bitmap);
3151
3078
CGImageRelease (bitmap);
3152
- CGContextRestoreGState (cr);
3153
-
3154
- if (!ok) return NULL ;
3155
3079
3156
3080
Py_INCREF (Py_None);
3157
3081
return Py_None;
0 commit comments