File: pltestpixelformat.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 (139 lines) | stat: -rw-r--r-- 5,205 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
/*
/--------------------------------------------------------------------
|
|      $Id: pltestpixelformat.cpp,v 1.3 2004/10/02 22:23:13 uzadow Exp $
|
|      Copyright (c) 1996-2002 Ulrich von Zadow
|
\--------------------------------------------------------------------
*/

#include "pltestpixelformat.h"
#include "plpixelformat.h"
#include "pltester.h"

#include <iostream>
#include <string>
#include <fstream>
#include <iomanip>

using namespace std;

PLTestPixelFormat ::PLTestPixelFormat  ()
{
}

PLTestPixelFormat ::~PLTestPixelFormat  ()
{
}

void PLTestPixelFormat ::RunTests ()
{
  cerr << "  Testing PixelFormat L16" << endl;
  cerr << "    GetBitsPerPixel..." << endl;
  Test(PLPixelFormat::L16.GetBitsPerPixel()==16);
  cerr << "    GetMask..." << endl;
  Test(PLPixelFormat::L16.GetMask(PLPixelFormat::L)==0x0000ffff);
  cerr << "    HasAlpha..." << endl;
  Test(PLPixelFormat::L16.HasAlpha()==false);
  cerr << "    IsGrayscale..." << endl;
  Test(PLPixelFormat::L16.IsGrayscale()==true);
  cerr << "    GetName..." << endl;
  Test(PLPixelFormat::L16.GetName()=="L16");

  cerr << "  Testing PixelFormat R8G8B8..." << endl;
  cerr << "    GetBitsPerPixel..." << endl;
  Test(PLPixelFormat::R8G8B8.GetBitsPerPixel()==24);
  cerr << "    GetMask..." << endl;
  Test(PLPixelFormat::R8G8B8.GetMask(PLPixelFormat::R)==0x00ff0000);
  Test(PLPixelFormat::R8G8B8.GetMask(PLPixelFormat::G)==0x0000ff00);
  Test(PLPixelFormat::R8G8B8.GetMask(PLPixelFormat::B)==0x000000ff);
  cerr << "    HasAlpha..." << endl;
  Test(PLPixelFormat::R8G8B8.HasAlpha()==false);
  cerr << "    IsGrayscale..." << endl;
  Test(PLPixelFormat::R8G8B8.IsGrayscale()==false);
  cerr << "    GetName..." << endl;
  Test(PLPixelFormat::R8G8B8.GetName()=="R8G8B8");
  Test(PLPixelFormat::R8G8B8.GetRGBSwapped()==PLPixelFormat::B8G8R8);

  cerr << "  Testing PixelFormat A8R8G8B8..." << endl;
  cerr << "    GetBitsPerPixel..." << endl;
  Test(PLPixelFormat::A8R8G8B8.GetBitsPerPixel()==32);
  cerr << "    GetMask..." << endl;
  Test(PLPixelFormat::A8R8G8B8.GetMask(PLPixelFormat::A)==0xff000000);
  Test(PLPixelFormat::A8R8G8B8.GetMask(PLPixelFormat::R)==0x00ff0000);
  Test(PLPixelFormat::A8R8G8B8.GetMask(PLPixelFormat::G)==0x0000ff00);
  Test(PLPixelFormat::A8R8G8B8.GetMask(PLPixelFormat::B)==0x000000ff);
  cerr << "    HasAlpha..." << endl;
  Test(PLPixelFormat::A8R8G8B8.HasAlpha()==true);
  cerr << "    IsGrayscale..." << endl;
  Test(PLPixelFormat::A8R8G8B8.IsGrayscale()==false);
  cerr << "    GetName..." << endl;
  Test(PLPixelFormat::A8R8G8B8.GetName()=="A8R8G8B8");
  Test(PLPixelFormat::A8R8G8B8.GetRGBSwapped()==PLPixelFormat::A8B8G8R8);

  cerr << "  Testing PixelFormat B16G16R16..." << endl;
  cerr << "    GetBitsPerPixel..." << endl;
  Test(PLPixelFormat::B16G16R16.GetBitsPerPixel()==48);
  cerr << "    GetMask..." << endl;
  Test(PLPixelFormat::B16G16R16.GetMask(PLPixelFormat::R)==0x000000000000ffff);
  Test(PLPixelFormat::B16G16R16.GetMask(PLPixelFormat::G)==0x00000000ffff0000);
  Test(PLPixelFormat::B16G16R16.GetMask(PLPixelFormat::B)==
       ((PLPixelFormat::Mask)0xffff) << 32);  
  cerr << "    HasAlpha..." << endl;
  Test(PLPixelFormat::B16G16R16.HasAlpha()==false);
  cerr << "    IsGrayscale..." << endl;
  Test(PLPixelFormat::B16G16R16.IsGrayscale()==false);
  cerr << "    GetName..." << endl;
  Test(PLPixelFormat::B16G16R16.GetName()=="B16G16R16");

  cerr << "  Testing PixelFormat X1R5G5B5..." << endl;
  cerr << "    GetBitsPerPixel..." << endl;
  Test(PLPixelFormat::X1R5G5B5.GetBitsPerPixel()==16);
  cerr << "    GetMask..." << endl;
  Test(PLPixelFormat::X1R5G5B5.GetMask(PLPixelFormat::R)==0x1f << 10);
  Test(PLPixelFormat::X1R5G5B5.GetMask(PLPixelFormat::G)==0x1f << 5);
  Test(PLPixelFormat::X1R5G5B5.GetMask(PLPixelFormat::B)==0x1f);  
  cerr << "    HasAlpha..." << endl;
  Test(PLPixelFormat::X1R5G5B5.HasAlpha()==false);
  cerr << "    IsGrayscale..." << endl;
  Test(PLPixelFormat::X1R5G5B5.IsGrayscale()==false);
  cerr << "    GetName..." << endl;
  Test(PLPixelFormat::X1R5G5B5.GetName()=="X1R5G5B5");

  cerr << "  Testing fromChannels RGB, 24..." << endl;
  Test(PLPixelFormat::FromChannels("RGB", 24) == PLPixelFormat::R8G8B8);

  cerr << "  Testing fromChannels YCrCb, 8..." << endl;
  bool bOkay = false;
  try {
    PLPixelFormat::FromChannels("YCrCb", 8);
  } catch(PLPixelFormat::UnsupportedPixelFormat&) {
    bOkay = true;
  }
  Test(bOkay);

  cerr << "  Testing fromChannels YCrCb, 8..." << endl;
}

/*
/--------------------------------------------------------------------
|
|      $Log: pltestpixelformat.cpp,v $
|      Revision 1.3  2004/10/02 22:23:13  uzadow
|      - configure and Makefile cleanups\n- Pixelformat enhancements for several filters\n- Added PLBmpBase:Dump\n- Added PLBmpBase::GetPixelNn()-methods\n- Changed default unix byte order to BGR
|
|      Revision 1.2  2004/09/15 15:26:23  uzadow
|      Linux compatibility changes, doc update.
|
|      Revision 1.1  2004/09/15 14:52:09  artcom
|      - added PLPixelformatTest
|      - added DICOM Decoder
|
|      Revision 1.1  2003/04/13 20:13:21  uzadow
|      Added counted pointer classes (windows ver.)
|
|
|
\--------------------------------------------------------------------
*/