[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[pygame] Unexpect blit behavior when using BLEND_ADD



I was trying out BLEND_ADD with blit to see if an alpha plane could be added to a surface with alpha's zero. Here is the trial session:

Python 2.4.4 (#71, Oct 18 2006, 08:34:43) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pygame
>>> pygame.version.ver
'1.8.1pre'
>>> s = pygame.Surface((10, 20), pygame.SRCALPHA, 32)
>>> alpha = pygame.Surface((10, 20), pygame.SRCALPHA, 32)
>>> s.fill((10, 20, 30, 0))
<rect(0, 0, 10, 20)>
>>> s.get_at((5, 5))
(10, 20, 30, 0)
>>> alpha.fill((0, 0, 0, 64))
<rect(0, 0, 10, 20)>
>>> alpha.get_at((5, 5))
(0, 0, 0, 64)
>>> s.blit(alpha, (0, 0), None, pygame.BLEND_ADD)
<rect(0, 0, 10, 20)>
>>> s.get_at((5, 5))
(0, 0, 0, 64)

I expected a (10, 20, 30, 64) but got (0, 0, 0, 64) instead. What is happening here? The result is identical to a normal blit:

>>> s = pygame.Surface((10, 20), pygame.SRCALPHA, 32)
>>> s.fill((10, 20, 30, 0))
<rect(0, 0, 10, 20)>
>>> s.blit(alpha, (0, 0))
<rect(0, 0, 10, 20)>
>>> s.get_at((5, 5))
(0, 0, 0, 64)



--
Lenard Lindstrom
<len-l@xxxxxxxxx>