Skip to content

Instantly share code, notes, and snippets.

@dahlia
Created March 4, 2013 12:00
Show Gist options
  • Save dahlia/5081821 to your computer and use it in GitHub Desktop.
Save dahlia/5081821 to your computer and use it in GitHub Desktop.
Wand experiments with PixelGet{Red,Green,Blue,Alpha}Quantum() functions
import ctypes
from wand.api import library
from wand.color import Color
library.PixelGetRedQuantum.argtypes = [ctypes.c_void_p]
library.PixelGetRedQuantum.restype = ctypes.c_size_t
library.PixelGetGreenQuantum.argtypes = [ctypes.c_void_p]
library.PixelGetGreenQuantum.restype = ctypes.c_size_t
library.PixelGetBlueQuantum.argtypes = [ctypes.c_void_p]
library.PixelGetBlueQuantum.restype = ctypes.c_size_t
library.PixelGetAlphaQuantum.argtypes = [ctypes.c_void_p]
library.PixelGetAlphaQuantum.restype = ctypes.c_size_t
with Color('#ff0088') as c:
print (c.red, c.green, c.blue, c.alpha)
# Prints: (1.0, 0.0, 0.5333333333333333, 1.0)
print (
library.PixelGetRedQuantum(c.resource),
library.PixelGetGreenQuantum(c.resource),
library.PixelGetBlueQuantum(c.resource),
library.PixelGetAlphaQuantum(c.resource),
)
# Prints: (65535L, 0L, 34952L, 65535L)
@dahlia
Copy link
Author

dahlia commented Mar 4, 2013

@inactivist Thanks for your surveys.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment