SmartPDF - lightweight pdf viewer app for rosapps
[reactos.git] / rosapps / smartpdf / baseutils / pdiff.h
1 #ifndef PDIFF_H_
2 #define PDIFF_H_
3
4 /*
5 Copyright (C) 2006 Yangli Hector Yee
6
7 This program is free software; you can redistribute it and/or modify it under the terms of the
8 GNU General Public License as published by the Free Software Foundation; either version 2 of the License,
9 or (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
12 without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 See the GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License along with this program;
16 if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
18 Code from http://pdiff.sourceforge.net
19 */
20
21 class RGBAImage
22 {
23 public:
24 virtual int Get_Width(void) const = 0;
25 virtual int Get_Height(void) const = 0;
26 virtual unsigned char Get_Red(unsigned int i) = 0;
27 virtual unsigned char Get_Green(unsigned int i) = 0;
28 virtual unsigned char Get_Blue(unsigned int i) = 0;
29 virtual unsigned char Get_Alpha(unsigned int i) = 0;
30 virtual void Set(unsigned char r, unsigned char g, unsigned char b, unsigned char a, unsigned int i) = 0;
31 virtual unsigned int Get(int i) const = 0;
32 };
33
34 class RGBAImageData : RGBAImage
35 {
36 public:
37 RGBAImageData(int w, int h)
38 {
39 Width = w;
40 Height = h;
41 Data = new unsigned int[w * h];
42 };
43 ~RGBAImageData() { if (Data) delete[] Data; }
44 unsigned char Get_Red(unsigned int i) { return (Data[i] & 0xFF); }
45 unsigned char Get_Green(unsigned int i) { return ((Data[i]>>8) & 0xFF); }
46 unsigned char Get_Blue(unsigned int i) { return ((Data[i]>>16) & 0xFF); }
47 unsigned char Get_Alpha(unsigned int i) { return ((Data[i]>>24) & 0xFF); }
48 void Set(unsigned char r, unsigned char g, unsigned char b, unsigned char a, unsigned int i)
49 { Data[i] = r | (g << 8) | (b << 16) | (a << 24); }
50 int Get_Width(void) const { return Width; }
51 int Get_Height(void) const { return Height; }
52 void Set(int x, int y, unsigned int d) { Data[x + y * Width] = d; }
53 unsigned int Get(int x, int y) const { return Data[x + y * Width]; }
54 unsigned int Get(int i) const { return Data[i]; }
55
56 protected:
57 int Width;
58 int Height;
59 unsigned int * Data;
60 };
61
62 class CompareArgs {
63 public:
64 CompareArgs();
65 ~CompareArgs();
66
67 RGBAImage *ImgA;
68 RGBAImage *ImgB;
69 RGBAImage *ImgDiff;
70 float FieldOfView; // Field of view in degrees
71 float Gamma; // The gamma to convert to linear color space
72 float Luminance; // the display's luminance
73 };
74
75 #define DIFFERENT_SIZES (unsigned long)-1
76 #define IDENTICAL (unsigned long)0
77
78 unsigned long Yee_Compare(CompareArgs &args);
79
80 #endif
81