Initial commit
[distort.git] / pictures.h
1 /*-----------------------------------------------------------------------------
2   Code written by Francois Fleuret, using GCC & Emacs
3   Jun-Nov 1995
4   Contact <francois.fleuret@inria.fr>
5 -----------------------------------------------------------------------------*/
6
7 // A class to manipulate pictures. June 1995.
8 // gcc/SunOS
9 // francois.fleuret@inria.fr
10 // Thanxxxxx to Emacs & gcc
11
12 /*---------------------------------------------------------------------------*/
13
14 #ifndef PICTURES_H
15 #define PICTURES_H
16
17 #define BUFFER_SIZE 256
18
19 /*---------------------------------------------------------------------------*/
20
21 #include <iostream.h>
22 #include <math.h>
23 #include <sys/types.h>
24 #include <sys/uio.h>
25 #include <fcntl.h>
26
27 #include "array.h"
28
29 extern "C" int read(int, char *, int);
30 extern "C" int write(int, char *, int);
31 //extern "C" int open(char *, int);
32 extern "C" int close(int);
33
34 /*
35 extern "C" image *image_(char *, char *, char *, nf_fmt *);
36 extern "C" c_lecflt(image *, int, unsigned char *);
37 extern "C" c_ecrflt(image *, int, unsigned char *);
38 extern "C" fermnf_(image **);
39 */
40
41 /*---------------------------------------------------------------------------*/
42
43 // 3 floats par pixel
44 #define PIC_DEPTH 3
45
46 #define PIC_RED 0
47 #define PIC_GREEN 1
48 #define PIC_BLUE 2
49
50 #define LARGEUR_TRUC 9
51 #define HAUTEUR_TRUC (MAX_TAGIFICATION/LARGEUR_TRUC)
52
53 /*---------------------------------------------------------------------------*/
54
55 class Picture
56 {
57 private:
58   Array<float> Body;
59   
60 public:
61   int SizeX, SizeY;
62   
63 public:
64
65   Picture();
66   Picture(Picture &v);
67   Picture(int SX, int SY);
68   ~Picture();
69
70   float GetComponent(int x, int y, int n);
71   void SetComponent(int x, int y, int n, float v);
72
73   void Clear();
74   void Fill(float v);
75
76   void Blur(int s);
77
78   void Free();
79   void Reformat(int x, int y);
80
81   void Reverse();
82   void ToBN();
83   void AddBorders(int w, float r, float g, float b);
84
85   void LoadPpm(char *file_name);
86   void SavePpm(char *file_name);
87
88   void ReSize(int nx, int ny);
89   void Cut(int x, int y, int w, int h, Picture &src);
90   void Copy(int xd, int yd, int xs, int ys, int w, int h, Picture &src);
91   int operator == (Picture &src);
92   void operator = (Picture &src);
93
94   float Picture::DistanceL2(Picture *p);
95 };
96
97 /*---------------------------------------------------------------------------*/
98
99 #endif