MCPcopy Create free account
hub / github.com/DentonW/DevIL / iluScale2DLinear_

Function iluScale2DLinear_

DevIL/src-ILU/src/ilu_scale2d.cpp:116–195  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

114
115
116ILimage *iluScale2DLinear_(ILimage *Image, ILimage *Scaled, ILuint Width, ILuint Height)
117{
118 ImgBps = Image->Bps / Image->Bpc;
119 SclBps = Scaled->Bps / Scaled->Bpc;
120
121 switch (Image->Bpc)
122 {
123 case 1:
124 for (y = 0; y < Height; y++) {
125 NewY1 = (ILuint)(y / ScaleY) * ImgBps;
126 for (x = 0; x < Width; x++) {
127 t1 = x / (ILdouble)Width;
128 t4 = t1 * Width;
129 t2 = t4 - (ILuint)(t4);
130 ft = t2 * IL_PI;
131 f = (1.0 - cos(ft)) * .5;
132 NewX1 = ((ILuint)(t4 / ScaleX)) * Image->Bpp;
133 NewX2 = ((ILuint)(t4 / ScaleX) + 1) * Image->Bpp;
134
135 Size = y * SclBps + x * Scaled->Bpp;
136 for (c = 0; c < Scaled->Bpp; c++) {
137 x1 = Image->Data[NewY1 + NewX1 + c];
138 x2 = Image->Data[NewY1 + NewX2 + c];
139 Scaled->Data[Size + c] = (ILubyte)((1.0 - f) * x1 + f * x2);
140 }
141 }
142 }
143 break;
144
145 case 2:
146 ShortPtr = (ILushort*)Image->Data;
147 SShortPtr = (ILushort*)Scaled->Data;
148 for (y = 0; y < Height; y++) {
149 NewY1 = (ILuint)(y / ScaleY) * ImgBps;
150 for (x = 0; x < Width; x++) {
151 t1 = x / (ILdouble)Width;
152 t4 = t1 * Width;
153 t2 = t4 - (ILuint)(t4);
154 ft = t2 * IL_PI;
155 f = (1.0 - cos(ft)) * .5;
156 NewX1 = ((ILuint)(t4 / ScaleX)) * Image->Bpp;
157 NewX2 = ((ILuint)(t4 / ScaleX) + 1) * Image->Bpp;
158
159 Size = y * SclBps + x * Scaled->Bpp;
160 for (c = 0; c < Scaled->Bpp; c++) {
161 x1 = ShortPtr[NewY1 + NewX1 + c];
162 x2 = ShortPtr[NewY1 + NewX2 + c];
163 SShortPtr[Size + c] = (ILushort)((1.0 - f) * x1 + f * x2);
164 }
165 }
166 }
167 break;
168
169 case 4:
170 IntPtr = (ILuint*)Image->Data;
171 SIntPtr = (ILuint*)Scaled->Data;
172 for (y = 0; y < Height; y++) {
173 NewY1 = (ILuint)(y / ScaleY) * ImgBps;

Callers 1

iluScale2D_Function · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected