diff --git a/floatimg/image.py b/floatimg/image.py index 2c01099..9b0022f 100644 --- a/floatimg/image.py +++ b/floatimg/image.py @@ -176,6 +176,9 @@ c_fimg_load_from_png = LIB.fimg_load_from_png c_fimg_load_from_png.argtypes = (ct.c_char_p, ct.POINTER(C_FloatImg)) c_fimg_load_from_png.restype = ct.c_int +c_fimg_get_maxvalue = LIB.fimg_get_maxvalue +c_fimg_get_maxvalue.argtypes = (ct.POINTER(C_FloatImg),) +c_fimg_get_maxvalue.restype = ct.c_float ############################################################################################################ class FloatImg: @@ -337,6 +340,11 @@ class FloatImg: == 0 ) + ####################################################################################################### + def maxvalue(self): + """return the maximum value for any channel in the image""" + return c_fimg_get_maxvalue(self.c_img_p) + ########################################################################################################### def fileinfos(fname): diff --git a/tests/maths.py b/tests/maths.py new file mode 100644 index 0000000..c5b1c15 --- /dev/null +++ b/tests/maths.py @@ -0,0 +1,12 @@ +"""test of core functions """ + +import floatimg + +def test_maxvaalue(): + width = 5 + height = 5 + + img = floatimg.create_rgb(width, height) + color = (255.0, 255.0, 255.0) + img.put(2,2, color) + assert img.maxvalue() == 255.0ls