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

Function IwiInitMipmaps

DevIL/src-IL/src/il_iwi.cpp:257–285  ·  view source on GitHub ↗

Function to intialize the mipmaps and determine the number of mipmaps.

Source from the content-addressed store, hash-verified

255
256// Function to intialize the mipmaps and determine the number of mipmaps.
257ILboolean IwiInitMipmaps(ILimage *BaseImage, ILuint *NumMips)
258{
259 ILimage *Image;
260 ILuint Width, Height, Mipmap;
261
262 Image = BaseImage;
263 Width = BaseImage->Width; Height = BaseImage->Height;
264 Image->Origin = IL_ORIGIN_UPPER_LEFT;
265
266 for (Mipmap = 0; Width != 1 && Height != 1; Mipmap++) {
267 // 1 is the smallest dimension possible.
268 Width = (Width >> 1) == 0 ? 1 : (Width >> 1);
269 Height = (Height >> 1) == 0 ? 1 : (Height >> 1);
270
271 Image->Mipmaps = ilNewImageFull(Width, Height, 1, BaseImage->Bpp, BaseImage->Format, BaseImage->Type, NULL);
272 if (Image->Mipmaps == NULL)
273 return IL_FALSE;
274 Image = Image->Mipmaps;
275
276 // ilNewImage does not set these.
277 Image->Format = BaseImage->Format;
278 Image->Type = BaseImage->Type;
279 // The origin is in the upper left.
280 Image->Origin = IL_ORIGIN_UPPER_LEFT;
281 }
282
283 *NumMips = Mipmap;
284 return IL_TRUE;
285}
286
287
288ILboolean IwiReadImage(ILimage *BaseImage, IWIHEAD *Header, ILuint NumMips)

Callers 1

iLoadIwiInternalFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected