Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/src/api/Image.py
blob: 3b3ce7f9a995532718064a4b65d77e1f3c2bb2b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# -*- coding: utf-8 -*-

import pygame

# ------------------------------------------------------------------------------
# loadImage().
# Loads an image.
#
# Parameters:
# aImageFilename: Image file path to load.
# aIsTransparent: If the image is transparent (True) or not (True, by default).
#
# Returns: The loaded image. 
# ------------------------------------------------------------------------------
def loadImage(aImageFilename, aIsTransparent = True):

    try:
        image = pygame.image.load(aImageFilename)
    except pygame.error, message:
        raise SystemExit, message

    if aIsTransparent:
        image = image.convert_alpha()

        # TODO: This is doubt... (taken from a tutorial), don't work?
        #image = image.convert()
        #esto obtiene el color del pixel 0, 0
        #color = image.get_at((0,0))
        #image.set_colorkey(color, RLEACCEL)
    else:
        image = image.convert()
        
    return image