Beispiel #1
0
import ctypes
from api.functions import image, main
from api import api, const
from api.types import ExceptionType, size_t
import color
api.register_all(image)
api.register_all(main)


class Image(object):
    ''' Represents a single image, supported by a MagickWand.'''
    def __init__(self, image=None, type=None):
        self._wand = api.NewMagickWand()
        if image is not None: self.read(image, type)
        #else: self.create( 100, 100, type )

    def __del__(self):
        if self._wand:
            self._wand = api.DestroyMagickWand(self._wand)

    def __copy__(self):
        c = Image()
        if self._wand:
            c._wand = api.CloneMagickWand(self._wand)
        return c

    def _clear(self):
        api.ClearMagickWand(self._wand)

    def read(self, image, type=None):
        self._clear()
Beispiel #2
0
import ctypes
from api.functions import image
from api import api, const
from api.types import ExceptionType
import color
api.register_all(image)


class Image(object):
    ''' Represents a single image, supported by a MagickWand.'''
    def __init__(self, image=None, type=None):
        self._wand = api.NewMagickWand()
        if image is not None: self.read(image, type)
        #else: self.create( 100, 100, type )

    def __del__(self):
        if self._wand:
            self._wand = api.DestroyMagickWand(self._wand)

    def __copy__(self):
        c = Image()
        if self._wand:
            c._wand = api.CloneMagickWand(self._wand)
        return c

    def _clear(self):
        api.ClearMagickWand(self._wand)

    def read(self, image, type=None):
        self._clear()
        if type:
Beispiel #3
0
import ctypes
from api.functions import image, main
from api import api, const
from api.types import ExceptionType, size_t
import color
api.register_all( image )
api.register_all( main )

class Image( object ):
    ''' Represents a single image, supported by a MagickWand.'''

    def __init__( self, image = None, type = None ):
        self._wand = api.NewMagickWand()
        if image is not None: self.read( image, type )
        #else: self.create( 100, 100, type )

    def __del__( self ):
        if self._wand:
            self._wand = api.DestroyMagickWand( self._wand )

    def __copy__( self ):
        c = Image()
        if self._wand:
            c._wand = api.CloneMagickWand( self._wand )
        return c

    def _clear( self ):
        api.ClearMagickWand( self._wand )

    def read( self, image, type = None ):
        self._clear()
Beispiel #4
0
from api import api
from api.functions import pixel
api.register_all(pixel)


class Color(object):
    ''' Represents a color, supported by a PixelWand. '''
    def __init__(self, color=None):
        ''' Create a color.  The specified color can be a name or string
            representation of a color.  Acceptable values can be found in the
            ImageMagick documentation at

                http://www.imagemagick.org/script/color.php.
        '''

        self._wand = api.NewPixelWand()

        if color:
            api.PixelSetColor(self._wand, color)

    def __del__(self):
        if self._wand and api:
            self._wand = api.DestroyPixelWand(self._wand)

    def __eq__(self, other):
        ''' Two colors are equal only if they share the same normalised color
            and alpha values.'''
        return api.IsPixelWandSimilar( self._wand, other._wand, 0 )\
            and api.PixelGetAlpha( self._wand ) == api.PixelGetAlpha( other._wand )

    def __ne__(self, other):
Beispiel #5
0
from api import api
from api.functions import pixel
api.register_all( pixel )

class Color( object ):
    ''' Represents a color, supported by a PixelWand. '''

    def __init__( self, color = None ):
        ''' Create a color.  The specified color can be a name or string
            representation of a color.  Acceptable values can be found in the
            ImageMagick documentation at

                http://www.imagemagick.org/script/color.php.
        '''

        self._wand = api.NewPixelWand()

        if color:
            api.PixelSetColor( self._wand, color )

    def __del__( self ):
        if self._wand and api:
            self._wand = api.DestroyPixelWand( self._wand )

    def __eq__( self, other ):
        ''' Two colors are equal only if they share the same normalised color
            and alpha values.'''
        return api.IsPixelWandSimilar( self._wand, other._wand, 0 )\
            and api.PixelGetAlpha( self._wand ) == api.PixelGetAlpha( other._wand )

    def __ne__( self, other ):