#include "raylib.h" #include void fileToBytes(const char *inputFileName, const char *outputFileName, const char *arrayName) { unsigned int fileSize = 0; unsigned char *fileData = LoadFileData(inputFileName, &fileSize); char *content = (char *)MemAlloc(sizeof(char) * fileSize * 10); int cursor = 0; for (unsigned int i = 0; i < fileSize; i++) { TextAppend(content, TextFormat(" 0x%02x,\n", fileData[i]), &cursor); } cursor = 0; char *final = (char *)MemAlloc((sizeof("const unsigned char ") + sizeof("[] = {\n") + (fileSize * sizeof(" 0x00,\n")) + sizeof("};") + strlen(arrayName)) * sizeof(char)); TextAppend(final, "const unsigned char ", &cursor); TextAppend(final, arrayName, &cursor); TextAppend(final, TextFormat("[%d] = {\n", fileSize), &cursor); TextAppend(final, content, &cursor); TextAppend(final, " };", &cursor); MemFree(content); SaveFileText(outputFileName, final); MemFree(final); }