1
// ==========================================================
2
// FreeImage 3 Test Script
4
// Design and implementation by
5
// - Herv� Drolon (drolon@infonie.fr)
7
// This file is part of FreeImage 3
9
// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY
10
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES
11
// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE
12
// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED
13
// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT
14
// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY
15
// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL
16
// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER
19
// Use at your own risk!
20
// ==========================================================
23
#include "TestSuite.h"
26
// ----------------------------------------------------------
28
/** Create a Zone Plate test pattern.
30
The circular zone plate has zero horizontal and vertical frequencies at the center.
31
Horizontal frequencies increase as you move horizontally, and vertical frequencies increase as you move vertically.
32
These patterns are useful to:
34
<li> evaluate image compression
35
<li> evaluate filter properties
36
<li> evaluate the quality of resampling algorithms
37
<li> adjust gamma correction - at the proper gamma setting, the m�ires should be minimized
40
[1] Ken Turkowski, Open Source Repository. [Online] http://www.worldserver.com/turk/opensource/
42
FIBITMAP* createZonePlateImage(unsigned width, unsigned height, int scale) {
43
const double PI = 3.1415926535898;
50
// allocate a 8-bit dib
51
dst = FreeImage_Allocate(width, height, 8);
55
// build a greyscale palette
56
RGBQUAD *pal = FreeImage_GetPalette(dst);
57
for(i = 0; i < 256; i++) {
63
// build the sinus table
64
for(i = 0; i < 256; i++) {
65
sinTab[i] = (BYTE)(127.5 * sin(PI * (i - 127.5) / 127.5) + 127.5);
71
// create a zone plate
72
for(i = height, y = -cY; i--; y++) {
73
BYTE *dst_bits = FreeImage_GetScanLine(dst, i);
74
for (j = width, x = -cX; j--; x++) {
75
d = ((x * x + y * y) * scale) >> 8;
76
dst_bits[j] = sinTab[d & 0xFF];