38{
40 {
42 }
43
44 NSCParameterAssert(height > 0);
45
46 height *= 2;
50
52 uint32_t *pixel = outPixMap.
pixels;
53 float fheight = height;
54 float rheight = 1.0f / fheight;
55
56 float halfSize = (sourcePixMap.
width - 1) * 0.5f;
57 uint8_t *srcBytes = sourcePixMap.
pixels;
58
59
60 float sinTable[width];
61 float cosTable[width];
62 for (
x = 0;
x < width;
x++)
63 {
64 float lon = ((float)
x * rheight) *
kPiF;
65 sinTable[
x] = sin(lon);
66 cosTable[
x] = cos(lon);
67 }
68
69 for (
y = 0;
y < height;
y++)
70 {
71
72
73
74
75
76
77
78
79
80
81 float cy = -sinTable[width * 3 / 4 -
y];
82 float lac = -cosTable[width * 3 / 4 -
y];
83 float ay = fabs(cy);
84
85 for (
x = 0;
x < width;
x++)
86 {
87 float cx = sinTable[
x] * lac;
88 float cz = cosTable[
x] * lac;
89
90 float ax = fabs(cx);
91 float az = fabs(cz);
92
93
95
96
98
99
100 if (ax >= ay && ax >= az)
101 {
104 r = ax;
105 if (0.0f < cx)
106 {
107 yOffset = 0;
108 }
109 else
110 {
112 yOffset = 1;
113 }
114 }
115 else if (ay >= ax && ay >= az)
116 {
119 r = ay;
120 if (0.0f < cy)
121 {
123 yOffset = 2;
124 }
125 else
126 {
127 yOffset = 3;
128 }
129 }
130 else
131 {
134 r = az;
135 if (0.0f < cz)
136 {
138 yOffset = 5;
139 }
140 else
141 {
142 yOffset = 4;
143 }
144 }
145
146
147 r = 1.0f / r;
150
151#ifndef NDEBUG
152 assert(ix < sourcePixMap.
width && iy < sourcePixMap.
width);
153#endif
154
155
156 iy += sourcePixMap.
width * yOffset;
157
158 uint32_t *row = (uint32_t *)(srcBytes + iy * sourcePixMap.
rowBytes);
159 *pixel++ = row[ix];
160 }
161 }
162
163
164 return OOScalePixMap(outPixMap, width / 2, height / 2, leaveSpaceForMipMaps);
165}
uint_fast32_t OOPixMapDimension
const OOPixMap kOONullPixMap
OOPixMap OOAllocatePixMap(OOPixMapDimension width, OOPixMapDimension height, OOPixMapFormat format, size_t rowBytes, size_t bufferSize)
BOOL OOIsValidPixMap(OOPixMap pixMap)
OOPixMap OOScalePixMap(OOPixMap srcPixMap, OOPixMapDimension dstWidth, OOPixMapDimension dstHeight, BOOL leaveSpaceForMipMaps)