diff options
| author | Mattias Andrée <maandree@operamail.com> | 2014-02-23 11:02:51 +0100 | 
|---|---|---|
| committer | Mattias Andrée <maandree@operamail.com> | 2014-02-23 11:02:51 +0100 | 
| commit | 8374fdcafbc649455333d470ea5b1be1f1549e4d (patch) | |
| tree | 54f00ab2f36e26d2f1bb87e05ccfe260ff7ec907 /src | |
| parent | m doc (diff) | |
| download | blueshift-8374fdcafbc649455333d470ea5b1be1f1549e4d.tar.gz blueshift-8374fdcafbc649455333d470ea5b1be1f1549e4d.tar.bz2 blueshift-8374fdcafbc649455333d470ea5b1be1f1549e4d.tar.xz | |
cython side of reading curves
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
| -rw-r--r-- | src/blueshift_randr.pyx | 23 | ||||
| -rw-r--r-- | src/blueshift_vidmode.pyx | 24 | 
2 files changed, 47 insertions, 0 deletions
| diff --git a/src/blueshift_randr.pyx b/src/blueshift_randr.pyx index a289c83..76a6f86 100644 --- a/src/blueshift_randr.pyx +++ b/src/blueshift_randr.pyx @@ -20,6 +20,7 @@ from libc.stdlib cimport malloc, free  cdef extern int blueshift_randr_open(int use_screen) +cdef extern unsigned short int* blueshift_randr_read(int use_crtc)  cdef extern int blueshift_randr_apply(unsigned long long int use_crtcs,                                        unsigned short int* r_curve,                                        unsigned short int* g_curve, @@ -37,6 +38,28 @@ def randr_open(int use_screen):      return blueshift_randr_open(use_screen) +def randr_read(int use_crtc): +    ''' +    Gets the current colour curves +     +    @param   use_crtc                                  The CRTC to use +    @return  :(r:list<int>, g:list<int>, b:list<int>)  The current red, green and blue colour curves +    ''' +    cdef unsigned short int* got +    got = blueshift_randr_read(use_crtc) +    if got is NULL: +        raise Exception() +    r, g, b, i = [], [], [], 0 +    for c in (r, g, b): +        s = got[i] +        i += 1 +        for j in range(s): +            c.append(s[i + j]) +        i += s +    free(got) +    return (r, g, b) + +  def randr_apply(unsigned long long use_crtcs, r_curve, g_curve, b_curve):      '''      Apply stage of colour curve control diff --git a/src/blueshift_vidmode.pyx b/src/blueshift_vidmode.pyx index 7d29655..ac7c6c1 100644 --- a/src/blueshift_vidmode.pyx +++ b/src/blueshift_vidmode.pyx @@ -20,6 +20,7 @@ from libc.stdlib cimport malloc, free  cdef extern int blueshift_vidmode_open(int use_screen) +cdef extern unsigned short int* blueshift_vidmode_read(int use_crtc)  cdef extern int blueshift_vidmode_apply(unsigned long long int use_crtcs,                                        unsigned short int* r_curve,                                        unsigned short int* g_curve, @@ -37,6 +38,29 @@ def vidmode_open(int use_screen):      return blueshift_vidmode_open(use_screen) +def vidmode_read(int use_crtc): +    ''' +    Gets the current colour curves +     +    @param   use_crtc                                  The CRTC to use +    @return  :(r:list<int>, g:list<int>, b:list<int>)  The current red, green and blue colour curves +    ''' +    cdef unsigned short int* got +    got = blueshift_vidmode_read(use_crtc) +    if got is NULL: +        raise Exception() +    r, g, b, i = [], [], [], 0 +    for c in (r, g, b): +        s = got[i] +        i += 1 +        for j in range(s): +            c.append(s[i + j]) +        i += s +    free(got) +    return (r, g, b) +     + +  def vidmode_apply(unsigned long long use_crtcs, r_curve, g_curve, b_curve):      '''      Apply stage of colour curve control | 
