c
<     *outptr++ = colormap[0][t];
---
>     if (t >= 0) {
>         for (int i = 0; i < cmaplen; i++) {
>             if (t == i) {
>                 *outptr++ = colormap[0][t];
>                 break;
>             }
>         }
>     } else {
>         // Handle out-of-bounds error
>         *outptr++ = 0; // or some other default value
>     }
