Index: uspace/lib/c/include/io/pixelmap.h
===================================================================
--- uspace/lib/c/include/io/pixelmap.h	(revision c62a82757f97403f2ba31f76aafdf68ae74e4003)
+++ uspace/lib/c/include/io/pixelmap.h	(revision 865b9817d13bfe38c3c0832bbbb859184dcb2e71)
@@ -1,4 +1,5 @@
 /*
  * Copyright (c) 2011 Petr Koupy
+ * Copyright (c) 2014 Martin Sucha
  * All rights reserved.
  *
@@ -40,4 +41,21 @@
 #include <unistd.h>
 #include <io/pixel.h>
+
+/* Defines how a pixel outside of pixmap rectangle shall be treated */
+typedef enum {
+	/* Pixels outside of a pixmap are PIXEL(0, 0, 0, 0) */
+	PIXELMAP_EXTEND_TRANSPARENT_BLACK = 0,
+	
+	/* The pixmap is repeated infinetely */
+	PIXELMAP_EXTEND_TILE,
+	
+	/* If outside of a pixmap, return closest pixel from the edge */
+	PIXELMAP_EXTEND_SIDES,
+	
+	/* If outside of a pixmap, return closest pixel from the edge,
+	 * with alpha = 0
+	 */
+	PIXELMAP_EXTEND_TRANSPARENT_SIDES
+} pixelmap_extend_t;
 
 typedef struct {
@@ -86,4 +104,48 @@
 }
 
+static inline pixel_t pixelmap_get_extended_pixel(pixelmap_t *pixmap,
+    native_t x, native_t y, pixelmap_extend_t extend)
+{
+	bool transparent = false;
+	if (extend == PIXELMAP_EXTEND_TILE) {
+		x %= pixmap->width;
+		y %= pixmap->height;
+	}
+	else if (extend == PIXELMAP_EXTEND_SIDES ||
+	    extend == PIXELMAP_EXTEND_TRANSPARENT_SIDES) {
+		bool transparent_outside =
+		    (extend == PIXELMAP_EXTEND_TRANSPARENT_SIDES);
+		if (x < 0) {
+			x = 0;
+			transparent = transparent_outside;
+		}
+		else if (((sysarg_t) x) >= pixmap->width) {
+			x = pixmap->width - 1;
+			transparent = transparent_outside;
+		}
+		
+		if (y < 0) {
+			y = 0;
+			transparent = transparent_outside;
+		}
+		else if (((sysarg_t) y) >= pixmap->height) {
+			y = pixmap->height - 1;
+			transparent = transparent_outside;
+		}
+	}
+	
+	if (x < 0 || ((sysarg_t) x) >= pixmap->width ||
+	    y < 0 || ((sysarg_t) y) >= pixmap->height)
+		return PIXEL(0, 0, 0, 0);
+
+	pixel_t pixel = pixelmap_get_pixel(pixmap, x, y);
+	
+	if (transparent)
+		pixel = PIXEL(0, RED(pixel), GREEN(pixel), BLUE(pixel));
+	
+	return pixel;
+}
+
+
 #endif
 
Index: uspace/lib/c/include/stdio.h
===================================================================
--- uspace/lib/c/include/stdio.h	(revision c62a82757f97403f2ba31f76aafdf68ae74e4003)
+++ uspace/lib/c/include/stdio.h	(revision 865b9817d13bfe38c3c0832bbbb859184dcb2e71)
@@ -120,4 +120,5 @@
 extern int snprintf(char *, size_t , const char *, ...)
     PRINTF_ATTRIBUTE(3, 4);
+extern int vasprintf(char **, const char *, va_list);
 extern int asprintf(char **, const char *, ...)
     PRINTF_ATTRIBUTE(2, 3);
