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

Function XpmGetColour

DevIL/src-IL/src/il_xpm.cpp:437–541  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

435ILboolean XpmGetColour(ILubyte *Buffer, ILint Size, int Len, XPMHASHENTRY **Table)
436#else
437ILboolean XpmGetColour(ILubyte *Buffer, ILint Size, int Len, XpmPixel* Colours)
438#endif
439{
440 ILint i = 0, j, strLen = 0;
441 ILubyte ColBuff[3];
442 char Buff[1024];
443
444 XpmPixel Colour;
445 ILubyte Name[XPM_MAX_CHAR_PER_PIXEL];
446
447 for ( ; i < Size; i++) {
448 if (Buffer[i] == '\"')
449 break;
450 }
451 i++; // Skip the quotes.
452
453 if (i >= Size)
454 return IL_FALSE;
455
456 // Get the characters.
457 for (j = 0; j < Len; ++j) {
458 Name[j] = Buffer[i++];
459 }
460
461 // Skip to the colour definition.
462 for ( ; i < Size; i++) {
463 if (Buffer[i] == 'c')
464 break;
465 }
466 i++; // Skip the 'c'.
467
468 if (i >= Size || Buffer[i] != ' ') { // no 'c' found...assume black
469#ifndef XPM_DONT_USE_HASHTABLE
470 memset(Colour, 0, sizeof(Colour));
471 Colour[3] = 255;
472 XpmInsertEntry(Table, Name, Len, Colour);
473#else
474 memset(Colours[Name[0]], 0, sizeof(Colour));
475 Colours[Name[0]][3] = 255;
476#endif
477 return IL_TRUE;
478 }
479
480 for ( ; i < Size; i++) {
481 if (Buffer[i] != ' ')
482 break;
483 }
484
485 if (i >= Size)
486 return IL_FALSE;
487
488 if (Buffer[i] == '#') {
489 // colour string may 4 digits/color or 1 digit/color
490 // (added 20040218) TODO: is isxdigit() ANSI???
491 ++i;
492 while (i + strLen < Size && isxdigit(Buffer[i + strLen]))
493 ++strLen;
494

Callers 1

il_xpm.cppFile · 0.85

Calls 2

XpmInsertEntryFunction · 0.85
XpmPredefColFunction · 0.85

Tested by

no test coverage detected