Skip to content

Commit

Permalink
Fix offsets in byref
Browse files Browse the repository at this point in the history
  • Loading branch information
dev7355608 committed Sep 18, 2017
1 parent 6ea48b9 commit 208efea
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
8 changes: 4 additions & 4 deletions gamma/gamma_quartz.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ctypes import byref, c_float, c_uint32, cdll
from ctypes import byref, sizeof, c_float, c_uint32, cdll
from ctypes.util import find_library


Expand Down Expand Up @@ -61,9 +61,9 @@ def set(self, func):
for i in range(ramp_size):
ramp[0][i] = ramp[1][i] = ramp[2][i] = func(i / ramp_size)

gamma_r = byref(ramp, 0 * ramp_size)
gamma_g = byref(ramp, 1 * ramp_size)
gamma_b = byref(ramp, 2 * ramp_size)
gamma_r = byref(ramp, 0 * ramp_size * sizeof(c_float))
gamma_g = byref(ramp, 1 * ramp_size * sizeof(c_float))
gamma_b = byref(ramp, 2 * ramp_size * sizeof(c_float))

error = CGSetDisplayTransferByTable(display.id, display.ramp_size,
gamma_r, gamma_g, gamma_b)
Expand Down
18 changes: 9 additions & 9 deletions gamma/gamma_vidmode.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ def __init__(self):

ramp = (c_ushort * ramp_size * 3)()

gamma_r = byref(ramp, 0 * ramp_size)
gamma_g = byref(ramp, 1 * ramp_size)
gamma_b = byref(ramp, 2 * ramp_size)
gamma_r = byref(ramp, 0 * ramp_size * sizeof(c_ushort))
gamma_g = byref(ramp, 1 * ramp_size * sizeof(c_ushort))
gamma_b = byref(ramp, 2 * ramp_size * sizeof(c_ushort))

if not XF86VidModeGetGammaRamp(display, screen_num, ramp_size,
gamma_r, gamma_g, gamma_b):
Expand All @@ -77,9 +77,9 @@ def set(self, func):
ramp[0][i] = ramp[1][i] = ramp[2][i] = \
int(C_USHORT_MAX * func(i / ramp_size))

gamma_r = byref(ramp, 0 * ramp_size)
gamma_g = byref(ramp, 1 * ramp_size)
gamma_b = byref(ramp, 2 * ramp_size)
gamma_r = byref(ramp, 0 * ramp_size * sizeof(c_ushort))
gamma_g = byref(ramp, 1 * ramp_size * sizeof(c_ushort))
gamma_b = byref(ramp, 2 * ramp_size * sizeof(c_ushort))

if not XF86VidModeSetGammaRamp(display, screen_num, ramp_size,
gamma_r, gamma_g, gamma_b):
Expand All @@ -93,9 +93,9 @@ def close(self):
ramp_size = self._ramp_size
ramp = self._saved_ramp

gamma_r = byref(ramp, 0 * ramp_size)
gamma_g = byref(ramp, 1 * ramp_size)
gamma_b = byref(ramp, 2 * ramp_size)
gamma_r = byref(ramp, 0 * ramp_size * sizeof(c_ushort))
gamma_g = byref(ramp, 1 * ramp_size * sizeof(c_ushort))
gamma_b = byref(ramp, 2 * ramp_size * sizeof(c_ushort))

if not XF86VidModeSetGammaRamp(display, screen_num, ramp_size,
gamma_r, gamma_g, gamma_b):
Expand Down

0 comments on commit 208efea

Please sign in to comment.