Browse Source

* 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
remotes/tiles
sam 16 years ago
parent
commit
9ba0524b9a
1 changed files with 14 additions and 9 deletions
  1. +14
    -9
      pipi/stock.c

+ 14
- 9
pipi/stock.c View File

@@ -77,7 +77,7 @@ pipi_image_t *pipi_load_stock(char const *name)
if(!strncmp(name, "random", 6)) if(!strncmp(name, "random", 6))
{ {
unsigned int ctx = 1; unsigned int ctx = 1;
int x, y, w, h;
int x, y, t, w, h;


w = atoi(name + 6); w = atoi(name + 6);
name = strchr(name + 6, 'x'); name = strchr(name + 6, 'x');
@@ -88,21 +88,26 @@ pipi_image_t *pipi_load_stock(char const *name)
return NULL; return NULL;


ret = pipi_new(w, h); 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; data = (float *)pix->pixels;


for(y = 0; y < h; y++) for(y = 0; y < h; y++)
for(x = 0; x < w; x++) 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; return ret;


Loading…
Cancel
Save