From 9ba0524b9a772922379357c1308bb891283311f6 Mon Sep 17 00:00:00 2001 From: sam Date: Sat, 16 Aug 2008 00:53:59 +0000 Subject: [PATCH] * stock.c: the random stock image now creates RGB noise. git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/libpipi/trunk@2727 92316355-f0b4-4df1-b90c-862c8a59935f --- pipi/stock.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/pipi/stock.c b/pipi/stock.c index 2ae4863..a25ebe2 100644 --- a/pipi/stock.c +++ b/pipi/stock.c @@ -77,7 +77,7 @@ pipi_image_t *pipi_load_stock(char const *name) if(!strncmp(name, "random", 6)) { unsigned int ctx = 1; - int x, y, w, h; + int x, y, t, w, h; w = atoi(name + 6); name = strchr(name + 6, 'x'); @@ -88,21 +88,26 @@ pipi_image_t *pipi_load_stock(char const *name) return NULL; ret = pipi_new(w, h); - pix = pipi_getpixels(ret, PIPI_PIXELS_Y_F); + pix = pipi_getpixels(ret, PIPI_PIXELS_RGBA_F); data = (float *)pix->pixels; for(y = 0; y < h; y++) for(x = 0; x < w; x++) { - long hi, lo; + for(t = 0; t < 3; t++) + { + long hi, lo; - hi = ctx / 12773L; - lo = ctx % 12773L; - ctx = 16807L * lo - 2836L * hi; - if(ctx <= 0) - ctx += 0x7fffffffL; + hi = ctx / 12773L; + lo = ctx % 12773L; + ctx = 16807L * lo - 2836L * hi; + if(ctx <= 0) + ctx += 0x7fffffffL; - data[y * w + x] = (double)((ctx % 65536) / 65535.); + data[4 * (y * w + x) + t] + = (double)((ctx % 65536) / 65535.); + } + data[4 * (y * w + x) + 3] = 1.0; } return ret;