title: PyGame: Applying transparency to an image with alpha?
body: <p>I want to display <a href="http://8bitboobs.com/stuff/alpha.png" rel="nofollow noreferrer">an image with alpha</a> with a specified transparency, but can't figure out how to do it.</p>
  
  <p>To elaborate on how I'm struggling with this, the blurb below is a slightly modified hunk of code from <a href="https://stackoverflow.com/questions/12255558/how-to-use-pygame-set-alpha-on-a-picture#answer-12271210">this SO answer</a>, but if you run it, you'll see that "image" loses it's native alpha, while the alpha of "image2" never changes!  Yuck.</p>
  
  <pre><code>#!/usr/bin/env python
  
  import pygame, sys
  
  pygame.init()
  
  window = pygame.display.set_mode((200, 200))
  background = pygame.Surface((window.get_size()))
  background.fill((255, 255, 255))
  image = image2 = pygame.image.load('alpha.png')
  
  image = image.convert()
  rect = image.get_rect()
  
  image2 = image2.convert_alpha()
  rect2 = image2.get_rect()
  
  rect2.left = rect.width + 1
  
  i = 0
  while True:
    for event in pygame.event.get():
      if event.type == 12:
        pygame.quit()
        sys.exit()
  
    image.set_alpha(i)
    image2.set_alpha(i)
  
    window.fill((255, 255, 255))
    window.blit(background, background.get_rect())
    window.blit(image, rect)
    window.blit(image2, rect2)
  
    if i == 255:
      i = 0
    else:
      i += 1
  
    pygame.display.update()
    pygame.time.Clock().tick(60)
  </code></pre>
  
  <p>So ... how is it done?</p>