cairo-util: Dont use non-standard JCS_EXT_BGRX color space

Everytime somebody has to write a channel swizzling loop,
God kills a kitten... and a dolphin and a unicorn.
diff --git a/clients/cairo-util.c b/clients/cairo-util.c
index 61a053b..54a05b1 100644
--- a/clients/cairo-util.c
+++ b/clients/cairo-util.c
@@ -289,13 +289,28 @@
 	cairo_close_path(cr);
 }
 
+static void
+swizzle_row(JSAMPLE *row, JDIMENSION width)
+{
+	JSAMPLE *s;
+	uint32_t *d;
+
+	s = row + (width - 1) * 3;
+	d = (uint32_t *) (row + (width - 1) * 4);
+	while (s >= row) {
+		*d = 0xff000000 | (s[0] << 16) | (s[1] << 8) | (s[2] << 0);
+		s -= 3;
+		d--;
+	}
+}
+
 cairo_surface_t *
 load_jpeg(const char *filename)
 {
 	struct jpeg_decompress_struct cinfo;
 	struct jpeg_error_mgr jerr;
 	FILE *fp;
-	int stride, i;
+	int stride, i, first;
 	JSAMPLE *data, *rows[4];
 
 	cinfo.err = jpeg_std_error(&jerr);
@@ -310,7 +325,7 @@
 
 	jpeg_read_header(&cinfo, TRUE);
 
-	cinfo.out_color_space = JCS_EXT_BGRX;
+	cinfo.out_color_space = JCS_RGB;
 	jpeg_start_decompress(&cinfo);
 
 	stride = cairo_format_stride_for_width(CAIRO_FORMAT_RGB24,
@@ -322,10 +337,13 @@
 	}
 
 	while (cinfo.output_scanline < cinfo.output_height) {
+		first = cinfo.output_scanline;
 		for (i = 0; i < ARRAY_LENGTH(rows); i++)
-			rows[i] = data + (cinfo.output_scanline + i) * stride;
+			rows[i] = data + (first + i) * stride;
 
 		jpeg_read_scanlines(&cinfo, rows, ARRAY_LENGTH(rows));
+		for (i = 0; first + i < cinfo.output_scanline; i++)
+			swizzle_row(rows[i], cinfo.output_width);
 	}
 
 	jpeg_finish_decompress(&cinfo);