瀏覽代碼

* stock.c: allow arbitrary sizes for the bayer stock image, even if they

give shitty results when used for ordered dithering.

git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/libpipi/trunk@2707 92316355-f0b4-4df1-b90c-862c8a59935f
remotes/tiles
sam 16 年之前
父節點
當前提交
a5ceceaf77
共有 1 個文件被更改,包括 14 次插入6 次删除
  1. +14
    -6
      pipi/stock.c

+ 14
- 6
pipi/stock.c 查看文件

@@ -35,17 +35,25 @@ pipi_image_t *pipi_load_stock(char const *name)
/* Generate a Bayer dithering pattern. */
if(!strncmp(name, "bayer", 5))
{
int i, j, n = atoi(name + 5);
int i, j, w, h, n;

if(n <= 0 || (n & (n - 1))) /* is n a power of two? */
w = atoi(name + 5);
name = strchr(name + 5, 'x');
if(!name)
return NULL;
h = atoi(name + 1);
if(w <= 0 || h <= 0)
return NULL;

ret = pipi_new(n, n);
for(n = 1; n < w || n < h; n *= 2)
;

ret = pipi_new(w, h);
pix = pipi_getpixels(ret, PIPI_PIXELS_Y_F);
data = (float *)pix->pixels;

for(j = 0; j < n; j++)
for(i = 0; i < n; i++)
for(j = 0; j < h; j++)
for(i = 0; i < w; i++)
{
int k, l, x = 0;

@@ -59,7 +67,7 @@ pipi_image_t *pipi_load_stock(char const *name)
x += 2 * l;
}

data[j * n + i] = (double)(x + 1) / (n * n + 1);
data[j * w + i] = (double)(x + 1) / (n * n + 1);
}

return ret;


Loading…
取消
儲存