Skip to content

Commit 8212261

Browse files
committed
Raise an exception when bluring a indexed surface.
1 parent 7075280 commit 8212261

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

docs/reST/ref/transform.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,9 @@ Instead, always begin with the original image and scale to the desired size.)
211211
212212
Returns the blurred surface using box blur algorithm.
213213

214+
This function does not work for indexed surfaces.
215+
An exception will be thrown if the input is an indexed surface.
216+
214217
.. versionadded:: 2.2.0
215218

216219
.. ## pygame.transform.box_blur ##
@@ -223,6 +226,9 @@ Instead, always begin with the original image and scale to the desired size.)
223226
Returns the blurred surface using gaussian blur algorithm.
224227
Slower than `box_blur()`.
225228

229+
This function does not work for indexed surfaces.
230+
An exception will be thrown if the input is an indexed surface.
231+
226232
.. versionadded:: 2.2.0
227233

228234
.. ## pygame.transform.gaussian_blur ##

src_c/transform.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3242,6 +3242,10 @@ blur(pgSurfaceObject *srcobj, pgSurfaceObject *dstobj, int radius,
32423242

32433243
src = pgSurface_AsSurface(srcobj);
32443244

3245+
if (src->format->palette) {
3246+
return RAISE(PyExc_ValueError, "Indexed surfaces connot be blurred.");
3247+
}
3248+
32453249
if (!dstobj) {
32463250
retsurf = newsurf_fromsurf(src, src->w, src->h);
32473251
if (!retsurf)

0 commit comments

Comments
 (0)