Index: uspace/lib/c/include/io/pixelmap.h
===================================================================
--- uspace/lib/c/include/io/pixelmap.h	(revision 8d3512f119e2a44f134b45bad386692c49984b5b)
+++ uspace/lib/c/include/io/pixelmap.h	(revision 00ddb40e40d76e7f5d1a1b654498668aa2cc0e10)
@@ -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/draw/font/bitmap_backend.c
===================================================================
--- uspace/lib/draw/font/bitmap_backend.c	(revision 8d3512f119e2a44f134b45bad386692c49984b5b)
+++ uspace/lib/draw/font/bitmap_backend.c	(revision 00ddb40e40d76e7f5d1a1b654498668aa2cc0e10)
@@ -143,5 +143,5 @@
 	source_t source;
 	source_init(&source);
-	source_set_texture(&source, raw_surface, false);
+	source_set_texture(&source, raw_surface, PIXELMAP_EXTEND_TRANSPARENT_BLACK);
 
 	transform_t transform;
Index: uspace/lib/draw/source.c
===================================================================
--- uspace/lib/draw/source.c	(revision 8d3512f119e2a44f134b45bad386692c49984b5b)
+++ uspace/lib/draw/source.c	(revision 00ddb40e40d76e7f5d1a1b654498668aa2cc0e10)
@@ -45,9 +45,9 @@
 	source->color = PIXEL(0, 0, 0, 0);
 	source->texture = NULL;
-	source->texture_tile = false;
+	source->texture_extend = PIXELMAP_EXTEND_TRANSPARENT_BLACK;
 
 	source->alpha = PIXEL(255, 0, 0, 0);
 	source->mask = NULL;
-	source->mask_tile = false;
+	source->mask_extend = PIXELMAP_EXTEND_TRANSPARENT_BLACK;
 }
 
@@ -73,8 +73,9 @@
 }
 
-void source_set_texture(source_t *source, surface_t *texture, bool tile)
+void source_set_texture(source_t *source, surface_t *texture,
+    pixelmap_extend_t extend)
 {
 	source->texture = texture;
-	source->texture_tile = tile;
+	source->texture_extend = extend;
 }
 
@@ -84,8 +85,9 @@
 }
 
-void source_set_mask(source_t *source, surface_t *mask, bool tile)
+void source_set_mask(source_t *source, surface_t *mask,
+    pixelmap_extend_t extend)
 {
 	source->mask = mask;
-	source->mask_tile = tile;
+	source->mask_extend = extend;
 }
 
@@ -95,5 +97,5 @@
 	    (source->alpha == (pixel_t) PIXEL(255, 0, 0, 0)) &&
 	    (source->texture != NULL) &&
-	    (source->texture_tile == false) &&
+	    (source->texture_extend == PIXELMAP_EXTEND_TRANSPARENT_BLACK) &&
 	    (transform_is_fast(&source->transform)));
 }
@@ -120,5 +122,5 @@
 		mask_pix = source->filter(
 		    surface_pixmap_access(source->mask),
-		    x, y, source->mask_tile);
+		    x, y, source->mask_extend);
 	} else {
 		mask_pix = source->alpha;
@@ -133,5 +135,5 @@
 		texture_pix = source->filter(
 		    surface_pixmap_access(source->texture),
-		    x, y, source->texture_tile);
+		    x, y, source->texture_extend);
 	} else {
 		texture_pix = source->color;
Index: uspace/lib/draw/source.h
===================================================================
--- uspace/lib/draw/source.h	(revision 8d3512f119e2a44f134b45bad386692c49984b5b)
+++ uspace/lib/draw/source.h	(revision 00ddb40e40d76e7f5d1a1b654498668aa2cc0e10)
@@ -42,4 +42,5 @@
 #include <transform.h>
 #include <filter.h>
+#include <io/pixelmap.h>
 
 #include "surface.h"
@@ -51,9 +52,9 @@
 	pixel_t color;
 	surface_t *texture;
-	bool texture_tile;
+	pixelmap_extend_t texture_extend;
 
 	pixel_t alpha;
 	surface_t *mask;
-	bool mask_tile;
+	pixelmap_extend_t mask_extend;
 } source_t;
 
@@ -66,8 +67,8 @@
 
 extern void source_set_color(source_t *, pixel_t);
-extern void source_set_texture(source_t *, surface_t *, bool);
+extern void source_set_texture(source_t *, surface_t *, pixelmap_extend_t);
 
 extern void source_set_alpha(source_t *, pixel_t);
-extern void source_set_mask(source_t *, surface_t *, bool);
+extern void source_set_mask(source_t *, surface_t *, pixelmap_extend_t);
 
 extern bool source_is_fast(source_t *);
Index: uspace/lib/gui/canvas.c
===================================================================
--- uspace/lib/gui/canvas.c	(revision 8d3512f119e2a44f134b45bad386692c49984b5b)
+++ uspace/lib/gui/canvas.c	(revision 00ddb40e40d76e7f5d1a1b654498668aa2cc0e10)
@@ -58,5 +58,6 @@
 	source_init(&source);
 	source_set_transform(&source, transform);
-	source_set_texture(&source, canvas->surface, false);
+	source_set_texture(&source, canvas->surface,
+	    PIXELMAP_EXTEND_TRANSPARENT_BLACK);
 	
 	drawctx_t drawctx;
Index: uspace/lib/softrend/filter.c
===================================================================
--- uspace/lib/softrend/filter.c	(revision 8d3512f119e2a44f134b45bad386692c49984b5b)
+++ uspace/lib/softrend/filter.c	(revision 00ddb40e40d76e7f5d1a1b654498668aa2cc0e10)
@@ -38,4 +38,5 @@
 #include <io/pixel.h>
 
+
 static long round(double val)
 {
@@ -59,13 +60,4 @@
 }
 
-static pixel_t get_pixel(pixelmap_t *pixmap, sysarg_t x, sysarg_t y, bool tile)
-{
-	if (tile) {
-		x %= pixmap->width;
-		y %= pixmap->height;
-	}
-
-	return pixelmap_get_pixel(pixmap, (sysarg_t) x, (sysarg_t) y);
-}
 
 static inline pixel_t blend_pixels(size_t count, float *weights,
@@ -84,10 +76,12 @@
 }
 
-pixel_t filter_nearest(pixelmap_t *pixmap, double x, double y, bool tile)
+pixel_t filter_nearest(pixelmap_t *pixmap, double x, double y,
+    pixelmap_extend_t extend)
 {
-	return get_pixel(pixmap, round(x), round(y), tile);
+	return pixelmap_get_extended_pixel(pixmap, round(x), round(y), extend);
 }
 
-pixel_t filter_bilinear(pixelmap_t *pixmap, double x, double y, bool tile)
+pixel_t filter_bilinear(pixelmap_t *pixmap, double x, double y,
+    pixelmap_extend_t extend)
 {
 	long x1 = floor(x);
@@ -97,6 +91,6 @@
 	
 	if (y1 == y2 && x1 == x2) {
-		return get_pixel(pixmap, (sysarg_t) x1, (sysarg_t) y1,
-		    tile);
+		return pixelmap_get_extended_pixel(pixmap,
+		    (sysarg_t) x1, (sysarg_t) y1, extend);
 	}
 	
@@ -105,8 +99,8 @@
 	
 	pixel_t pixels[4];
-	pixels[0] = get_pixel(pixmap, x1, y1, tile);
-	pixels[1] = get_pixel(pixmap, x2, y1, tile);
-	pixels[2] = get_pixel(pixmap, x1, y2, tile);
-	pixels[3] = get_pixel(pixmap, x2, y2, tile);
+	pixels[0] = pixelmap_get_extended_pixel(pixmap, x1, y1, extend);
+	pixels[1] = pixelmap_get_extended_pixel(pixmap, x2, y1, extend);
+	pixels[2] = pixelmap_get_extended_pixel(pixmap, x1, y2, extend);
+	pixels[3] = pixelmap_get_extended_pixel(pixmap, x2, y2, extend);
 	
 	float weights[4];
@@ -119,5 +113,6 @@
 }
 
-pixel_t filter_bicubic(pixelmap_t *pixmap, double x, double y, bool tile)
+pixel_t filter_bicubic(pixelmap_t *pixmap, double x, double y,
+    pixelmap_extend_t extend)
 {
 	// TODO
Index: uspace/lib/softrend/filter.h
===================================================================
--- uspace/lib/softrend/filter.h	(revision 8d3512f119e2a44f134b45bad386692c49984b5b)
+++ uspace/lib/softrend/filter.h	(revision 00ddb40e40d76e7f5d1a1b654498668aa2cc0e10)
@@ -40,9 +40,9 @@
 #include <io/pixelmap.h>
 
-typedef pixel_t (*filter_t)(pixelmap_t *, double, double, bool);
+typedef pixel_t (*filter_t)(pixelmap_t *, double, double, pixelmap_extend_t);
 
-extern pixel_t filter_nearest(pixelmap_t *, double, double, bool);
-extern pixel_t filter_bilinear(pixelmap_t *, double, double, bool);
-extern pixel_t filter_bicubic(pixelmap_t *, double, double, bool);
+extern pixel_t filter_nearest(pixelmap_t *, double, double, pixelmap_extend_t);
+extern pixel_t filter_bilinear(pixelmap_t *, double, double, pixelmap_extend_t);
+extern pixel_t filter_bicubic(pixelmap_t *, double, double, pixelmap_extend_t);
 
 #endif
Index: uspace/srv/hid/compositor/compositor.c
===================================================================
--- uspace/srv/hid/compositor/compositor.c	(revision 8d3512f119e2a44f134b45bad386692c49984b5b)
+++ uspace/srv/hid/compositor/compositor.c	(revision 00ddb40e40d76e7f5d1a1b654498668aa2cc0e10)
@@ -444,5 +444,6 @@
 
 					source_set_transform(&source, transform);
-					source_set_texture(&source, win->surface, false);
+					source_set_texture(&source, win->surface,
+					    PIXELMAP_EXTEND_TRANSPARENT_SIDES);
 					source_set_alpha(&source, PIXEL(win->opacity, 0, 0, 0));
 
