#!/usr/bin/env python

'''Test L load using the platform decoder (QuickTime, Quartz, GDI+ or Gdk).
You should see the l.png image on a checkboard background.
'''

__docformat__ = 'restructuredtext'
__version__ = '$Id$'

import unittest
import base_load
from pyglet import compat_platform

if compat_platform.startswith('linux'):
    from pyglet.image.codecs.gdkpixbuf2 import GdkPixbuf2ImageDecoder as dclass
elif compat_platform in ('win32', 'cygwin'):
    from pyglet.image.codecs.gdiplus import GDIPlusDecoder as dclass
elif compat_platform == 'darwin':
    from pyglet import options as pyglet_options
    if pyglet_options['darwin_cocoa']:
        from pyglet.image.codecs.quartz import QuartzImageDecoder as dclass
    else:
        from pyglet.image.codecs.quicktime import QuickTimeImageDecoder as dclass

class TEST_PLATFORM_L_LOAD(base_load.TestLoad):
    texture_file = 'l.png'
    decoder = dclass()

if __name__ == '__main__':
    unittest.main()
    from pyglet.window import Window
    _shadow_window = Window(width=1, height=1, visible=False)
    _shadow_window.switch_to()

    from pyglet import app
    app.windows.remove(_shadow_window)


from pyglet import compat_platform
from base import ObjectSpace, CanvasConfig, Context
if _is_epydoc:
    from base import Config
elif compat_platform in ('win32', 'cygwin'):
    from win32 import Win32Config as Config
elif compat_platform.startswith('linux'):
    from xlib import XlibConfig as Config
elif compat_platform == 'darwin':
    if _pyglet.options['darwin_cocoa']:
        from cocoa import CocoaConfig as Config
    else:
        from carbon import CarbonConfig as Config
del base

# XXX remove
_shadow_window = None

# Import pyglet.window now if it isn't currently being imported (this creates
# the shadow window).
if (not _is_epydoc and 'pyglet.window' not in _sys.modules
        and _pyglet.options['shadow_window']):
Beispiel #3
0
def add_default_image_codecs():
    # Add the codecs we know about.  These should be listed in order of
    # preference.  This is called automatically by pyglet.image.

    # Compressed texture in DDS format
    try:
        from pyglet.image.codecs import dds
        add_encoders(dds)
        add_decoders(dds)
    except ImportError:
        pass

    # Mac OS X default: Quartz
    if compat_platform == 'darwin':
        try:
            from pyglet.image.codecs import quartz
            add_encoders(quartz)
            add_decoders(quartz)
        except ImportError:
            pass

    # Windows XP default: GDI+
    if compat_platform in ('win32', 'cygwin'):
        try:
            from pyglet.image.codecs import gdiplus
            add_encoders(gdiplus)
            add_decoders(gdiplus)
        except ImportError:
            pass

    # Linux default: GdkPixbuf 2.0
    if compat_platform.startswith('linux'):
        try:
            from pyglet.image.codecs import gdkpixbuf2
            add_encoders(gdkpixbuf2)
            add_decoders(gdkpixbuf2)
        except ImportError:
            pass

    # Fallback: PIL
    try:
        from pyglet.image.codecs import pil
        add_encoders(pil)
        add_decoders(pil)
    except ImportError:
        pass

    # Fallback: PNG loader (slow)
    try:
        from pyglet.image.codecs import png
        add_encoders(png)
        add_decoders(png)
    except ImportError:
        pass

    # Fallback: BMP loader (slow)
    try:
        from pyglet.image.codecs import bmp
        add_encoders(bmp)
        add_decoders(bmp)
    except ImportError:
        pass
Beispiel #4
0
def add_default_image_codecs():
    # Add the codecs we know about.  These should be listed in order of
    # preference.  This is called automatically by pyglet.image.

    # Compressed texture in DDS format
    try:
        from pyglet.image.codecs import dds
        add_encoders(dds)
        add_decoders(dds)
    except ImportError:
        pass

    # Mac OS X default: Quicktime for Carbon, Quartz for Cocoa.
    # TODO: Make ctypes Quartz the default for both Carbon & Cocoa.
    if compat_platform == 'darwin':
        try:
            from pyglet import options as pyglet_options
            if pyglet_options['darwin_cocoa']:
                import pyglet.image.codecs.quartz
                add_encoders(quartz)
                add_decoders(quartz)
            else:
                import pyglet.image.codecs.quicktime
                add_encoders(quicktime)
                add_decoders(quicktime)
        except ImportError:
            pass

    # Windows XP default: GDI+
    if compat_platform in ('win32', 'cygwin'):
        try:
            import pyglet.image.codecs.gdiplus
            add_encoders(gdiplus)
            add_decoders(gdiplus)
        except ImportError:
            pass

    # Linux default: GdkPixbuf 2.0
    if compat_platform.startswith('linux'):
        try:
            import pyglet.image.codecs.gdkpixbuf2
            add_encoders(gdkpixbuf2)
            add_decoders(gdkpixbuf2)
        except ImportError:
            pass

    # Fallback: PIL
    try:
        import pyglet.image.codecs.pil
        add_encoders(pil)
        add_decoders(pil)
    except ImportError:
        pass

    # Fallback: PNG loader (slow)
    try:
        import pyglet.image.codecs.png
        add_encoders(png)
        add_decoders(png)
    except ImportError:
        pass

    # Fallback: BMP loader (slow)
    try:
        import pyglet.image.codecs.bmp
        add_encoders(bmp)
        add_decoders(bmp)
    except ImportError:
        pass
Beispiel #5
0
    _shadow_window = Window(width=1, height=1, visible=False)
    _shadow_window.switch_to()

    from pyglet import app

    app.windows.remove(_shadow_window)


from pyglet import compat_platform
from base import ObjectSpace, CanvasConfig, Context

if _is_epydoc:
    from base import Config
elif compat_platform in ("win32", "cygwin"):
    from win32 import Win32Config as Config
elif compat_platform.startswith("linux"):
    from xlib import XlibConfig as Config
elif compat_platform == "darwin":
    if _pyglet.options["darwin_cocoa"]:
        from cocoa import CocoaConfig as Config
    else:
        from carbon import CarbonConfig as Config
del base

# XXX remove
_shadow_window = None

# Import pyglet.window now if it isn't currently being imported (this creates
# the shadow window).
if not _is_epydoc and "pyglet.window" not in _sys.modules and _pyglet.options["shadow_window"]:
    # trickery is for circular import
def add_default_codecs():
    # Add the codecs we know about.  These should be listed in order of
    # preference.  This is called automatically by pyglet.image.

    # Compressed texture in DDS format
    try:
        from pyglet.image.codecs import dds
        registry.add_encoders(dds)
        registry.add_decoders(dds)
    except ImportError:
        pass

    # Mac OS X default: Quartz
    if compat_platform == 'darwin':
        try:
            from pyglet.image.codecs import quartz
            registry.add_encoders(quartz)
            registry.add_decoders(quartz)
        except ImportError:
            pass

    # Windows 7 default: Windows Imaging Component
    if compat_platform in ('win32', 'cygwin'):
        from pyglet.libs.win32.constants import WINDOWS_7_OR_GREATER
        if WINDOWS_7_OR_GREATER:  # Supports Vista and above.
            try:
                from pyglet.image.codecs import wic
                registry.add_encoders(wic)
                registry.add_decoders(wic)
            except ImportError:
                pass

    # Windows XP default: GDI+
    if compat_platform in ('win32', 'cygwin'):
        try:
            from pyglet.image.codecs import gdiplus
            registry.add_encoders(gdiplus)
            registry.add_decoders(gdiplus)
        except ImportError:
            pass

    # Linux default: GdkPixbuf 2.0
    if compat_platform.startswith('linux'):
        try:
            from pyglet.image.codecs import gdkpixbuf2
            registry.add_encoders(gdkpixbuf2)
            registry.add_decoders(gdkpixbuf2)
        except ImportError:
            pass

    # Fallback: PIL
    try:
        from pyglet.image.codecs import pil
        registry.add_encoders(pil)
        registry.add_decoders(pil)
    except ImportError:
        pass

    # Fallback: PNG loader (slow)
    try:
        from pyglet.image.codecs import png
        registry.add_encoders(png)
        registry.add_decoders(png)
    except ImportError:
        pass

    # Fallback: BMP loader (slow)
    try:
        from pyglet.image.codecs import bmp
        registry.add_encoders(bmp)
        registry.add_decoders(bmp)
    except ImportError:
        pass