380{
382 BOOL rescale;
383 size_t newSize;
384 uint8_t components;
386
388
389
393
395
397 {
399 {
401 components = 1;
402 }
403 else
404 {
405 OOLogWARN(
@"texture.load.extractChannel.invalid",
@"Cannot extract channel from texture \"%@\
"", [
_path lastPathComponent]);
406 }
407 }
408
409 [self getDesiredWidth:&desiredWidth andHeight:&desiredHeight];
410
412 {
414 desiredHeight =
MIN(desiredWidth * 2, 512U);
416 desiredWidth = desiredHeight * 2;
417
420 pixMap = converted;
422
423#if DUMP_CONVERTED_CUBE_MAPS
424 OODumpPixMap(pixMap, [NSString stringWithFormat:
@"converted cube map %@", [[
_path lastPathComponent] stringByDeletingPathExtension]]);
425#endif
426 }
427
428
429 rescale = (
_width != desiredWidth ||
_height != desiredHeight);
430 if (rescale)
431 {
433#if OO_TEXTURE_CUBE_MAP
435#endif
436
437 OOLog(
@"texture.load.rescale",
@"Rescaling texture \"%@\
" from %u x %u to %u x %u.", [
_path lastPathComponent], pixMap.
width, pixMap.
height, desiredWidth, desiredHeight);
438
439 pixMap =
OOScalePixMap(pixMap, desiredWidth, desiredHeight, leaveSpaceForMipMaps);
441
446 }
447
448#if OO_TEXTURE_CUBE_MAP
450 {
452 {
453 [self generateMipMapsForCubeMap];
454 }
455 return;
456 }
457#endif
458
459
461 {
462
463 newSize = desiredWidth * components * desiredHeight;
464 newSize = (newSize * 4) / 3;
465
467
472 }
474 {
476 }
477
478
479}
OOPixMap OOConvertCubeMapToLatLong(OOPixMap sourcePixMap, OOPixMapDimension height, BOOL leaveSpaceForMipMaps)
#define OOLogWARN(class, format,...)
#define OOLog(class, format,...)
BOOL OOExtractPixMapChannel(OOPixMap *ioPixMap, uint8_t channelIndex, BOOL compactWhenDone)
BOOL OOPixMapToRGBA(OOPixMap *ioPixMap)
uint_fast32_t OOPixMapDimension
void OOFreePixMap(OOPixMap *ioPixMap)
void OODumpPixMap(OOPixMap pixMap, NSString *name)
OOPixMap OOMakePixMap(void *pixels, OOPixMapDimension width, OOPixMapDimension height, OOPixMapFormat format, size_t rowBytes, size_t bufferSize)
BOOL OOIsValidPixMap(OOPixMap pixMap)
BOOL OOExpandPixMap(OOPixMap *ioPixMap, size_t desiredSize)
static BOOL sReducedDetail
OOPixMap OOScalePixMap(OOPixMap srcPixMap, OOPixMapDimension dstWidth, OOPixMapDimension dstHeight, BOOL leaveSpaceForMipMaps)
BOOL OOGenerateMipMaps(void *textureBytes, OOPixMapDimension width, OOPixMapDimension height, OOPixMapFormat format)
BOOL OOCubeMapsAvailable(void)
uint8_t OOTextureComponentsForFormat(OOTextureDataFormat format)
@ kOOTextureDataGrayscale
OOTextureDataFormat _format
uint8_t _extractChannelIndex