58 puts(
"Nearest neighbor interpolation utility, P. Getreuer 2011\n");
59 puts(
"Usage: nninterp [options] <input file> <output file>\n"
62 puts(
" -x <number> the interpolation factor\n");
64 " -g <grid> grid to use for resampling, choices for <grid> are\n"
65 " centered grid with centered alignment (default)\n"
66 " topleft the top-left anchored grid\n");
68 puts(
" -q <number> quality for saving JPEG images (0 to 100)\n");
70 puts(
"Example: interpolate by factor 2.5\n"
71 " nninterp -x 2.5 frog.bmp coarse.bmp");
75 int main(
int argc,
char *argv[])
78 image u = {NULL, 0, 0}, v = {NULL, 0, 0};
87 IMAGEIO_U8 | IMAGEIO_RGBA)))
94 printf(
"%dx%d input --> %dx%d output\n", v.Width, v.Height, u.
Width, u.
Height);
97 if(!(u.
Data = (uint32_t *)
Malloc(
sizeof(uint32_t)*
100 fprintf(stderr,
"Memory allocation failed.\n");
105 v.Data, v.Width, v.Height,
114 printf(
"Output written to \"%s\".\n", Param.
OutputFile);
127 static char *DefaultOutputFile = (
char *)
"out.bmp";
146 for(i = 1; i < argc;)
148 if(argv[i] && argv[i][0] ==
'-')
150 if((OptionChar = argv[i][1]) == 0)
157 OptionString = &argv[i][2];
159 OptionString = argv[i];
178 if(!strcmp(OptionString,
"centered")
179 || !strcmp(OptionString,
"center"))
181 else if(!strcmp(OptionString,
"topleft")
182 || !strcmp(OptionString,
"top-left"))
186 ErrorMessage(
"Grid must be either \"centered\" or \"topleft\".\n");
197 ErrorMessage(
"JPEG quality must be between 0 and 100.\n");
206 if(isprint(OptionChar))