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

Function ReadCMYK

DevIL/src-IL/src/il_psd.cpp:433–525  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

431
432
433ILboolean ReadCMYK(PSDHEAD *Head)
434{
435 ILuint ColorMode, ResourceSize, MiscInfo, Size, i, j;
436 ILushort Compressed;
437 ILenum Format, Type;
438 ILubyte *Resources = NULL, *KChannel = NULL;
439
440 ColorMode = GetBigUInt(); // Skip over the 'color mode data section'
441 iseek(ColorMode, IL_SEEK_CUR);
442
443 ResourceSize = GetBigUInt(); // Read the 'image resources section'
444 Resources = (ILubyte*)ialloc(ResourceSize);
445 if (Resources == NULL) {
446 return IL_FALSE;
447 }
448 if (iread(Resources, 1, ResourceSize) != ResourceSize)
449 goto cleanup_error;
450
451 MiscInfo = GetBigUInt();
452 iseek(MiscInfo, IL_SEEK_CUR);
453
454 Compressed = GetBigUShort();
455
456 switch (Head->Channels)
457 {
458 case 4:
459 Format = IL_RGB;
460 ChannelNum = 4;
461 Head->Channels = 3;
462 break;
463 case 5:
464 Format = IL_RGBA;
465 ChannelNum = 5;
466 Head->Channels = 4;
467 break;
468 default:
469 ilSetError(IL_FORMAT_NOT_SUPPORTED);
470 return IL_FALSE;
471 }
472 switch (Head->Depth)
473 {
474 case 8:
475 Type = IL_UNSIGNED_BYTE;
476 break;
477 case 16:
478 Type = IL_UNSIGNED_SHORT;
479 break;
480 default:
481 ilSetError(IL_FORMAT_NOT_SUPPORTED);
482 return IL_FALSE;
483 }
484 if (!ilTexImage(Head->Width, Head->Height, 1, (ILubyte)Head->Channels, Format, Type, NULL))
485 goto cleanup_error;
486 if (!PsdGetData(Head, iCurImage->Data, (ILboolean)Compressed))
487 goto cleanup_error;
488
489 Size = iCurImage->Bpc * iCurImage->Width * iCurImage->Height;
490 KChannel = (ILubyte*)ialloc(Size);

Callers 1

ReadPsdFunction · 0.85

Calls 6

GetBigUIntFunction · 0.85
GetBigUShortFunction · 0.85
ilSetErrorFunction · 0.85
PsdGetDataFunction · 0.85
GetSingleChannelFunction · 0.85
ParseResourcesFunction · 0.85

Tested by

no test coverage detected