File: imgImage.c

package info (click to toggle)
imgstar 1.1-4
  • links: PTS
  • area: non-free
  • in suites: potato, slink
  • size: 972 kB
  • ctags: 529
  • sloc: ansic: 7,264; makefile: 111
file content (71 lines) | stat: -rw-r--r-- 1,886 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/****************************************************************************/
/*                                                                          */
/* IMG* Image Processing Tools Library                                      */
/* Program:   imgImage.c                                                    */
/* Author:    Simon A.J. Winder                                             */
/* Date:      Thu Oct 20 20:45:44 1994                                      */
/* Copyright (C) 1994 Simon A.J. Winder                                     */
/*                                                                          */
/****************************************************************************/

#include "tools.h"

#define PRGNAME "Image"
#define ERROR(e) imgError(e,PRGNAME)
#define ARG_ERROR(e,arg) imgArgError(e,arg,PRGNAME)

int main(int argc,char **argv)
{
  it_image *out;
  it_float *ptr;
  int x,y,width=256,height=256;
  double val=0.0;

  IFHELP
    {
      fprintf(stderr,"img%s - Generate a blank image\n",
	      PRGNAME);
      fprintf(stderr,"img%s [width height] [value]\n",
	      PRGNAME);
      fprintf(stderr,"  stdin: None\n");
      fprintf(stderr,"  stdout: Float\n");
      exit(0);
    }

  imgStart(PRGNAME);

  if(argc>4)
    ERROR("invalid arguments");
  if(argc==2)
    val=atof(argv[1]);
  if(argc>2)
    {
      width=atoi(argv[1]);
      height=atoi(argv[2]);
    }
  if(argc==4)
    val=atof(argv[3]);

  out=i_create_image(width,height,IT_FLOAT,IM_FRAGMENT);
  if(out==NULL)
    ERROR("out of memory");

  if(val!=0.0)
    for(y=0;y<height;y++)
      {
	ptr=im_float_row(out,y);
	for(x=0;x<width;x++)
	  *ptr++ =val;
      }

  out->min_value=val;
  out->max_value=val;

  i_write_image_file(stdout,out,IF_BINARY);
  i_destroy_image(out);

  imgFinish(PRGNAME);
  return(0);
}
/* Version 1.0 (Oct 1994) */
/* Version 1.1 (Nov 1994) */