File: pltestexif.cpp

package info (click to toggle)
paintlib 2.6.2-14
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 7,920 kB
  • ctags: 3,874
  • sloc: cpp: 25,209; sh: 10,605; ansic: 1,891; makefile: 120
file content (182 lines) | stat: -rw-r--r-- 4,795 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
/*
/--------------------------------------------------------------------
|
|      $Id: pltestexif.cpp,v 1.12 2004/09/11 14:15:38 uzadow Exp $
|
|      Copyright (c) 1996-2002 Ulrich von Zadow
|
\--------------------------------------------------------------------
*/

#include "pltestexif.h"
#include "pltester.h"

#include <iostream>
#include <fstream>

#include "plpaintlibdefs.h"
#include "pljpegdec.h"
#include "pljpegenc.h"

#include "plexif.h"

using namespace std;

PLTestExif::PLTestExif ()
{
}

PLTestExif::~PLTestExif ()
{
}

void PLTestExif::RunTests ()
{
  cerr << "Running exif decoding tests...\n";
/*  testImage("143_jpg.jpg", "", 0);
  testImage("canon-ixus.jpg", "Canon", 60);
  testImage("fujifilm-dx10.jpg", "FUJIFILM", 38);
*/
  testImage("fujifilm-finepix40i.jpg", "FUJIFILM", 54);
/*
  testImage("fujifilm-mx1700.jpg", "FUJIFILM", 38);
  testImage("kodak-dc210.jpg", "Eastman Kodak Company", 25);
  testImage("kodak-dc240.jpg", "EASTMAN KODAK COMPANY", 33);
  testImage("nikon-e950.jpg", "NIKON", 46);
  testImage("olympus-c960.jpg", "OLYMPUS OPTICAL CO.,LTD", 43);
  testImage("ricoh-rdc5300.jpg", "RICOH      ", 30);
  testImage("sanyo-vpcg250.jpg", "SANYO Electric Co.,Ltd.", 31);
  testImage("sanyo-vpcsx550.jpg", "SANYO Electric Co.,Ltd.", 33);
  testImage("sony-cybershot.jpg", "SONY", 32);
  testImage("sony-d700.jpg", "SONY", 26);
  testImage("../../more_testpics/exif/exif_error.jpg", "", 0);
*/
  testEncode();
}

void PLTestExif::testImage(const string& sFName, const string& sMakeExpected, int NumTags)
{
  string sCompleteFName = PLTester::m_sTestFileDir+sFName;
  cerr << "  Testing " << sFName.c_str() << "...\n";

  PLJPEGDecoder Decoder;
  try
  {
    PLAnyBmp Bmp;
    Decoder.OpenFile (sCompleteFName.c_str());
    PLExif ExifData;
    Decoder.GetExifData(ExifData);
    const PLExifTagList & ev = ExifData.GetAllTags();
    cerr << "    ev.size: " << ev.size() << ", NumTags: " << NumTags << endl;
    string sMake;
    ExifData.GetTagCommon("Main.Make", sMake);
    Test (sMake == sMakeExpected);

    Decoder.MakeBmp(&Bmp);
    Decoder.Close();
  }
  catch (PLTextException e)
  {
    if (e.GetCode() == PL_ERRFORMAT_NOT_COMPILED)
    {
      cerr << "      --> Test skipped.\n";
    }
    else
    {
      Decoder.Close();
      cerr << "    Caught exception: " << (const char *)e << endl;
      Test(false);
    }
  }
  cerr << endl;
}

void PLTestExif::testEncode()
{
  PLJPEGDecoder Decoder;
  PLJPEGEncoder Encoder;
  cerr << "  Testing encode...\n";
  try
  {
    PLAnyBmp Bmp;
    Decoder.OpenFile ((PLTester::m_sTestFileDir+"fujifilm-finepix40i.jpg").c_str());
    PLExif ExifData;
    Decoder.GetExifData(ExifData);
    const PLExifTagList & ev = ExifData.GetAllTags();
    int NumTags = ev.size();
    cerr << "    NumTags !=0...\n";
    Test(NumTags != 0);
    Decoder.MakeBmp(&Bmp);
    Decoder.Close();

    Encoder.SetExifData(ExifData);
    Encoder.MakeFileFromBmp("test.jpg", &Bmp);
    
    Decoder.OpenFile ("test.jpg");
    Decoder.GetExifData(ExifData);
    Test(NumTags == ExifData.GetAllTags().size());
  }
  catch (PLTextException e)
  {
    if (e.GetCode() == PL_ERRFORMAT_NOT_COMPILED)
    {
      cerr << "      --> Test skipped.\n";
    }
    else
    {
      Decoder.Close();
      Test(false);
    }
  }

}

/*
/--------------------------------------------------------------------
|
|      $Log: pltestexif.cpp,v $
|      Revision 1.12  2004/09/11 14:15:38  uzadow
|      Comitted testimages, resized most of them.
|
|      Revision 1.11  2004/09/11 12:41:36  uzadow
|      removed plstdpch.h
|
|      Revision 1.10  2004/09/11 10:30:40  uzadow
|      Linux build fixes, automake dependency fixes.
|
|      Revision 1.9  2004/04/15 20:22:22  uzadow
|      - All test output goes to cerr now.
|      - Fixed behaviour when test images were not available.
|
|      Revision 1.8  2004/04/15 19:09:38  uzadow
|      - Moved TestBmpList to test source, where it is versioned.
|      - All test output goes to cerr now.
|
|      Revision 1.7  2004/03/12 10:31:26  uzadow
|      More robust handling of broken exif data in otherwise correct jpegs.
|
|      Revision 1.6  2003/08/03 16:41:45  uzadow
|      More bigendian combatibility changes.
|
|      Revision 1.5  2003/04/19 19:03:59  uzadow
|      Exif save (windows)
|
|      Revision 1.4  2003/04/19 12:36:03  uzadow
|      Only one exif testpic.
|
|      Revision 1.3  2003/04/18 20:50:24  uzadow
|      no message
|
|      Revision 1.2  2003/04/18 20:35:44  uzadow
|      Linux exif changes, pt 2
|
|      Revision 1.1  2003/04/13 21:51:43  uzadow
|      Added exif loading - windows ver.
|
|      Revision 1.1  2003/04/13 20:13:21  uzadow
|      Added counted pointer classes (windows ver.)
|
|
|
\--------------------------------------------------------------------
*/