Commits

Anonymous committed 37e90d2

surfarray alpha routines added

  • Participants
  • Parent commits 415f3ac

Comments (0)

Files changed (29)

 surface src/surface.c $(SDL)
 time src/time.c $(SDL)
 joystick src/joystick.c $(SDL)
+draw src/draw.c $(SDL)
 
 
 
 # BUG   = fixed a bug that was crashing
 
 Jan 25, 2001
+	added the draw module, with clipped line function
+	added alpha routines in surfarray module
+	more locking checks for surfarray
 	make extra sure all of SDL is shutdown properly
 
 Jan 24, 2001

File docs/index.html

 <a href=ref/pygame_constants.html>constants</a> || 
 <a href=ref/pygame_cursors.html>cursors</a> || 
 <a href=ref/pygame_display.html>display</a> || 
-<a href=ref/pygame_event.html>event</a> ||<br>
-|| <a href=ref/pygame_font.html>font</a> || 
+<a href=ref/pygame_draw.html>draw</a> ||<br>
+|| <a href=ref/pygame_event.html>event</a> || 
+<a href=ref/pygame_font.html>font</a> || 
 <a href=ref/pygame_image.html>image</a> || 
 <a href=ref/pygame_joystick.html>joystick</a> || 
 <a href=ref/pygame_key.html>key</a> || 
 <a href=ref/pygame_mixer.html>mixer</a> || 
-<a href=ref/pygame_mixer_music.html>mixer_music</a> || 
-<a href=ref/pygame_mouse.html>mouse</a> ||<br>
-|| <a href=ref/pygame_surfarray.html>surfarray</a> || 
+<a href=ref/pygame_mixer_music.html>mixer_music</a> ||<br>
+|| <a href=ref/pygame_mouse.html>mouse</a> || 
+<a href=ref/pygame_surfarray.html>surfarray</a> || 
 <a href=ref/pygame_time.html>time</a> || 
 <a href=ref/pygame_version.html>version</a> ||<br>
 

File docs/ref/CD.html

 <a href=pygame_constants.html>constants</a> || 
 <a href=pygame_cursors.html>cursors</a> || 
 <a href=pygame_display.html>display</a> || 
-<a href=pygame_event.html>event</a> ||<br>
-|| <a href=pygame_font.html>font</a> || 
+<a href=pygame_draw.html>draw</a> ||<br>
+|| <a href=pygame_event.html>event</a> || 
+<a href=pygame_font.html>font</a> || 
 <a href=pygame_image.html>image</a> || 
 <a href=pygame_joystick.html>joystick</a> || 
 <a href=pygame_key.html>key</a> || 
 <a href=pygame_mixer.html>mixer</a> || 
-<a href=pygame_mixer_music.html>mixer_music</a> || 
-<a href=pygame_mouse.html>mouse</a> ||<br>
-|| <a href=pygame_surfarray.html>surfarray</a> || 
+<a href=pygame_mixer_music.html>mixer_music</a> ||<br>
+|| <a href=pygame_mouse.html>mouse</a> || 
+<a href=pygame_surfarray.html>surfarray</a> || 
 <a href=pygame_time.html>time</a> || 
 <a href=pygame_version.html>version</a> ||<br>
 

File docs/ref/Channel.html

 <a href=pygame_constants.html>constants</a> || 
 <a href=pygame_cursors.html>cursors</a> || 
 <a href=pygame_display.html>display</a> || 
-<a href=pygame_event.html>event</a> ||<br>
-|| <a href=pygame_font.html>font</a> || 
+<a href=pygame_draw.html>draw</a> ||<br>
+|| <a href=pygame_event.html>event</a> || 
+<a href=pygame_font.html>font</a> || 
 <a href=pygame_image.html>image</a> || 
 <a href=pygame_joystick.html>joystick</a> || 
 <a href=pygame_key.html>key</a> || 
 <a href=pygame_mixer.html>mixer</a> || 
-<a href=pygame_mixer_music.html>mixer_music</a> || 
-<a href=pygame_mouse.html>mouse</a> ||<br>
-|| <a href=pygame_surfarray.html>surfarray</a> || 
+<a href=pygame_mixer_music.html>mixer_music</a> ||<br>
+|| <a href=pygame_mouse.html>mouse</a> || 
+<a href=pygame_surfarray.html>surfarray</a> || 
 <a href=pygame_time.html>time</a> || 
 <a href=pygame_version.html>version</a> ||<br>
 

File docs/ref/Font.html

 <a href=pygame_constants.html>constants</a> || 
 <a href=pygame_cursors.html>cursors</a> || 
 <a href=pygame_display.html>display</a> || 
-<a href=pygame_event.html>event</a> ||<br>
-|| <a href=pygame_font.html>font</a> || 
+<a href=pygame_draw.html>draw</a> ||<br>
+|| <a href=pygame_event.html>event</a> || 
+<a href=pygame_font.html>font</a> || 
 <a href=pygame_image.html>image</a> || 
 <a href=pygame_joystick.html>joystick</a> || 
 <a href=pygame_key.html>key</a> || 
 <a href=pygame_mixer.html>mixer</a> || 
-<a href=pygame_mixer_music.html>mixer_music</a> || 
-<a href=pygame_mouse.html>mouse</a> ||<br>
-|| <a href=pygame_surfarray.html>surfarray</a> || 
+<a href=pygame_mixer_music.html>mixer_music</a> ||<br>
+|| <a href=pygame_mouse.html>mouse</a> || 
+<a href=pygame_surfarray.html>surfarray</a> || 
 <a href=pygame_time.html>time</a> || 
 <a href=pygame_version.html>version</a> ||<br>
 

File docs/ref/Joystick.html

 <a href=pygame_constants.html>constants</a> || 
 <a href=pygame_cursors.html>cursors</a> || 
 <a href=pygame_display.html>display</a> || 
-<a href=pygame_event.html>event</a> ||<br>
-|| <a href=pygame_font.html>font</a> || 
+<a href=pygame_draw.html>draw</a> ||<br>
+|| <a href=pygame_event.html>event</a> || 
+<a href=pygame_font.html>font</a> || 
 <a href=pygame_image.html>image</a> || 
 <a href=pygame_joystick.html>joystick</a> || 
 <a href=pygame_key.html>key</a> || 
 <a href=pygame_mixer.html>mixer</a> || 
-<a href=pygame_mixer_music.html>mixer_music</a> || 
-<a href=pygame_mouse.html>mouse</a> ||<br>
-|| <a href=pygame_surfarray.html>surfarray</a> || 
+<a href=pygame_mixer_music.html>mixer_music</a> ||<br>
+|| <a href=pygame_mouse.html>mouse</a> || 
+<a href=pygame_surfarray.html>surfarray</a> || 
 <a href=pygame_time.html>time</a> || 
 <a href=pygame_version.html>version</a> ||<br>
 

File docs/ref/Rect.html

 <a href=pygame_constants.html>constants</a> || 
 <a href=pygame_cursors.html>cursors</a> || 
 <a href=pygame_display.html>display</a> || 
-<a href=pygame_event.html>event</a> ||<br>
-|| <a href=pygame_font.html>font</a> || 
+<a href=pygame_draw.html>draw</a> ||<br>
+|| <a href=pygame_event.html>event</a> || 
+<a href=pygame_font.html>font</a> || 
 <a href=pygame_image.html>image</a> || 
 <a href=pygame_joystick.html>joystick</a> || 
 <a href=pygame_key.html>key</a> || 
 <a href=pygame_mixer.html>mixer</a> || 
-<a href=pygame_mixer_music.html>mixer_music</a> || 
-<a href=pygame_mouse.html>mouse</a> ||<br>
-|| <a href=pygame_surfarray.html>surfarray</a> || 
+<a href=pygame_mixer_music.html>mixer_music</a> ||<br>
+|| <a href=pygame_mouse.html>mouse</a> || 
+<a href=pygame_surfarray.html>surfarray</a> || 
 <a href=pygame_time.html>time</a> || 
 <a href=pygame_version.html>version</a> ||<br>
 

File docs/ref/Sound.html

 <a href=pygame_constants.html>constants</a> || 
 <a href=pygame_cursors.html>cursors</a> || 
 <a href=pygame_display.html>display</a> || 
-<a href=pygame_event.html>event</a> ||<br>
-|| <a href=pygame_font.html>font</a> || 
+<a href=pygame_draw.html>draw</a> ||<br>
+|| <a href=pygame_event.html>event</a> || 
+<a href=pygame_font.html>font</a> || 
 <a href=pygame_image.html>image</a> || 
 <a href=pygame_joystick.html>joystick</a> || 
 <a href=pygame_key.html>key</a> || 
 <a href=pygame_mixer.html>mixer</a> || 
-<a href=pygame_mixer_music.html>mixer_music</a> || 
-<a href=pygame_mouse.html>mouse</a> ||<br>
-|| <a href=pygame_surfarray.html>surfarray</a> || 
+<a href=pygame_mixer_music.html>mixer_music</a> ||<br>
+|| <a href=pygame_mouse.html>mouse</a> || 
+<a href=pygame_surfarray.html>surfarray</a> || 
 <a href=pygame_time.html>time</a> || 
 <a href=pygame_version.html>version</a> ||<br>
 

File docs/ref/Surface.html

 <a href=pygame_constants.html>constants</a> || 
 <a href=pygame_cursors.html>cursors</a> || 
 <a href=pygame_display.html>display</a> || 
-<a href=pygame_event.html>event</a> ||<br>
-|| <a href=pygame_font.html>font</a> || 
+<a href=pygame_draw.html>draw</a> ||<br>
+|| <a href=pygame_event.html>event</a> || 
+<a href=pygame_font.html>font</a> || 
 <a href=pygame_image.html>image</a> || 
 <a href=pygame_joystick.html>joystick</a> || 
 <a href=pygame_key.html>key</a> || 
 <a href=pygame_mixer.html>mixer</a> || 
-<a href=pygame_mixer_music.html>mixer_music</a> || 
-<a href=pygame_mouse.html>mouse</a> ||<br>
-|| <a href=pygame_surfarray.html>surfarray</a> || 
+<a href=pygame_mixer_music.html>mixer_music</a> ||<br>
+|| <a href=pygame_mouse.html>mouse</a> || 
+<a href=pygame_surfarray.html>surfarray</a> || 
 <a href=pygame_time.html>time</a> || 
 <a href=pygame_version.html>version</a> ||<br>
 

File docs/ref/pygame.html

 <a href=pygame_constants.html>constants</a> || 
 <a href=pygame_cursors.html>cursors</a> || 
 <a href=pygame_display.html>display</a> || 
-<a href=pygame_event.html>event</a> ||<br>
-|| <a href=pygame_font.html>font</a> || 
+<a href=pygame_draw.html>draw</a> ||<br>
+|| <a href=pygame_event.html>event</a> || 
+<a href=pygame_font.html>font</a> || 
 <a href=pygame_image.html>image</a> || 
 <a href=pygame_joystick.html>joystick</a> || 
 <a href=pygame_key.html>key</a> || 
 <a href=pygame_mixer.html>mixer</a> || 
-<a href=pygame_mixer_music.html>mixer_music</a> || 
-<a href=pygame_mouse.html>mouse</a> ||<br>
-|| <a href=pygame_surfarray.html>surfarray</a> || 
+<a href=pygame_mixer_music.html>mixer_music</a> ||<br>
+|| <a href=pygame_mouse.html>mouse</a> || 
+<a href=pygame_surfarray.html>surfarray</a> || 
 <a href=pygame_time.html>time</a> || 
 <a href=pygame_version.html>version</a> ||<br>
 

File docs/ref/pygame_UserRect.html

 <a href=pygame_constants.html>constants</a> || 
 <a href=pygame_cursors.html>cursors</a> || 
 <a href=pygame_display.html>display</a> || 
-<a href=pygame_event.html>event</a> ||<br>
-|| <a href=pygame_font.html>font</a> || 
+<a href=pygame_draw.html>draw</a> ||<br>
+|| <a href=pygame_event.html>event</a> || 
+<a href=pygame_font.html>font</a> || 
 <a href=pygame_image.html>image</a> || 
 <a href=pygame_joystick.html>joystick</a> || 
 <a href=pygame_key.html>key</a> || 
 <a href=pygame_mixer.html>mixer</a> || 
-<a href=pygame_mixer_music.html>mixer_music</a> || 
-<a href=pygame_mouse.html>mouse</a> ||<br>
-|| <a href=pygame_surfarray.html>surfarray</a> || 
+<a href=pygame_mixer_music.html>mixer_music</a> ||<br>
+|| <a href=pygame_mouse.html>mouse</a> || 
+<a href=pygame_surfarray.html>surfarray</a> || 
 <a href=pygame_time.html>time</a> || 
 <a href=pygame_version.html>version</a> ||<br>
 

File docs/ref/pygame_cdrom.html

 <a href=pygame_constants.html>constants</a> || 
 <a href=pygame_cursors.html>cursors</a> || 
 <a href=pygame_display.html>display</a> || 
-<a href=pygame_event.html>event</a> ||<br>
-|| <a href=pygame_font.html>font</a> || 
+<a href=pygame_draw.html>draw</a> ||<br>
+|| <a href=pygame_event.html>event</a> || 
+<a href=pygame_font.html>font</a> || 
 <a href=pygame_image.html>image</a> || 
 <a href=pygame_joystick.html>joystick</a> || 
 <a href=pygame_key.html>key</a> || 
 <a href=pygame_mixer.html>mixer</a> || 
-<a href=pygame_mixer_music.html>mixer_music</a> || 
-<a href=pygame_mouse.html>mouse</a> ||<br>
-|| <a href=pygame_surfarray.html>surfarray</a> || 
+<a href=pygame_mixer_music.html>mixer_music</a> ||<br>
+|| <a href=pygame_mouse.html>mouse</a> || 
+<a href=pygame_surfarray.html>surfarray</a> || 
 <a href=pygame_time.html>time</a> || 
 <a href=pygame_version.html>version</a> ||<br>
 

File docs/ref/pygame_constants.html

 <a href=pygame_constants.html>constants</a> || 
 <a href=pygame_cursors.html>cursors</a> || 
 <a href=pygame_display.html>display</a> || 
-<a href=pygame_event.html>event</a> ||<br>
-|| <a href=pygame_font.html>font</a> || 
+<a href=pygame_draw.html>draw</a> ||<br>
+|| <a href=pygame_event.html>event</a> || 
+<a href=pygame_font.html>font</a> || 
 <a href=pygame_image.html>image</a> || 
 <a href=pygame_joystick.html>joystick</a> || 
 <a href=pygame_key.html>key</a> || 
 <a href=pygame_mixer.html>mixer</a> || 
-<a href=pygame_mixer_music.html>mixer_music</a> || 
-<a href=pygame_mouse.html>mouse</a> ||<br>
-|| <a href=pygame_surfarray.html>surfarray</a> || 
+<a href=pygame_mixer_music.html>mixer_music</a> ||<br>
+|| <a href=pygame_mouse.html>mouse</a> || 
+<a href=pygame_surfarray.html>surfarray</a> || 
 <a href=pygame_time.html>time</a> || 
 <a href=pygame_version.html>version</a> ||<br>
 

File docs/ref/pygame_cursors.html

 <a href=pygame_constants.html>constants</a> || 
 <a href=pygame_cursors.html>cursors</a> || 
 <a href=pygame_display.html>display</a> || 
-<a href=pygame_event.html>event</a> ||<br>
-|| <a href=pygame_font.html>font</a> || 
+<a href=pygame_draw.html>draw</a> ||<br>
+|| <a href=pygame_event.html>event</a> || 
+<a href=pygame_font.html>font</a> || 
 <a href=pygame_image.html>image</a> || 
 <a href=pygame_joystick.html>joystick</a> || 
 <a href=pygame_key.html>key</a> || 
 <a href=pygame_mixer.html>mixer</a> || 
-<a href=pygame_mixer_music.html>mixer_music</a> || 
-<a href=pygame_mouse.html>mouse</a> ||<br>
-|| <a href=pygame_surfarray.html>surfarray</a> || 
+<a href=pygame_mixer_music.html>mixer_music</a> ||<br>
+|| <a href=pygame_mouse.html>mouse</a> || 
+<a href=pygame_surfarray.html>surfarray</a> || 
 <a href=pygame_time.html>time</a> || 
 <a href=pygame_version.html>version</a> ||<br>
 

File docs/ref/pygame_display.html

 <a href=pygame_constants.html>constants</a> || 
 <a href=pygame_cursors.html>cursors</a> || 
 <a href=pygame_display.html>display</a> || 
-<a href=pygame_event.html>event</a> ||<br>
-|| <a href=pygame_font.html>font</a> || 
+<a href=pygame_draw.html>draw</a> ||<br>
+|| <a href=pygame_event.html>event</a> || 
+<a href=pygame_font.html>font</a> || 
 <a href=pygame_image.html>image</a> || 
 <a href=pygame_joystick.html>joystick</a> || 
 <a href=pygame_key.html>key</a> || 
 <a href=pygame_mixer.html>mixer</a> || 
-<a href=pygame_mixer_music.html>mixer_music</a> || 
-<a href=pygame_mouse.html>mouse</a> ||<br>
-|| <a href=pygame_surfarray.html>surfarray</a> || 
+<a href=pygame_mixer_music.html>mixer_music</a> ||<br>
+|| <a href=pygame_mouse.html>mouse</a> || 
+<a href=pygame_surfarray.html>surfarray</a> || 
 <a href=pygame_time.html>time</a> || 
 <a href=pygame_version.html>version</a> ||<br>
 

File docs/ref/pygame_event.html

 <a href=pygame_constants.html>constants</a> || 
 <a href=pygame_cursors.html>cursors</a> || 
 <a href=pygame_display.html>display</a> || 
-<a href=pygame_event.html>event</a> ||<br>
-|| <a href=pygame_font.html>font</a> || 
+<a href=pygame_draw.html>draw</a> ||<br>
+|| <a href=pygame_event.html>event</a> || 
+<a href=pygame_font.html>font</a> || 
 <a href=pygame_image.html>image</a> || 
 <a href=pygame_joystick.html>joystick</a> || 
 <a href=pygame_key.html>key</a> || 
 <a href=pygame_mixer.html>mixer</a> || 
-<a href=pygame_mixer_music.html>mixer_music</a> || 
-<a href=pygame_mouse.html>mouse</a> ||<br>
-|| <a href=pygame_surfarray.html>surfarray</a> || 
+<a href=pygame_mixer_music.html>mixer_music</a> ||<br>
+|| <a href=pygame_mouse.html>mouse</a> || 
+<a href=pygame_surfarray.html>surfarray</a> || 
 <a href=pygame_time.html>time</a> || 
 <a href=pygame_version.html>version</a> ||<br>
 

File docs/ref/pygame_font.html

 <a href=pygame_constants.html>constants</a> || 
 <a href=pygame_cursors.html>cursors</a> || 
 <a href=pygame_display.html>display</a> || 
-<a href=pygame_event.html>event</a> ||<br>
-|| <a href=pygame_font.html>font</a> || 
+<a href=pygame_draw.html>draw</a> ||<br>
+|| <a href=pygame_event.html>event</a> || 
+<a href=pygame_font.html>font</a> || 
 <a href=pygame_image.html>image</a> || 
 <a href=pygame_joystick.html>joystick</a> || 
 <a href=pygame_key.html>key</a> || 
 <a href=pygame_mixer.html>mixer</a> || 
-<a href=pygame_mixer_music.html>mixer_music</a> || 
-<a href=pygame_mouse.html>mouse</a> ||<br>
-|| <a href=pygame_surfarray.html>surfarray</a> || 
+<a href=pygame_mixer_music.html>mixer_music</a> ||<br>
+|| <a href=pygame_mouse.html>mouse</a> || 
+<a href=pygame_surfarray.html>surfarray</a> || 
 <a href=pygame_time.html>time</a> || 
 <a href=pygame_version.html>version</a> ||<br>
 

File docs/ref/pygame_image.html

 <a href=pygame_constants.html>constants</a> || 
 <a href=pygame_cursors.html>cursors</a> || 
 <a href=pygame_display.html>display</a> || 
-<a href=pygame_event.html>event</a> ||<br>
-|| <a href=pygame_font.html>font</a> || 
+<a href=pygame_draw.html>draw</a> ||<br>
+|| <a href=pygame_event.html>event</a> || 
+<a href=pygame_font.html>font</a> || 
 <a href=pygame_image.html>image</a> || 
 <a href=pygame_joystick.html>joystick</a> || 
 <a href=pygame_key.html>key</a> || 
 <a href=pygame_mixer.html>mixer</a> || 
-<a href=pygame_mixer_music.html>mixer_music</a> || 
-<a href=pygame_mouse.html>mouse</a> ||<br>
-|| <a href=pygame_surfarray.html>surfarray</a> || 
+<a href=pygame_mixer_music.html>mixer_music</a> ||<br>
+|| <a href=pygame_mouse.html>mouse</a> || 
+<a href=pygame_surfarray.html>surfarray</a> || 
 <a href=pygame_time.html>time</a> || 
 <a href=pygame_version.html>version</a> ||<br>
 

File docs/ref/pygame_joystick.html

 <a href=pygame_constants.html>constants</a> || 
 <a href=pygame_cursors.html>cursors</a> || 
 <a href=pygame_display.html>display</a> || 
-<a href=pygame_event.html>event</a> ||<br>
-|| <a href=pygame_font.html>font</a> || 
+<a href=pygame_draw.html>draw</a> ||<br>
+|| <a href=pygame_event.html>event</a> || 
+<a href=pygame_font.html>font</a> || 
 <a href=pygame_image.html>image</a> || 
 <a href=pygame_joystick.html>joystick</a> || 
 <a href=pygame_key.html>key</a> || 
 <a href=pygame_mixer.html>mixer</a> || 
-<a href=pygame_mixer_music.html>mixer_music</a> || 
-<a href=pygame_mouse.html>mouse</a> ||<br>
-|| <a href=pygame_surfarray.html>surfarray</a> || 
+<a href=pygame_mixer_music.html>mixer_music</a> ||<br>
+|| <a href=pygame_mouse.html>mouse</a> || 
+<a href=pygame_surfarray.html>surfarray</a> || 
 <a href=pygame_time.html>time</a> || 
 <a href=pygame_version.html>version</a> ||<br>
 

File docs/ref/pygame_key.html

 <a href=pygame_constants.html>constants</a> || 
 <a href=pygame_cursors.html>cursors</a> || 
 <a href=pygame_display.html>display</a> || 
-<a href=pygame_event.html>event</a> ||<br>
-|| <a href=pygame_font.html>font</a> || 
+<a href=pygame_draw.html>draw</a> ||<br>
+|| <a href=pygame_event.html>event</a> || 
+<a href=pygame_font.html>font</a> || 
 <a href=pygame_image.html>image</a> || 
 <a href=pygame_joystick.html>joystick</a> || 
 <a href=pygame_key.html>key</a> || 
 <a href=pygame_mixer.html>mixer</a> || 
-<a href=pygame_mixer_music.html>mixer_music</a> || 
-<a href=pygame_mouse.html>mouse</a> ||<br>
-|| <a href=pygame_surfarray.html>surfarray</a> || 
+<a href=pygame_mixer_music.html>mixer_music</a> ||<br>
+|| <a href=pygame_mouse.html>mouse</a> || 
+<a href=pygame_surfarray.html>surfarray</a> || 
 <a href=pygame_time.html>time</a> || 
 <a href=pygame_version.html>version</a> ||<br>
 

File docs/ref/pygame_mixer.html

 <a href=pygame_constants.html>constants</a> || 
 <a href=pygame_cursors.html>cursors</a> || 
 <a href=pygame_display.html>display</a> || 
-<a href=pygame_event.html>event</a> ||<br>
-|| <a href=pygame_font.html>font</a> || 
+<a href=pygame_draw.html>draw</a> ||<br>
+|| <a href=pygame_event.html>event</a> || 
+<a href=pygame_font.html>font</a> || 
 <a href=pygame_image.html>image</a> || 
 <a href=pygame_joystick.html>joystick</a> || 
 <a href=pygame_key.html>key</a> || 
 <a href=pygame_mixer.html>mixer</a> || 
-<a href=pygame_mixer_music.html>mixer_music</a> || 
-<a href=pygame_mouse.html>mouse</a> ||<br>
-|| <a href=pygame_surfarray.html>surfarray</a> || 
+<a href=pygame_mixer_music.html>mixer_music</a> ||<br>
+|| <a href=pygame_mouse.html>mouse</a> || 
+<a href=pygame_surfarray.html>surfarray</a> || 
 <a href=pygame_time.html>time</a> || 
 <a href=pygame_version.html>version</a> ||<br>
 

File docs/ref/pygame_mixer_music.html

 <a href=pygame_constants.html>constants</a> || 
 <a href=pygame_cursors.html>cursors</a> || 
 <a href=pygame_display.html>display</a> || 
-<a href=pygame_event.html>event</a> ||<br>
-|| <a href=pygame_font.html>font</a> || 
+<a href=pygame_draw.html>draw</a> ||<br>
+|| <a href=pygame_event.html>event</a> || 
+<a href=pygame_font.html>font</a> || 
 <a href=pygame_image.html>image</a> || 
 <a href=pygame_joystick.html>joystick</a> || 
 <a href=pygame_key.html>key</a> || 
 <a href=pygame_mixer.html>mixer</a> || 
-<a href=pygame_mixer_music.html>mixer_music</a> || 
-<a href=pygame_mouse.html>mouse</a> ||<br>
-|| <a href=pygame_surfarray.html>surfarray</a> || 
+<a href=pygame_mixer_music.html>mixer_music</a> ||<br>
+|| <a href=pygame_mouse.html>mouse</a> || 
+<a href=pygame_surfarray.html>surfarray</a> || 
 <a href=pygame_time.html>time</a> || 
 <a href=pygame_version.html>version</a> ||<br>
 

File docs/ref/pygame_mouse.html

 <a href=pygame_constants.html>constants</a> || 
 <a href=pygame_cursors.html>cursors</a> || 
 <a href=pygame_display.html>display</a> || 
-<a href=pygame_event.html>event</a> ||<br>
-|| <a href=pygame_font.html>font</a> || 
+<a href=pygame_draw.html>draw</a> ||<br>
+|| <a href=pygame_event.html>event</a> || 
+<a href=pygame_font.html>font</a> || 
 <a href=pygame_image.html>image</a> || 
 <a href=pygame_joystick.html>joystick</a> || 
 <a href=pygame_key.html>key</a> || 
 <a href=pygame_mixer.html>mixer</a> || 
-<a href=pygame_mixer_music.html>mixer_music</a> || 
-<a href=pygame_mouse.html>mouse</a> ||<br>
-|| <a href=pygame_surfarray.html>surfarray</a> || 
+<a href=pygame_mixer_music.html>mixer_music</a> ||<br>
+|| <a href=pygame_mouse.html>mouse</a> || 
+<a href=pygame_surfarray.html>surfarray</a> || 
 <a href=pygame_time.html>time</a> || 
 <a href=pygame_version.html>version</a> ||<br>
 

File docs/ref/pygame_surfarray.html

 <a href=pygame_constants.html>constants</a> || 
 <a href=pygame_cursors.html>cursors</a> || 
 <a href=pygame_display.html>display</a> || 
-<a href=pygame_event.html>event</a> ||<br>
-|| <a href=pygame_font.html>font</a> || 
+<a href=pygame_draw.html>draw</a> ||<br>
+|| <a href=pygame_event.html>event</a> || 
+<a href=pygame_font.html>font</a> || 
 <a href=pygame_image.html>image</a> || 
 <a href=pygame_joystick.html>joystick</a> || 
 <a href=pygame_key.html>key</a> || 
 <a href=pygame_mixer.html>mixer</a> || 
-<a href=pygame_mixer_music.html>mixer_music</a> || 
-<a href=pygame_mouse.html>mouse</a> ||<br>
-|| <a href=pygame_surfarray.html>surfarray</a> || 
+<a href=pygame_mixer_music.html>mixer_music</a> ||<br>
+|| <a href=pygame_mouse.html>mouse</a> || 
+<a href=pygame_surfarray.html>surfarray</a> || 
 <a href=pygame_time.html>time</a> || 
 <a href=pygame_version.html>version</a> ||<br>
 
 get a 3d array copied from a surface</td></tr>
 
 
+<tr><td><a href=#array_alpha>array_alpha</a></td><td> -
+get an array with a surface pixel alpha values</td></tr>
+
+
+<tr><td><a href=#array_colorkey>array_colorkey</a></td><td> -
+get an array with a surface colorkey values</td></tr>
+
+
 <tr><td><a href=#blit_array>blit_array</a></td><td> -
 quickly transfer an array to a Surface</td></tr>
 
 get a 3d reference array to a surface</td></tr>
 
 
+<tr><td><a href=#pixels_alpha>pixels_alpha</a></td><td> -
+get a reference array to a surface alpha data</td></tr>
+
+
 </table>
 
 <hr>
 outside of that loop.
 </ul><br>&nbsp;<br>
 
+<a name=array_alpha><font size=+2><b>array_alpha
+</b></font><br><font size=+1><tt>
+pygame.surfarray.array_alpha(Surface) -> Array
+</tt></font><ul>
+This returns a new contigous 2d array with the
+alpha values of an image as unsigned bytes. If the
+surface has no alpha, an array of all opaque values
+is returned.
+<br>&nbsp;<br>
+Some surfaces will require the surface to be locked for pixel access.
+If locking is needed and the surface is not locked, it will be temporarily
+locked in this function. If you will be calling this function many times
+in one loop, it is will be much better to lock and unlock the surface
+outside of that loop.
+</ul><br>&nbsp;<br>
+
+<a name=array_colorkey><font size=+2><b>array_colorkey
+</b></font><br><font size=+1><tt>
+pygame.surfarray.array_colorkey(Surface) -> Array
+</tt></font><ul>
+This returns a new contigous 2d array with the
+colorkey values of an image as unsigned bytes. If the
+surface has no colorkey, an array of all opaque values
+is returned. Otherwise the array is either 0's or 255's.
+<br>&nbsp;<br>
+Some surfaces will require the surface to be locked for pixel access.
+If locking is needed and the surface is not locked, it will be temporarily
+locked in this function. If you will be calling this function many times
+in one loop, it is will be much better to lock and unlock the surface
+outside of that loop.
+</ul><br>&nbsp;<br>
+
 <a name=blit_array><font size=+2><b>blit_array
 </b></font><br><font size=+1><tt>
 pygame.surfarray.blit_array(surf, array) -> None
 unlocked the surface.
 </ul><br>&nbsp;<br>
 
+<a name=pixels_alpha><font size=+2><b>pixels_alpha
+</b></font><br><font size=+1><tt>
+pygame.surfarray.pixels_alpha(Surface) -> Array
+</tt></font><ul>
+This returns a new noncontigous array that directly
+effects a Surface's alpha contents.
+<br>&nbsp;<br>
+This will only work for 32bit surfaces with a pixel
+alpha channel enabled.
+<br>&nbsp;<br>
+You'll need the surface to be locked if that is
+required. Also be aware that between unlocking and
+relocking a surface, the pixel data can be moved,
+so don't hang onto this array after you have
+unlocked the surface.
+</ul><br>&nbsp;<br>
+
 
 <hr>
 

File docs/ref/pygame_time.html

 <a href=pygame_constants.html>constants</a> || 
 <a href=pygame_cursors.html>cursors</a> || 
 <a href=pygame_display.html>display</a> || 
-<a href=pygame_event.html>event</a> ||<br>
-|| <a href=pygame_font.html>font</a> || 
+<a href=pygame_draw.html>draw</a> ||<br>
+|| <a href=pygame_event.html>event</a> || 
+<a href=pygame_font.html>font</a> || 
 <a href=pygame_image.html>image</a> || 
 <a href=pygame_joystick.html>joystick</a> || 
 <a href=pygame_key.html>key</a> || 
 <a href=pygame_mixer.html>mixer</a> || 
-<a href=pygame_mixer_music.html>mixer_music</a> || 
-<a href=pygame_mouse.html>mouse</a> ||<br>
-|| <a href=pygame_surfarray.html>surfarray</a> || 
+<a href=pygame_mixer_music.html>mixer_music</a> ||<br>
+|| <a href=pygame_mouse.html>mouse</a> || 
+<a href=pygame_surfarray.html>surfarray</a> || 
 <a href=pygame_time.html>time</a> || 
 <a href=pygame_version.html>version</a> ||<br>
 

File docs/ref/pygame_version.html

 <a href=pygame_constants.html>constants</a> || 
 <a href=pygame_cursors.html>cursors</a> || 
 <a href=pygame_display.html>display</a> || 
-<a href=pygame_event.html>event</a> ||<br>
-|| <a href=pygame_font.html>font</a> || 
+<a href=pygame_draw.html>draw</a> ||<br>
+|| <a href=pygame_event.html>event</a> || 
+<a href=pygame_font.html>font</a> || 
 <a href=pygame_image.html>image</a> || 
 <a href=pygame_joystick.html>joystick</a> || 
 <a href=pygame_key.html>key</a> || 
 <a href=pygame_mixer.html>mixer</a> || 
-<a href=pygame_mixer_music.html>mixer_music</a> || 
-<a href=pygame_mouse.html>mouse</a> ||<br>
-|| <a href=pygame_surfarray.html>surfarray</a> || 
+<a href=pygame_mixer_music.html>mixer_music</a> ||<br>
+|| <a href=pygame_mouse.html>mouse</a> || 
+<a href=pygame_surfarray.html>surfarray</a> || 
 <a href=pygame_time.html>time</a> || 
 <a href=pygame_version.html>version</a> ||<br>
 
+/*
+    pygame - Python Game Library
+    Copyright (C) 2000  Pete Shinners
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Pete Shinners
+    pete@shinners.org
+*/
+
+/*
+ *  drawing module for pygame
+ */
+#include "pygame.h"
+
+static int clipline(int* pts, int left, int top, int right, int bottom);
+static void drawline(SDL_Surface* surf, Uint32 color, int startx, int starty, int endx, int endy);
+static void drawhorzline(SDL_Surface* surf, Uint32 color, int startx, int starty, int endx, int endy);
+
+
+    /*DOC*/ static char doc_line[] =
+    /*DOC*/    "pygame.draw.line(Surface, color, startpos, endpos) -> Rect\n"
+    /*DOC*/    "draw a line on a surface\n"
+    /*DOC*/    "\n"
+    /*DOC*/    "Draws a line on a surface. This will respect the clipping\n"
+    /*DOC*/    "rectangle. A bounding box of the effected area is returned\n"
+    /*DOC*/    "as a rectangle.\n"
+    /*DOC*/    "\n"
+    /*DOC*/ ;
+
+static PyObject* line(PyObject* self, PyObject* arg)
+{
+	PyObject *surfobj, *colorobj, *start, *end;
+	SDL_Surface* surf;
+	short startx, starty, endx, endy;
+	int top, left, bottom, right;
+	int pts[4];
+	Uint8 rgba[4];
+	Uint32 color;
+	int didlock = 0;
+
+	/*get all the arguments*/
+	if(!PyArg_ParseTuple(arg, "O!OOO", &PySurface_Type, &surfobj, &colorobj, &start, &end))
+		return NULL;
+	surf = PySurface_AsSurface(surfobj);
+
+	if(surf->format->BytesPerPixel <= 0 || surf->format->BytesPerPixel > 4)
+		return RAISE(PyExc_ValueError, "unsupport bit depth for line draw");
+
+	if(!RGBAFromObj(colorobj, rgba))
+		return RAISE(PyExc_TypeError, "Invalid color RGB argument");
+	color = SDL_MapRGBA(surf->format, rgba[0], rgba[1], rgba[2], rgba[3]);
+
+	if(!TwoShortsFromObj(start, &startx, &starty))
+		return RAISE(PyExc_TypeError, "Invalid start position argument");
+	if(!TwoShortsFromObj(end, &endx, &endy))
+		return RAISE(PyExc_TypeError, "Invalid end position argument");
+	
+	/*clip line to the surface*/
+	pts[0] = startx; pts[1] = starty;
+	pts[2] = endx; pts[3] = endy;
+	if(!clipline(pts, surf->clip_rect.x, surf->clip_rect.y,
+				surf->clip_rect.x + surf->clip_rect.w - 1,
+				surf->clip_rect.y + surf->clip_rect.h - 1))
+		return PyRect_New4(startx, starty, 0, 0);
+
+	if(!surf->pixels)
+	{
+		if(SDL_LockSurface(surf) == -1)
+			return RAISE(PyExc_SDLError, SDL_GetError());
+		didlock = 1;
+	}
+
+	/*a nice help would be horizontal and vertical drawers too*/
+	if(pts[1] == pts[3])
+		drawhorzline(surf, color, pts[0], pts[1], pts[2], pts[3]);
+	else
+		drawline(surf, color, pts[0], pts[1], pts[2], pts[3]);
+
+	if(didlock)
+		SDL_UnlockSurface(surf);
+
+	/*compute return rect*/
+	if(startx < endx)
+	{
+		left = startx;
+		right = endx;
+	}
+	else
+	{
+		left = endx;
+		right = startx;
+	}
+	if(starty < endy)
+	{
+		top = starty;
+		bottom = endy;
+	}
+	else
+	{
+		top = endy;
+		bottom = starty;
+	}
+	return PyRect_New4((short)left, (short)top, (short)(right-left), (short)(bottom-top));
+}
+
+
+
+
+/*this line clipping based heavily off of code from
+http://www.ncsa.uiuc.edu/Vis/Graphics/src/clipCohSuth.c */
+#define LEFT_EDGE   0x1
+#define RIGHT_EDGE  0x2
+#define BOTTOM_EDGE 0x4
+#define TOP_EDGE    0x8
+#define INSIDE(a)   (!a)
+#define REJECT(a,b) (a&b)
+#define ACCEPT(a,b) (!(a|b))
+
+static int encode(int x, int y, int left, int top, int right, int bottom)
+{
+	int code = 0;
+	if(x < left)  code |= LEFT_EDGE;
+	if(x > right) code |= RIGHT_EDGE;
+	if(y < top)   code |= TOP_EDGE;
+	if(y > bottom)code |= BOTTOM_EDGE;
+	return code;
+}
+
+static int clipline(int* pts, int left, int top, int right, int bottom)
+{
+	int x1 = pts[0];
+	int y1 = pts[1];
+	int x2 = pts[2];
+	int y2 = pts[3];
+	int code1, code2;
+	int draw = 0;
+	int swaptmp;
+	float m; /*slope*/
+
+	while(1)
+	{
+		code1 = encode(x1, y1, left, top, right, bottom);
+		code2 = encode(x2, y2, left, top, right, bottom);
+		if(ACCEPT(code1, code2)) {
+			draw = 1;
+			break;
+		}
+		else if(REJECT(code1, code2))
+			break;
+		else {
+			if(INSIDE(code1)) {
+				swaptmp = x2; x2 = x1; x1 = swaptmp;
+				swaptmp = y2; y2 = y1; y1 = swaptmp;
+				swaptmp = code2; code2 = code1; code1 = swaptmp;
+			}
+			if(x2 != x1)      
+				m = (y2 - y1) / (float)(x2 - x1);
+			if(code1 & LEFT_EDGE) {
+				y1 += (int)((left - x1) * m);
+				x1 = left; 
+			} 
+			else if(code1 & RIGHT_EDGE) {
+				y1 += (int)((right - x1) * m);
+				x1 = right; 
+			} 
+			else if(code1 & BOTTOM_EDGE) {
+				if(x2 != x1)
+					x1 += (int)((bottom - y1) / m);
+				y1 = bottom;
+			} 
+			else if(code1 & TOP_EDGE) {
+				if(x2 != x1)
+					x1 += (int)((top - y1) / m);
+				y1 = top;
+			} 
+		}
+	}
+	if(draw) {
+		pts[0] = x1; pts[1] = y1;
+		pts[2] = x2; pts[3] = y2;
+	}
+	return draw;
+}
+
+
+
+
+/*here's a sdl'ized version of bresenham*/
+static void drawline(SDL_Surface* surf, Uint32 color, int x1, int y1, int x2, int y2)
+{
+	int deltax, deltay, signx, signy;
+	int pixx, pixy;
+	int x = 0, y = 0;
+	int swaptmp;
+	Uint8 *pixel;
+	Uint8 *color_24;
+
+ 	deltax = x2 - x1;
+ 	deltay = y2 - y1;
+ 	signx = (deltax < 0) ? -1 : 1;
+ 	signy = (deltay < 0) ? -1 : 1;
+ 	deltax = signx * deltax + 1;
+ 	deltay = signy * deltay + 1;
+
+	pixx = surf->format->BytesPerPixel;
+	pixy = surf->pitch;
+	pixel = ((Uint8*)surf->pixels) + pixx * x1 + pixy * y1;
+
+	pixx *= signx;
+	pixy *= signy;
+	if(deltax < deltay) /*swap axis if rise > run*/
+	{
+		swaptmp = deltax; deltax = deltay; deltay = swaptmp;
+		swaptmp = pixx; pixx = pixy; pixy = swaptmp;
+	}
+
+	switch(surf->format->BytesPerPixel)
+	{
+	case 1:
+		for(; x < deltax; x++, pixel += pixx) {
+			*pixel = (Uint8)color;
+			y += deltay; if(y >= deltax) {y -= deltax; pixel += pixy;}
+		}break;
+	case 2:
+		for(; x < deltax; x++, pixel += pixx) {
+			*(Uint16*)pixel = (Uint16)color;
+			y += deltay; if(y >= deltax) {y -= deltax; pixel += pixy;}
+		}break;
+	case 3:
+		color_24 = (Uint8*)&color;
+		for(; x < deltax; x++, pixel += pixx) {
+			pixel[0] = color_24[0];
+			pixel[1] = color_24[1];
+			pixel[2] = color_24[2];
+			y += deltay; if(y >= deltax) {y -= deltax; pixel += pixy;}
+		}break;
+	default: /*case 4*/
+		for(; x < deltax; x++, pixel += pixx) {
+			*(Uint32*)pixel = (Uint32)color;
+			y += deltay; if(y >= deltax) {y -= deltax; pixel += pixy;}
+		}break;
+	}
+}
+
+
+
+static void drawhorzline(SDL_Surface* surf, Uint32 color, int x1, int y1, int x2, int y2)
+{
+	Uint8 *pixel, *end;
+	Uint8 *color_24;
+
+	if(x1 == x2) return;
+
+	pixel = ((Uint8*)surf->pixels) + surf->pitch * y1;
+	if(x1 < x2)
+	{
+		end = pixel + x2 * surf->format->BytesPerPixel;
+		pixel += x1 * surf->format->BytesPerPixel;
+	}
+	else
+	{
+		end = pixel + x1 * surf->format->BytesPerPixel;
+		pixel += x2 * surf->format->BytesPerPixel;
+	}
+
+	switch(surf->format->BytesPerPixel)
+	{
+	case 1:
+		for(; pixel <= end; ++pixel) {
+			*pixel = (Uint8)color;
+		}break;
+	case 2:
+		for(; pixel <= end; ++pixel) {
+			*(Uint16*)pixel = (Uint16)color;
+		}break;
+	case 3:
+		color_24 = (Uint8*)&color;
+		for(; pixel <= end; ++pixel) {
+			pixel[0] = color_24[0];
+			pixel[1] = color_24[1];
+			pixel[2] = color_24[2];
+		}break;
+	default: /*case 4*/
+		for(; pixel <= end; ++pixel) {
+			*(Uint32*)pixel = (Uint32)color;
+		}break;
+	}
+}
+
+
+
+static PyMethodDef draw_builtins[] =
+{
+	{ "line", line, 1, doc_line },
+
+	{ NULL, NULL }
+};
+
+
+
+    /*DOC*/ static char doc_pygame_draw_MODULE[] =
+    /*DOC*/    "Contains routines to draw onto a surface.\n"
+    /*DOC*/    "\n"
+    /*DOC*/    "Note that all\n"
+    /*DOC*/    "drawing routines use direct pixel access, so the surfaces\n"
+    /*DOC*/    "must be locked for use. The draw functions will temporarily\n"
+    /*DOC*/    "lock the surface if needed, but if performing many drawing\n"
+    /*DOC*/    "routines together, it would be best to surround the drawing\n"
+    /*DOC*/    "code with a lock/unlock pair.\n"
+    /*DOC*/ ;
+
+void initdraw(void)
+{
+	PyObject *module, *dict;
+
+    /* create the module */
+	module = Py_InitModule3("draw", draw_builtins, doc_pygame_draw_MODULE);
+	dict = PyModule_GetDict(module);
+
+	/*imported needed apis*/
+	import_pygame_base();
+	import_pygame_rect();
+	import_pygame_surface();
+}
+

File src/surfarray.c

 #include<SDL_byteorder.h>
 
 
+#define TEMP_UNLOCK 	if(didlock) SDL_UnlockSurface(surf)
+
+
 
     /*DOC*/ static char doc_pixels3d[] =
     /*DOC*/    "pygame.surfarray.pixels3d(Surface) -> Array\n"
 
 
 	if(surf->format->BytesPerPixel == 3 || surf->format->BytesPerPixel < 1 || surf->format->BytesPerPixel > 4)
-	{
-		PyErr_SetString(PyExc_ValueError, "unsupport bit depth for 2D reference array");
-		return NULL;
-	}
+		return RAISE(PyExc_ValueError, "unsupport bit depth for 2D reference array");
 
 	dim[0] = surf->w;
 	dim[1] = surf->h;
 }
 
 
+    /*DOC*/ static char doc_pixels_alpha[] =
+    /*DOC*/    "pygame.surfarray.pixels_alpha(Surface) -> Array\n"
+    /*DOC*/    "get a reference array to a surface alpha data\n"
+    /*DOC*/    "\n"
+    /*DOC*/    "This returns a new noncontigous array that directly\n"
+    /*DOC*/    "effects a Surface's alpha contents.\n"
+    /*DOC*/    "\n"
+    /*DOC*/    "This will only work for 32bit surfaces with a pixel\n"
+    /*DOC*/    "alpha channel enabled.\n"
+    /*DOC*/    "\n"
+    /*DOC*/    "You'll need the surface to be locked if that is\n"
+    /*DOC*/    "required. Also be aware that between unlocking and\n"
+    /*DOC*/    "relocking a surface, the pixel data can be moved,\n"
+    /*DOC*/    "so don't hang onto this array after you have\n"
+    /*DOC*/    "unlocked the surface.\n"
+    /*DOC*/ ;
+
+static PyObject* pixels_alpha(PyObject* self, PyObject* arg)
+{
+	int dim[3];
+	PyObject* array;
+	SDL_Surface* surf;
+	char* startpixel;
+	const int lilendian = (SDL_BYTEORDER == SDL_LIL_ENDIAN);
+
+	if(!PyArg_ParseTuple(arg, "O!", &PySurface_Type, &array))
+		return NULL;
+	surf = PySurface_AsSurface(array);
+
+	if(surf->format->BytesPerPixel != 4)
+		return RAISE(PyExc_ValueError, "unsupport bit depth for alpha array");
+
+	/*must discover information about how data is packed*/
+	if(surf->format->Amask == 0xff<<24)
+		startpixel = ((char*)surf->pixels) + (lilendian ? 0 : 3);
+	else if(surf->format->Amask == 0xff)
+		startpixel = ((char*)surf->pixels) + (lilendian ? 3 : 0);
+	else
+		return RAISE(PyExc_ValueError, "unsupport colormasks for alpha reference array");
+
+	dim[0] = surf->w;
+	dim[1] = surf->h;
+	array = PyArray_FromDimsAndData(2, dim, PyArray_UBYTE, startpixel);
+	if(array)
+	{
+		((PyArrayObject*)array)->strides[1] = surf->pitch;
+		((PyArrayObject*)array)->strides[0] = surf->format->BytesPerPixel;
+		((PyArrayObject*)array)->flags = OWN_DIMENSIONS|OWN_STRIDES;
+	}
+	return array;
+}
+
 
     /*DOC*/ static char doc_array2d[] =
     /*DOC*/    "pygame.surfarray.array2d(Surface) -> Array\n"
 	PyObject* array;
 	SDL_Surface* surf;
 	int stridex, stridey;
+	int didlock = 0;
 
 	if(!PyArg_ParseTuple(arg, "O!", &PySurface_Type, &array))
 		return NULL;
 	stridex = ((PyArrayObject*)array)->strides[0];
 	stridey = ((PyArrayObject*)array)->strides[1];
 
+	if(!surf->pixels)
+	{
+		if(SDL_LockSurface(surf) == -1)
+			return RAISE(PyExc_SDLError, SDL_GetError());
+		didlock = 1;
+	}
+
 	switch(surf->format->BytesPerPixel)
 	{
 	case 1:
 			}
 		}break;
 	}
+
+	TEMP_UNLOCK;
 	return array;
 }
 
 	int Rmask, Gmask, Bmask, Rshift, Gshift, Bshift;
 	int stridex, stridey;
 	SDL_Color* palette;
+	int didlock = 0;
 
 	if(!PyArg_ParseTuple(arg, "O!", &PySurface_Type, &array))
 		return NULL;
 
 	stridex = ((PyArrayObject*)array)->strides[0];
 	stridey = ((PyArrayObject*)array)->strides[1];
+
+	if(!surf->pixels)
+	{
+		if(SDL_LockSurface(surf) == -1)
+			return RAISE(PyExc_SDLError, SDL_GetError());
+		didlock = 1;
+	}
 	
 	switch(surf->format->BytesPerPixel)
 	{
 	case 1:
 		if(!format->palette)
+		{
+			TEMP_UNLOCK;
 			return RAISE(PyExc_RuntimeError, "8bit surface has no palette");
+		}
 		palette = format->palette->colors;
 		for(loopy = 0; loopy < surf->h; ++loopy)
 		{
 		}break;
 	}
 
+	TEMP_UNLOCK;
+	return array;
+}
+
+
+
+
+    /*DOC*/ static char doc_array_alpha[] =
+    /*DOC*/    "pygame.surfarray.array_alpha(Surface) -> Array\n"
+    /*DOC*/    "get an array with a surface pixel alpha values\n"
+    /*DOC*/    "\n"
+    /*DOC*/    "This returns a new contigous 2d array with the\n"
+    /*DOC*/    "alpha values of an image as unsigned bytes. If the\n"
+    /*DOC*/    "surface has no alpha, an array of all opaque values\n"
+    /*DOC*/    "is returned.\n"
+    /*DOC*/    "\n"
+    /*DOC*/    "Some surfaces will require the surface to be locked for pixel access.\n"
+    /*DOC*/    "If locking is needed and the surface is not locked, it will be temporarily\n"
+    /*DOC*/    "locked in this function. If you will be calling this function many times\n"
+    /*DOC*/    "in one loop, it is will be much better to lock and unlock the surface\n"
+    /*DOC*/    "outside of that loop.\n"
+    /*DOC*/ ;
+
+PyObject* array_alpha(PyObject* self, PyObject* arg)
+{
+	int dim[2], loopy;
+	Uint8* data;
+	Uint32 color;
+	PyObject* array;
+	SDL_Surface* surf;
+	int stridex, stridey;
+	int didlock = 0;
+	int Ashift, Amask, Aloss;
+
+	if(!PyArg_ParseTuple(arg, "O!", &PySurface_Type, &array))
+		return NULL;
+	surf = PySurface_AsSurface(array);
+
+	dim[0] = surf->w;
+	dim[1] = surf->h;
+
+	if(surf->format->BytesPerPixel <= 1 || surf->format->BytesPerPixel > 4)
+		return RAISE(PyExc_ValueError, "unsupport bit depth for alpha array");
+
+	array = PyArray_FromDims(2, dim, PyArray_UBYTE);
+	if(!array) return NULL;
+
+	Amask = surf->format->Amask;
+	Ashift = surf->format->Ashift;
+	Aloss = surf->format->Aloss;
+
+	if(!Amask) /*no pixel alpha*/
+	{
+		memset(((PyArrayObject*)array)->data, 255, surf->w * surf->h);
+		return array;
+	}
+
+	stridex = ((PyArrayObject*)array)->strides[0];
+	stridey = ((PyArrayObject*)array)->strides[1];
+
+	if(!surf->pixels)
+	{
+		if(SDL_LockSurface(surf) == -1)
+			return RAISE(PyExc_SDLError, SDL_GetError());
+		didlock = 1;
+	}
+
+	switch(surf->format->BytesPerPixel)
+	{
+	case 2:
+		for(loopy = 0; loopy < surf->h; ++loopy)
+		{
+			Uint16* pix = (Uint16*)(((char*)surf->pixels)+loopy*surf->pitch);
+			Uint16* end = (Uint16*)(((char*)pix)+surf->w*2);
+			data = ((Uint8*)((PyArrayObject*)array)->data) + stridey*loopy;
+			while(pix < end)
+			{
+				color = *pix++;
+				*data = (color & Amask) >> Ashift << Aloss;
+				data += stridex;
+			}
+		}break;
+	case 3:
+		for(loopy = 0; loopy < surf->h; ++loopy)
+		{
+			Uint8* pix = (Uint8*)(((char*)surf->pixels)+loopy*surf->pitch);
+			Uint8* end = pix+surf->w*3;
+			data = ((Uint8*)((PyArrayObject*)array)->data) + stridey*loopy;
+			while(pix < end)
+			{
+#if SDL_BYTEORDER == SDL_LIL_ENDIAN
+				color = pix[0] + (pix[1]<<8) + (pix[2]<<16);
+#else
+				color = pix[2] + (pix[1]<<8) + (pix[0]<<16);
+#endif
+				*data = (color & Amask) >> Ashift << Aloss;
+				pix += 3;
+				data += stridex;
+			}
+		}break;
+	default: /*case 4*/
+		for(loopy = 0; loopy < surf->h; ++loopy)
+		{
+			Uint32* pix = (Uint32*)(((char*)surf->pixels)+loopy*surf->pitch);
+			Uint32* end = (Uint32*)(((char*)pix)+surf->w*4);
+			data = ((Uint8*)((PyArrayObject*)array)->data) + stridey*loopy;
+			while(pix < end)
+			{
+				color = *pix++;
+				*data = (color & Amask) >> Ashift << Aloss;
+				data += stridex;
+			}
+		}break;
+	}
+
+	TEMP_UNLOCK;
+	return array;
+}
+
+
+
+    /*DOC*/ static char doc_array_colorkey[] =
+    /*DOC*/    "pygame.surfarray.array_colorkey(Surface) -> Array\n"
+    /*DOC*/    "get an array with a surface colorkey values\n"
+    /*DOC*/    "\n"
+    /*DOC*/    "This returns a new contigous 2d array with the\n"
+    /*DOC*/    "colorkey values of an image as unsigned bytes. If the\n"
+    /*DOC*/    "surface has no colorkey, an array of all opaque values\n"
+    /*DOC*/    "is returned. Otherwise the array is either 0's or 255's.\n"
+    /*DOC*/    "\n"
+    /*DOC*/    "Some surfaces will require the surface to be locked for pixel access.\n"
+    /*DOC*/    "If locking is needed and the surface is not locked, it will be temporarily\n"
+    /*DOC*/    "locked in this function. If you will be calling this function many times\n"
+    /*DOC*/    "in one loop, it is will be much better to lock and unlock the surface\n"
+    /*DOC*/    "outside of that loop.\n"
+    /*DOC*/ ;
+
+PyObject* array_colorkey(PyObject* self, PyObject* arg)
+{
+	int dim[2], loopy;
+	Uint8* data;
+	Uint32 color, colorkey;
+	PyObject* array;
+	SDL_Surface* surf;
+	int stridex, stridey;
+	int didlock = 0;
+
+	if(!PyArg_ParseTuple(arg, "O!", &PySurface_Type, &array))
+		return NULL;
+	surf = PySurface_AsSurface(array);
+
+	dim[0] = surf->w;
+	dim[1] = surf->h;
+
+	if(surf->format->BytesPerPixel <= 0 || surf->format->BytesPerPixel > 4)
+		return RAISE(PyExc_ValueError, "unsupport bit depth for colorkey array");
+
+	array = PyArray_FromDims(2, dim, PyArray_UBYTE);
+	if(!array) return NULL;
+
+	colorkey = surf->format->colorkey;
+
+	if(!(surf->flags & SDL_SRCCOLORKEY)) /*no pixel alpha*/
+	{
+		memset(((PyArrayObject*)array)->data, 255, surf->w * surf->h);
+		return array;
+	}
+
+	stridex = ((PyArrayObject*)array)->strides[0];
+	stridey = ((PyArrayObject*)array)->strides[1];
+
+	if(!surf->pixels)
+	{
+		if(SDL_LockSurface(surf) == -1)
+			return RAISE(PyExc_SDLError, SDL_GetError());
+		didlock = 1;
+	}
+
+	switch(surf->format->BytesPerPixel)
+	{
+	case 1:
+		for(loopy = 0; loopy < surf->h; ++loopy)
+		{
+			Uint8* pix = (Uint8*)(((char*)surf->pixels)+loopy*surf->pitch);
+			Uint8* end = (Uint8*)(((char*)pix)+surf->w*2);
+			data = ((Uint8*)((PyArrayObject*)array)->data) + stridey*loopy;
+			while(pix < end)
+			{
+				color = *pix++;
+				*data = (color == colorkey) * 255;
+				data += stridex;
+			}
+		}break;
+	case 2:
+		for(loopy = 0; loopy < surf->h; ++loopy)
+		{
+			Uint16* pix = (Uint16*)(((char*)surf->pixels)+loopy*surf->pitch);
+			Uint16* end = (Uint16*)(((char*)pix)+surf->w*2);
+			data = ((Uint8*)((PyArrayObject*)array)->data) + stridey*loopy;
+			while(pix < end)
+			{
+				color = *pix++;
+				*data = (color == colorkey) * 255;
+				data += stridex;
+			}
+		}break;
+	case 3:
+		for(loopy = 0; loopy < surf->h; ++loopy)
+		{
+			Uint8* pix = (Uint8*)(((char*)surf->pixels)+loopy*surf->pitch);
+			Uint8* end = pix+surf->w*3;
+			data = ((Uint8*)((PyArrayObject*)array)->data) + stridey*loopy;
+			while(pix < end)
+			{
+#if SDL_BYTEORDER == SDL_LIL_ENDIAN
+				color = pix[0] + (pix[1]<<8) + (pix[2]<<16);
+#else
+				color = pix[2] + (pix[1]<<8) + (pix[0]<<16);
+#endif
+				*data = (color == colorkey) * 255;
+				pix += 3;
+				data += stridex;
+			}
+		}break;
+	default: /*case 4*/
+		for(loopy = 0; loopy < surf->h; ++loopy)
+		{
+			Uint32* pix = (Uint32*)(((char*)surf->pixels)+loopy*surf->pitch);
+			Uint32* end = (Uint32*)(((char*)pix)+surf->w*4);
+			data = ((Uint8*)((PyArrayObject*)array)->data) + stridey*loopy;
+			while(pix < end)
+			{
+				color = *pix++;
+				*data = (color == colorkey) * 255;
+				data += stridex;
+			}
+		}break;
+	}
+
+	TEMP_UNLOCK;
 	return array;
 }
 
 	}	}
 
 
-#define TEMP_UNLOCK 	if(didlock) SDL_UnlockSurface(surf)
 
     /*DOC*/ static char doc_blit_array[] =
     /*DOC*/    "pygame.surfarray.blit_array(surf, array) -> None\n"
 {
 	{ "pixels2d", pixels2d, 1, doc_pixels2d },
 	{ "pixels3d", pixels3d, 1, doc_pixels3d },
+	{ "pixels_alpha", pixels_alpha, 1, doc_pixels_alpha },
 	{ "array2d", array2d, 1, doc_array2d },
 	{ "array3d", array3d, 1, doc_array3d },
+	{ "array_alpha", array_alpha, 1, doc_array_alpha },
+	{ "array_colorkey", array_colorkey, 1, doc_array_colorkey },
 	{ "map_array", map_array, 1, doc_map_array },
 /*	{ "unmap_array", unmap_array, 1, doc_unmap_array },*/
 	{ "blit_array", blit_array, 1, doc_blit_array },