move some properties to attributes as they're not supposed to change

This commit is contained in:
Mutah 2021-05-12 13:36:37 +02:00
parent 1d4e2242cd
commit 6fccc1b6cf
1 changed files with 15 additions and 7 deletions

View File

@ -126,22 +126,24 @@ class FloatImg:
""" """
# proxy attributes to the C_FloatImg structure # proxy attributes to the C_FloatImg structure
# TODO: now more about them
magic = property(lambda self: self.c_img.magic) magic = property(lambda self: self.c_img.magic)
width = property(lambda self: self.c_img.width)
height = property(lambda self: self.c_img.height)
type_id = property(lambda self: self.c_img.type)
fval = property(lambda self: self.c_img.fval) fval = property(lambda self: self.c_img.fval)
count = property(lambda self: self.c_img.count) count = property(lambda self: self.c_img.count)
# oh yeah, really really sluggish access to pixels img.R[0].contents # oh yeah, really really sluggish access to pixels img.R[0].contents
# however, pixel data are not designed to be accessed this way # however, pixel data are not designed to be accessed this way
R = property( # R = property(
lambda self: pointer(self.c_img.contents.R)[: self.width * self.height] # lambda self: pointer(self.c_img.contents.R)[: self.width * self.height]
) # )
####################################################################################################### #######################################################################################################
def __init__(self, c_img): def __init__(self, c_img):
self.c_img = c_img self.c_img = c_img
self.width = c_img.width
self.height = c_img.height
self.type_id = c_img.type
# convenient pointer for later calls to C library
self.c_img_p = ct.pointer(c_img) self.c_img_p = ct.pointer(c_img)
####################################################################################################### #######################################################################################################
@ -160,7 +162,7 @@ class FloatImg:
####################################################################################################### #######################################################################################################
def clear(self): def clear(self):
"""clear data""" """clear data"""
return c_fimg_clear(self.c_img_p) assert c_fimg_clear(self.c_img_p) == 0
####################################################################################################### #######################################################################################################
def clone(self, flags=0): def clone(self, flags=0):
@ -220,6 +222,12 @@ class FloatImg:
== 0 == 0
) )
# TODO
# fimg_plot_rgb
# fimg_add_rgb
# export(fname, flags) : depending file extension, save to the correct format
########################################################################################################### ###########################################################################################################
def fileinfos(fname): def fileinfos(fname):