瀏覽代碼

* 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 年之前
父節點
當前提交
9ba0524b9a
共有 1 個檔案被更改,包括 14 行新增9 行删除
  1. +14
    -9
      pipi/stock.c

+ 14
- 9
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;


Loading…
取消
儲存