@@ -35,17 +35,25 @@ pipi_image_t *pipi_load_stock(char const *name)
/* Generate a Bayer dithering pattern. */
/* Generate a Bayer dithering pattern. */
if(!strncmp(name, "bayer", 5))
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;
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);
pix = pipi_getpixels(ret, PIPI_PIXELS_Y_F);
data = (float *)pix->pixels;
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;
int k, l, x = 0;
@@ -59,7 +67,7 @@ pipi_image_t *pipi_load_stock(char const *name)
x += 2 * l;
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;
return ret;