Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7cccfb3

Browse files
committed
Support 16-bit grayscale
1 parent dc66ed0 commit 7cccfb3

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

src/_image_resample.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,34 @@ template <> class type_mapping<float>
647647
};
648648

649649

650+
template <> class type_mapping<unsigned short>
651+
{
652+
public:
653+
typedef agg::gray16 color_type;
654+
typedef agg::blender_gray<color_type> blender_type;
655+
typedef agg::pixfmt_alpha_blend_gray<blender_type, agg::rendering_buffer> pixfmt_type;
656+
typedef pixfmt_type pixfmt_pre_type;
657+
658+
template <typename A>
659+
struct span_gen_affine_type
660+
{
661+
typedef agg::span_image_resample_gray_affine<A> type;
662+
};
663+
664+
template <typename A, typename B>
665+
struct span_gen_filter_type
666+
{
667+
typedef agg::span_image_filter_gray<A, B> type;
668+
};
669+
670+
template <typename A, typename B>
671+
struct span_gen_nn_type
672+
{
673+
typedef agg::span_image_filter_gray_nn<A, B> type;
674+
};
675+
};
676+
677+
650678
template <> class type_mapping<unsigned char>
651679
{
652680
public:

src/_image_wrapper.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,19 @@ image_resample(PyObject *self, PyObject* args, PyObject *kwargs)
303303
params);
304304
Py_END_ALLOW_THREADS
305305
break;
306+
case NPY_UINT16:
307+
case NPY_INT16:
308+
Py_BEGIN_ALLOW_THREADS
309+
resample(
310+
(unsigned short *)PyArray_DATA(input_array),
311+
PyArray_DIM(input_array, 1),
312+
PyArray_DIM(input_array, 0),
313+
(unsigned short *)PyArray_DATA(output_array),
314+
PyArray_DIM(output_array, 1),
315+
PyArray_DIM(output_array, 0),
316+
params);
317+
Py_END_ALLOW_THREADS
318+
break;
306319
default:
307320
PyErr_SetString(PyExc_ValueError, "Unsupported dtype");
308321
goto error;

0 commit comments

Comments
 (0)