24 #define ROUNDCLAMP(X) (((X) < 0) ? 0 : (((X) > 1) ? 255 : floor(X*255 + 0.5f)))
60 int RedX,
int RedY,
const char *OutputFile)
62 const int NumPixels = Width*Height;
66 uint8_t *ImageU8 = NULL;
67 float Temp, x1, y1, x2, y2;
68 int i, x, y, DimScale = 5, Success = 0;
70 if(!(Mosaic = (
float *)
Malloc(
sizeof(
float)*NumPixels))
71 || !(Stencil = (
int *)
Malloc(
sizeof(
int)*NumPixels))
72 || !(ImageU8 = (uint8_t *)
Malloc(
sizeof(uint8_t)*3*NumPixels))
74 || !(File =
PsOpen(OutputFile, 0, 0,
75 DimScale*Width, DimScale*Height)))
78 CfaFlatten(Mosaic, Image, Width, Height, RedX, RedY);
84 for(i = 0; i < NumPixels; i++)
86 Temp = 0.5f + 0.5f*Image[i];
88 Temp = 0.5f + 0.5f*Image[i + NumPixels];
90 Temp = 0.5f + 0.5f*Image[i + 2*NumPixels];
96 "/ColorImageFilter /FlateEncode"))
99 fprintf(File,
"/bdef {bind def} bind def\n"
100 "/m1 {moveto rlineto stroke} bdef\n"
101 "0.08 setlinewidth\n"
102 "%d %d scale\n", DimScale, DimScale);
109 for(y = 0, i = 0; y < Height; y++)
110 for(x = 0; x < Width; x++, i++)
112 x2 = (float)(cos(Stencil[i]*
M_PI_8)*0.45);
113 y2 = (float)(sin(Stencil[i]*M_PI_8)*0.45);
118 fprintf(File,
"%.2f %.2f %.2f %.2f m1\n",
120 x + x1 + 0.5f, y1 + (Height - y - 0.5f));