67#if !defined(EXTERNAL_CONFIG_FLAGS)
71#if defined(SUPPORT_MODULE_RTEXTURES)
82#if !defined(SUPPORT_FILEFORMAT_BMP)
85#if !defined(SUPPORT_FILEFORMAT_PNG)
88#if !defined(SUPPORT_FILEFORMAT_TGA)
91#if !defined(SUPPORT_FILEFORMAT_JPG)
94#if !defined(SUPPORT_FILEFORMAT_PSD)
97#if !defined(SUPPORT_FILEFORMAT_GIF)
100#if !defined(SUPPORT_FILEFORMAT_PIC)
103#if !defined(SUPPORT_FILEFORMAT_HDR)
111#if defined(__TINYC__)
115#if (defined(SUPPORT_FILEFORMAT_BMP) || \
116 defined(SUPPORT_FILEFORMAT_PNG) || \
117 defined(SUPPORT_FILEFORMAT_TGA) || \
118 defined(SUPPORT_FILEFORMAT_JPG) || \
119 defined(SUPPORT_FILEFORMAT_PSD) || \
120 defined(SUPPORT_FILEFORMAT_GIF) || \
121 defined(SUPPORT_FILEFORMAT_PIC) || \
122 defined(SUPPORT_FILEFORMAT_HDR))
124 #define STBI_MALLOC RL_MALLOC
125 #define STBI_FREE RL_FREE
126 #define STBI_REALLOC RL_REALLOC
128 #define STB_IMAGE_IMPLEMENTATION
133#if defined(SUPPORT_FILEFORMAT_QOI)
134 #define QOI_MALLOC RL_MALLOC
135 #define QOI_FREE RL_FREE
137 #define QOI_IMPLEMENTATION
141#if defined(SUPPORT_IMAGE_EXPORT)
142 #define STBIW_MALLOC RL_MALLOC
143 #define STBIW_FREE RL_FREE
144 #define STBIW_REALLOC RL_REALLOC
146 #define STB_IMAGE_WRITE_IMPLEMENTATION
150#if defined(SUPPORT_IMAGE_MANIPULATION)
151 #define STBIR_MALLOC(size,c) ((void)(c), RL_MALLOC(size))
152 #define STBIR_FREE(ptr,c) ((void)(c), RL_FREE(ptr))
154 #define STB_IMAGE_RESIZE_IMPLEMENTATION
161#ifndef PIXELFORMAT_UNCOMPRESSED_R5G5B5A1_ALPHA_THRESHOLD
162 #define PIXELFORMAT_UNCOMPRESSED_R5G5B5A1_ALPHA_THRESHOLD 50
183#if defined(SUPPORT_FILEFORMAT_DDS)
184static Image LoadDDS(
const unsigned char *fileData,
unsigned int fileSize);
186#if defined(SUPPORT_FILEFORMAT_PKM)
187static Image LoadPKM(
const unsigned char *fileData,
unsigned int fileSize);
189#if defined(SUPPORT_FILEFORMAT_KTX)
190static Image LoadKTX(
const unsigned char *fileData,
unsigned int fileSize);
191static int SaveKTX(
Image image,
const char *fileName);
193#if defined(SUPPORT_FILEFORMAT_PVR)
194static Image LoadPVR(
const unsigned char *fileData,
unsigned int fileSize);
196#if defined(SUPPORT_FILEFORMAT_ASTC)
197static Image LoadASTC(
const unsigned char *fileData,
unsigned int fileSize);
211#if defined(SUPPORT_FILEFORMAT_PNG) || \
212 defined(SUPPORT_FILEFORMAT_BMP) || \
213 defined(SUPPORT_FILEFORMAT_TGA) || \
214 defined(SUPPORT_FILEFORMAT_JPG) || \
215 defined(SUPPORT_FILEFORMAT_GIF) || \
216 defined(SUPPORT_FILEFORMAT_PIC) || \
217 defined(SUPPORT_FILEFORMAT_HDR) || \
218 defined(SUPPORT_FILEFORMAT_PSD)
220 #define STBI_REQUIRED
224 unsigned int fileSize = 0;
225 unsigned char *fileData =
LoadFileData(fileName, &fileSize);
240 unsigned int dataSize = 0;
241 unsigned char *fileData =
LoadFileData(fileName, &dataSize);
243 if (fileData !=
NULL)
245 unsigned char *dataPtr = fileData;
248 if (headerSize > 0) dataPtr += headerSize;
251 memcpy(image.
data, dataPtr, size);
273#if defined(SUPPORT_FILEFORMAT_GIF)
276 unsigned int dataSize = 0;
277 unsigned char *fileData =
LoadFileData(fileName, &dataSize);
279 if (fileData !=
NULL)
299 *frames = frameCount;
311 || (strcmp(fileType,
".png") == 0)
313#
if defined(SUPPORT_FILEFORMAT_BMP)
314 || (strcmp(fileType,
".bmp") == 0)
316#
if defined(SUPPORT_FILEFORMAT_TGA)
317 || (strcmp(fileType,
".tga") == 0)
319#
if defined(SUPPORT_FILEFORMAT_JPG)
320 || ((strcmp(fileType,
".jpg") == 0) || (strcmp(fileType,
".jpeg") == 0))
323 || (strcmp(fileType,
".gif") == 0)
325#
if defined(SUPPORT_FILEFORMAT_PIC)
326 || (strcmp(fileType,
".pic") == 0)
328#
if defined(SUPPORT_FILEFORMAT_PSD)
329 || (strcmp(fileType,
".psd") == 0)
333#if defined(STBI_REQUIRED)
336 if (fileData !=
NULL)
353#if defined(SUPPORT_FILEFORMAT_HDR)
354 else if (strcmp(fileType,
".hdr") == 0)
356#if defined(STBI_REQUIRED)
357 if (fileData !=
NULL)
376#if defined(SUPPORT_FILEFORMAT_QOI)
377 else if (strcmp(fileType,
".qoi") == 0)
387#if defined(SUPPORT_FILEFORMAT_DDS)
388 else if (strcmp(fileType,
".dds") == 0) image = LoadDDS(fileData, dataSize);
390#if defined(SUPPORT_FILEFORMAT_PKM)
391 else if (strcmp(fileType,
".pkm") == 0) image = LoadPKM(fileData, dataSize);
393#if defined(SUPPORT_FILEFORMAT_KTX)
394 else if (strcmp(fileType,
".ktx") == 0) image = LoadKTX(fileData, dataSize);
396#if defined(SUPPORT_FILEFORMAT_PVR)
397 else if (strcmp(fileType,
".pvr") == 0) image = LoadPVR(fileData, dataSize);
399#if defined(SUPPORT_FILEFORMAT_ASTC)
400 else if (strcmp(fileType,
".astc") == 0) image = LoadASTC(fileData, dataSize);
427#if defined(GRAPHICS_API_OPENGL_ES2)
468#if defined(SUPPORT_IMAGE_EXPORT)
470 bool allocatedData =
false;
471 unsigned char *imgData = (
unsigned char *)image.
data;
481 allocatedData =
true;
484#if defined(SUPPORT_FILEFORMAT_PNG)
488 unsigned char *fileData = stbi_write_png_to_mem((
const unsigned char *)imgData, image.
width*channels, image.
width, image.
height, channels, &dataSize);
495#if defined(SUPPORT_FILEFORMAT_BMP)
498#if defined(SUPPORT_FILEFORMAT_TGA)
501#if defined(SUPPORT_FILEFORMAT_JPG)
505#if defined(SUPPORT_FILEFORMAT_QOI)
513 if ((channels == 3) || (channels == 4))
521 success =
qoi_write(fileName, imgData, &desc);
525#if defined(SUPPORT_FILEFORMAT_KTX)
526 else if (
IsFileExtension(fileName,
".ktx")) success = SaveKTX(image, fileName);
535 if (allocatedData)
RL_FREE(imgData);
538 if (success != 0)
TRACELOG(
LOG_INFO,
"FILEIO: [%s] Image exported successfully", fileName);
547 bool success =
false;
549#if defined(SUPPORT_IMAGE_EXPORT)
551#ifndef TEXT_BYTES_PER_LINE
552 #define TEXT_BYTES_PER_LINE 20
559 char *txtData = (
char *)
RL_CALLOC(dataSize*6 + 2000,
sizeof(
char));
562 byteCount += sprintf(txtData + byteCount,
"////////////////////////////////////////////////////////////////////////////////////////\n");
563 byteCount += sprintf(txtData + byteCount,
"// //\n");
564 byteCount += sprintf(txtData + byteCount,
"// ImageAsCode exporter v1.0 - Image pixel data exported as an array of bytes //\n");
565 byteCount += sprintf(txtData + byteCount,
"// //\n");
566 byteCount += sprintf(txtData + byteCount,
"// more info and bugs-report: github.com/raysan5/raylib //\n");
567 byteCount += sprintf(txtData + byteCount,
"// feedback and support: ray[at]raylib.com //\n");
568 byteCount += sprintf(txtData + byteCount,
"// //\n");
569 byteCount += sprintf(txtData + byteCount,
"// Copyright (c) 2018-2022 Ramon Santamaria (@raysan5) //\n");
570 byteCount += sprintf(txtData + byteCount,
"// //\n");
571 byteCount += sprintf(txtData + byteCount,
"////////////////////////////////////////////////////////////////////////////////////////\n\n");
574 char varFileName[256] = { 0 };
576 for (
int i = 0; varFileName[i] !=
'\0'; i++)
if ((varFileName[i] >=
'a') && (varFileName[i] <=
'z')) { varFileName[i] = varFileName[i] - 32; }
579 byteCount += sprintf(txtData + byteCount,
"// Image data information\n");
580 byteCount += sprintf(txtData + byteCount,
"#define %s_WIDTH %i\n", varFileName, image.
width);
581 byteCount += sprintf(txtData + byteCount,
"#define %s_HEIGHT %i\n", varFileName, image.
height);
582 byteCount += sprintf(txtData + byteCount,
"#define %s_FORMAT %i // raylib internal pixel format\n\n", varFileName, image.
format);
584 byteCount += sprintf(txtData + byteCount,
"static unsigned char %s_DATA[%i] = { ", varFileName, dataSize);
585 for (
int i = 0; i < dataSize - 1; i++) byteCount += sprintf(txtData + byteCount, ((i%
TEXT_BYTES_PER_LINE == 0)?
"0x%x,\n" :
"0x%x, "), ((
unsigned char *)image.
data)[i]);
586 byteCount += sprintf(txtData + byteCount,
"0x%x };\n", ((
unsigned char *)image.
data)[dataSize - 1]);
595 if (success != 0)
TRACELOG(
LOG_INFO,
"FILEIO: [%s] Image as code exported successfully", fileName);
609 for (
int i = 0; i < width*height; i++) pixels[i] = color;
622#if defined(SUPPORT_IMAGE_GENERATION)
628 for (
int j = 0; j < height; j++)
630 float factor = (float)j/(
float)height;
631 for (
int i = 0; i < width; i++)
633 pixels[j*width + i].
r = (int)((
float)bottom.
r*factor + (float)top.
r*(1.f - factor));
634 pixels[j*width + i].
g = (int)((
float)bottom.
g*factor + (float)top.
g*(1.f - factor));
635 pixels[j*width + i].
b = (int)((
float)bottom.
b*factor + (float)top.
b*(1.f - factor));
636 pixels[j*width + i].
a = (int)((
float)bottom.
a*factor + (float)top.
a*(1.f - factor));
656 for (
int i = 0; i < width; i++)
658 float factor = (float)i/(
float)width;
659 for (
int j = 0; j < height; j++)
661 pixels[j*width + i].
r = (int)((
float)right.
r*factor + (float)left.
r*(1.f - factor));
662 pixels[j*width + i].
g = (int)((
float)right.
g*factor + (float)left.
g*(1.f - factor));
663 pixels[j*width + i].
b = (int)((
float)right.
b*factor + (float)left.
b*(1.f - factor));
664 pixels[j*width + i].
a = (int)((
float)right.
a*factor + (float)left.
a*(1.f - factor));
683 float radius = (width < height)? (
float)width/2.0f : (float)height/2.0f;
685 float centerX = (float)width/2.0f;
686 float centerY = (float)height/2.0f;
688 for (
int y = 0; y < height; y++)
690 for (
int x = 0; x < width; x++)
692 float dist = hypotf((
float)x - centerX, (
float)y - centerY);
693 float factor = (dist - radius*density)/(radius*(1.0f - density));
695 factor = (float)fmax(factor, 0.0f);
696 factor = (float)fmin(factor, 1.f);
698 pixels[y*width + x].
r = (int)((
float)outer.
r*factor + (float)inner.
r*(1.0f - factor));
699 pixels[y*width + x].
g = (int)((
float)outer.
g*factor + (float)inner.
g*(1.0f - factor));
700 pixels[y*width + x].
b = (int)((
float)outer.
b*factor + (float)inner.
b*(1.0f - factor));
701 pixels[y*width + x].
a = (int)((
float)outer.
a*factor + (float)inner.
a*(1.0f - factor));
721 for (
int y = 0; y < height; y++)
723 for (
int x = 0; x < width; x++)
725 if ((x/checksX + y/checksY)%2 == 0) pixels[y*width + x] = col1;
726 else pixels[y*width + x] = col2;
746 for (
int i = 0; i < width*height; i++)
749 else pixels[i] =
BLACK;
768 int seedsPerRow = width/tileSize;
769 int seedsPerCol = height/tileSize;
770 int seedCount = seedsPerRow*seedsPerCol;
774 for (
int i = 0; i < seedCount; i++)
776 int y = (i/seedsPerRow)*tileSize +
GetRandomValue(0, tileSize - 1);
777 int x = (i%seedsPerRow)*tileSize +
GetRandomValue(0, tileSize - 1);
778 seeds[i] = (
Vector2){ (float)x, (
float)y };
781 for (
int y = 0; y < height; y++)
783 int tileY = y/tileSize;
785 for (
int x = 0; x < width; x++)
787 int tileX = x/tileSize;
789 float minDistance = 65536.0f;
792 for (
int i = -1; i < 2; i++)
794 if ((tileX + i < 0) || (tileX + i >= seedsPerRow))
continue;
796 for (
int j = -1; j < 2; j++)
798 if ((tileY + j < 0) || (tileY + j >= seedsPerCol))
continue;
800 Vector2 neighborSeed = seeds[(tileY + j)*seedsPerRow + tileX + i];
802 float dist = (float)hypot(x - (
int)neighborSeed.
x, y - (int)neighborSeed.
y);
803 minDistance = (float)fmin(minDistance, dist);
808 int intensity = (int)(minDistance*256.0f/tileSize);
809 if (intensity > 255) intensity = 255;
811 pixels[y*width + x] = (
Color){ intensity, intensity, intensity, 255 };
835 Image newImage = { 0 };
837 int width = image.
width;
838 int height = image.
height;
841 for (
int i = 0; i < image.
mipmaps; i++)
849 if (width < 1) width = 1;
850 if (height < 1) height = 1;
858 memcpy(newImage.
data, image.
data, size);
872 Image result = { 0 };
882 for (
int y = 0; y < rec.
height; y++)
884 memcpy(((
unsigned char *)result.
data) + y*(
int)rec.
width*bytesPerPixel, ((
unsigned char *)image.
data) + ((y + (
int)rec.
y)*image.
width + (
int)rec.
x)*bytesPerPixel, (
int)rec.
width*bytesPerPixel);
898 if (crop.
x < 0) { crop.
width += crop.
x; crop.
x = 0; }
899 if (crop.
y < 0) { crop.
height += crop.
y; crop.
y = 0; }
914 unsigned char *croppedData = (
unsigned char *)
RL_MALLOC((
int)(crop.
width*crop.
height)*bytesPerPixel);
917 for (
int y = (
int)crop.
y, offsetSize = 0; y < (int)(crop.
y + crop.
height); y++)
919 memcpy(croppedData + offsetSize, ((
unsigned char *)image->
data) + (y*image->
width + (
int)crop.
x)*bytesPerPixel, (
int)crop.
width*bytesPerPixel);
920 offsetSize += ((int)crop.
width*bytesPerPixel);
936 image->
data = croppedData;
948 if ((newFormat != 0) && (image->
format != newFormat))
952 Vector4 *pixels = LoadImageDataNormalized(*image);
956 image->
format = newFormat;
966 for (
int i = 0; i < image->
width*image->
height; i++)
968 ((
unsigned char *)image->
data)[i] = (
unsigned char)((pixels[i].x*0.299f + pixels[i].y*0.587f + pixels[i].z*0.114f)*255.0f);
976 for (
int i = 0; i < image->
width*image->
height*2; i += 2, k++)
978 ((
unsigned char *)image->
data)[i] = (
unsigned char)((pixels[k].x*0.299f + (
float)pixels[k].
y*0.587f + (float)pixels[k].z*0.114f)*255.0f);
979 ((
unsigned char *)image->
data)[i + 1] = (
unsigned char)(pixels[k].w*255.0f);
991 for (
int i = 0; i < image->
width*image->
height; i++)
993 r = (
unsigned char)(round(pixels[i].x*31.0f));
994 g = (
unsigned char)(round(pixels[i].y*63.0f));
995 b = (
unsigned char)(round(pixels[i].z*31.0f));
997 ((
unsigned short *)image->
data)[i] = (
unsigned short)r << 11 | (
unsigned short)g << 5 | (
unsigned short)b;
1005 for (
int i = 0, k = 0; i < image->
width*image->
height*3; i += 3, k++)
1007 ((
unsigned char *)image->
data)[i] = (
unsigned char)(pixels[k].x*255.0f);
1008 ((
unsigned char *)image->
data)[i + 1] = (
unsigned char)(pixels[k].y*255.0f);
1009 ((
unsigned char *)image->
data)[i + 2] = (
unsigned char)(pixels[k].z*255.0f);
1016 unsigned char r = 0;
1017 unsigned char g = 0;
1018 unsigned char b = 0;
1019 unsigned char a = 0;
1021 for (
int i = 0; i < image->
width*image->
height; i++)
1023 r = (
unsigned char)(round(pixels[i].x*31.0f));
1024 g = (
unsigned char)(round(pixels[i].y*31.0f));
1025 b = (
unsigned char)(round(pixels[i].z*31.0f));
1028 ((
unsigned short *)image->
data)[i] = (
unsigned short)r << 11 | (
unsigned short)g << 6 | (
unsigned short)b << 1 | (
unsigned short)a;
1036 unsigned char r = 0;
1037 unsigned char g = 0;
1038 unsigned char b = 0;
1039 unsigned char a = 0;
1041 for (
int i = 0; i < image->
width*image->
height; i++)
1043 r = (
unsigned char)(round(pixels[i].x*15.0f));
1044 g = (
unsigned char)(round(pixels[i].y*15.0f));
1045 b = (
unsigned char)(round(pixels[i].z*15.0f));
1046 a = (
unsigned char)(round(pixels[i].w*15.0f));
1048 ((
unsigned short *)image->
data)[i] = (
unsigned short)r << 12 | (
unsigned short)g << 8 | (
unsigned short)b << 4 | (
unsigned short)a;
1056 for (
int i = 0, k = 0; i < image->
width*image->
height*4; i += 4, k++)
1058 ((
unsigned char *)image->
data)[i] = (
unsigned char)(pixels[k].x*255.0f);
1059 ((
unsigned char *)image->
data)[i + 1] = (
unsigned char)(pixels[k].y*255.0f);
1060 ((
unsigned char *)image->
data)[i + 2] = (
unsigned char)(pixels[k].z*255.0f);
1061 ((
unsigned char *)image->
data)[i + 3] = (
unsigned char)(pixels[k].w*255.0f);
1070 for (
int i = 0; i < image->
width*image->
height; i++)
1072 ((
float *)image->
data)[i] = (float)(pixels[i].x*0.299f + pixels[i].y*0.587f + pixels[i].z*0.114f);
1079 for (
int i = 0, k = 0; i < image->
width*image->
height*3; i += 3, k++)
1081 ((
float *)image->
data)[i] = pixels[k].
x;
1082 ((
float *)image->
data)[i + 1] = pixels[k].
y;
1083 ((
float *)image->
data)[i + 2] = pixels[k].
z;
1090 for (
int i = 0, k = 0; i < image->
width*image->
height*4; i += 4, k++)
1092 ((
float *)image->
data)[i] = pixels[k].
x;
1093 ((
float *)image->
data)[i + 1] = pixels[k].
y;
1094 ((
float *)image->
data)[i + 2] = pixels[k].
z;
1095 ((
float *)image->
data)[i + 3] = pixels[k].
w;
1109 #if defined(SUPPORT_IMAGE_MANIPULATION)
1127 int potWidth = (int)powf(2, ceilf(logf((
float)image->
width)/logf(2)));
1128 int potHeight = (int)powf(2, ceilf(logf((
float)image->
height)/logf(2)));
1134#if defined(SUPPORT_IMAGE_MANIPULATION)
1138 Image imText = { 0 };
1139#if defined(SUPPORT_MODULE_RTEXT)
1140 int defaultFontSize = 10;
1141 if (fontSize < defaultFontSize) fontSize = defaultFontSize;
1142 int spacing = fontSize/defaultFontSize;
1154 Image imText = { 0 };
1155#if defined(SUPPORT_MODULE_RTEXT)
1156 int size = (int)strlen(text);
1158 int textOffsetX = 0;
1159 int textOffsetY = 0;
1167 for (
int i = 0; i < size; i++)
1170 int codepointByteCount = 0;
1171 int codepoint =
GetCodepoint(&text[i], &codepointByteCount);
1176 if (codepoint == 0x3f) codepointByteCount = 1;
1178 if (codepoint ==
'\n')
1187 if ((codepoint !=
' ') && (codepoint !=
'\t'))
1190 ImageDraw(&imText, font.
glyphs[index].
image, (
Rectangle){ 0, 0, (float)font.glyphs[index].image.width, (float)font.glyphs[index].image.height }, rec, tint);
1197 i += (codepointByteCount - 1);
1201 if (fontSize > imSize.
y)
1203 float scaleFactor = fontSize/imSize.
y;
1209 else ImageResize(&imText, (
int)(imSize.
x*scaleFactor), (
int)(imSize.
y*scaleFactor));
1246 unsigned char thresholdValue = (
unsigned char)(threshold*255.0f);
1247 for (
int i = 1; i < image->
width*image->
height*2; i += 2)
1249 if (((
unsigned char *)image->
data)[i] <= thresholdValue)
1251 ((
unsigned char *)image->
data)[i - 1] = color.
r;
1252 ((
unsigned char *)image->
data)[i] = color.
a;
1258 unsigned char thresholdValue = ((threshold < 0.5f)? 0 : 1);
1260 unsigned char r = (
unsigned char)(round((
float)color.
r*31.0f));
1261 unsigned char g = (
unsigned char)(round((
float)color.
g*31.0f));
1262 unsigned char b = (
unsigned char)(round((
float)color.
b*31.0f));
1263 unsigned char a = (color.
a < 128)? 0 : 1;
1265 for (
int i = 0; i < image->
width*image->
height; i++)
1267 if ((((
unsigned short *)image->
data)[i] & 0b0000000000000001) <= thresholdValue)
1269 ((
unsigned short *)image->
data)[i] = (
unsigned short)r << 11 | (
unsigned short)g << 6 | (
unsigned short)b << 1 | (
unsigned short)a;
1275 unsigned char thresholdValue = (
unsigned char)(threshold*15.0f);
1277 unsigned char r = (
unsigned char)(round((
float)color.
r*15.0f));
1278 unsigned char g = (
unsigned char)(round((
float)color.
g*15.0f));
1279 unsigned char b = (
unsigned char)(round((
float)color.
b*15.0f));
1280 unsigned char a = (
unsigned char)(round((
float)color.
a*15.0f));
1282 for (
int i = 0; i < image->
width*image->
height; i++)
1284 if ((((
unsigned short *)image->
data)[i] & 0x000f) <= thresholdValue)
1286 ((
unsigned short *)image->
data)[i] = (
unsigned short)r << 12 | (
unsigned short)g << 8 | (
unsigned short)b << 4 | (
unsigned short)a;
1292 unsigned char thresholdValue = (
unsigned char)(threshold*255.0f);
1293 for (
int i = 3; i < image->
width*image->
height*4; i += 4)
1295 if (((
unsigned char *)image->
data)[i] <= thresholdValue)
1297 ((
unsigned char *)image->
data)[i - 3] = color.
r;
1298 ((
unsigned char *)image->
data)[i - 2] = color.
g;
1299 ((
unsigned char *)image->
data)[i - 1] = color.
b;
1300 ((
unsigned char *)image->
data)[i] = color.
a;
1306 for (
int i = 3; i < image->
width*image->
height*4; i += 4)
1308 if (((
float *)image->
data)[i] <= threshold)
1310 ((
float *)image->
data)[i - 3] = (float)color.
r/255.0f;
1311 ((
float *)image->
data)[i - 2] = (
float)color.
g/255.0f;
1312 ((
float *)image->
data)[i - 1] = (float)color.
b/255.0f;
1313 ((
float *)image->
data)[i] = (
float)color.
a/255.0f;
1347 for (
int i = 0, k = 0; (i < mask.
width*mask.
height) || (i < image->width*image->
height); i++, k += 2)
1349 data[k] = ((
unsigned char *)image->
data)[i];
1350 data[k + 1] = ((
unsigned char *)mask.
data)[i];
1363 for (
int i = 0, k = 3; (i < mask.
width*mask.
height) || (i < image->width*image->
height); i++, k += 4)
1365 ((
unsigned char *)image->
data)[k] = ((
unsigned char *)mask.
data)[i];
1382 for (
int i = 0; i < image->
width*image->
height; i++)
1384 if (pixels[i].a == 0)
1390 else if (pixels[i].a < 255)
1392 alpha = (float)pixels[i].a/255.0f;
1393 pixels[i].
r = (
unsigned char)((
float)pixels[i].
r*alpha);
1394 pixels[i].
g = (
unsigned char)((
float)pixels[i].
g*alpha);
1395 pixels[i].
b = (
unsigned char)((
float)pixels[i].
b*alpha);
1401 int format = image->
format;
1402 image->
data = pixels;
1417 bool fastPath =
true;
1423 unsigned char *output = (
unsigned char *)
RL_MALLOC(newWidth*newHeight*bytesPerPixel);
1435 image->
data = output;
1436 image->
width = newWidth;
1437 image->
height = newHeight;
1448 int format = image->
format;
1453 image->
data = output;
1454 image->
width = newWidth;
1455 image->
height = newHeight;
1472 int xRatio = (int)((image->
width << 16)/newWidth) + 1;
1473 int yRatio = (int)((image->
height << 16)/newHeight) + 1;
1476 for (
int y = 0; y < newHeight; y++)
1478 for (
int x = 0; x < newWidth; x++)
1480 x2 = ((x*xRatio) >> 16);
1481 y2 = ((y*yRatio) >> 16);
1483 output[(y*newWidth) + x] = pixels[(y2*image->
width) + x2] ;
1487 int format = image->
format;
1491 image->
data = output;
1492 image->
width = newWidth;
1493 image->
height = newHeight;
1510 else if ((newWidth != image->
width) || (newHeight != image->
height))
1513 Vector2 dstPos = { (float)offsetX, (
float)offsetY };
1517 srcRec.
x = (float)-offsetX;
1518 srcRec.
width += (float)offsetX;
1521 else if ((offsetX + image->
width) > newWidth) srcRec.
width = (
float)(newWidth - offsetX);
1525 srcRec.
y = (float)-offsetY;
1526 srcRec.
height += (float)offsetY;
1529 else if ((offsetY + image->
height) > newHeight) srcRec.
height = (
float)(newHeight - offsetY);
1531 if (newWidth < srcRec.
width) srcRec.
width = (float)newWidth;
1532 if (newHeight < srcRec.
height) srcRec.
height = (float)newHeight;
1535 unsigned char *resizedData = (
unsigned char *)
RL_CALLOC(newWidth*newHeight*bytesPerPixel, 1);
1539 int dstOffsetSize = ((int)dstPos.
y*newWidth + (
int)dstPos.
x)*bytesPerPixel;
1541 for (
int y = 0; y < (int)srcRec.
height; y++)
1543 memcpy(resizedData + dstOffsetSize, ((
unsigned char *)image->
data) + ((y + (
int)srcRec.
y)*image->
width + (
int)srcRec.
x)*bytesPerPixel, (
int)srcRec.
width*bytesPerPixel);
1544 dstOffsetSize += (newWidth*bytesPerPixel);
1548 image->
data = resizedData;
1549 image->
width = newWidth;
1550 image->
height = newHeight;
1564 int mipWidth = image->
width;
1565 int mipHeight = image->
height;
1569 while ((mipWidth != 1) || (mipHeight != 1))
1571 if (mipWidth != 1) mipWidth /= 2;
1572 if (mipHeight != 1) mipHeight /= 2;
1575 if (mipWidth < 1) mipWidth = 1;
1576 if (mipHeight < 1) mipHeight = 1;
1578 TRACELOGD(
"IMAGE: Next mipmap level: %i x %i - current size %i", mipWidth, mipHeight, mipSize);
1584 if (image->
mipmaps < mipCount)
1588 if (temp !=
NULL) image->
data = temp;
1594 mipWidth = image->
width/2;
1595 mipHeight = image->
height/2;
1599 for (
int i = 1; i < mipCount; i++)
1601 TRACELOGD(
"IMAGE: Generating mipmap level: %i (%i x %i) - size: %i - offset: 0x%x", i, mipWidth, mipHeight, mipSize, nextmip);
1605 memcpy(nextmip, imCopy.
data, mipSize);
1613 if (mipWidth < 1) mipWidth = 1;
1614 if (mipHeight < 1) mipHeight = 1;
1638 if ((rBpp + gBpp + bBpp + aBpp) > 16)
1640 TRACELOG(
LOG_WARNING,
"IMAGE: Unsupported dithering bpps (%ibpp), only 16bpp or lower modes supported", (rBpp+gBpp+bBpp+aBpp));
1650 TRACELOG(
LOG_WARNING,
"IMAGE: Format is already 16bpp or lower, dithering could have no effect");
1660 TRACELOG(
LOG_WARNING,
"IMAGE: Unsupported dithered OpenGL internal format: %ibpp (R%iG%iB%iA%i)", (rBpp+gBpp+bBpp+aBpp), rBpp, gBpp, bBpp, aBpp);
1669 int rError, gError, bError;
1670 unsigned short rPixel, gPixel, bPixel, aPixel;
1672 #define MIN(a,b) (((a)<(b))?(a):(b))
1674 for (
int y = 0; y < image->
height; y++)
1676 for (
int x = 0; x < image->
width; x++)
1678 oldPixel = pixels[y*image->
width + x];
1681 newPixel.
r = oldPixel.
r >> (8 - rBpp);
1682 newPixel.
g = oldPixel.
g >> (8 - gBpp);
1683 newPixel.
b = oldPixel.
b >> (8 - bBpp);
1684 newPixel.
a = oldPixel.
a >> (8 - aBpp);
1688 rError = (int)oldPixel.
r - (
int)(newPixel.
r << (8 - rBpp));
1689 gError = (int)oldPixel.
g - (
int)(newPixel.
g << (8 - gBpp));
1690 bError = (int)oldPixel.
b - (
int)(newPixel.
b << (8 - bBpp));
1692 pixels[y*image->
width + x] = newPixel;
1695 if (x < (image->
width - 1))
1697 pixels[y*image->
width + x+1].
r =
MIN((
int)pixels[y*image->
width + x+1].
r + (
int)((
float)rError*7.0f/16), 0xff);
1698 pixels[y*image->
width + x+1].
g =
MIN((
int)pixels[y*image->
width + x+1].
g + (
int)((
float)gError*7.0f/16), 0xff);
1699 pixels[y*image->
width + x+1].
b =
MIN((
int)pixels[y*image->
width + x+1].
b + (
int)((
float)bError*7.0f/16), 0xff);
1702 if ((x > 0) && (y < (image->
height - 1)))
1704 pixels[(y+1)*image->
width + x-1].
r =
MIN((
int)pixels[(y+1)*image->
width + x-1].
r + (
int)((float)rError*3.0f/16), 0xff);
1705 pixels[(y+1)*image->
width + x-1].
g =
MIN((
int)pixels[(y+1)*image->
width + x-1].
g + (
int)((float)gError*3.0f/16), 0xff);
1706 pixels[(y+1)*image->
width + x-1].
b =
MIN((
int)pixels[(y+1)*image->
width + x-1].
b + (
int)((float)bError*3.0f/16), 0xff);
1709 if (y < (image->
height - 1))
1711 pixels[(y+1)*image->
width + x].
r =
MIN((
int)pixels[(y+1)*image->
width + x].
r + (
int)((float)rError*5.0f/16), 0xff);
1712 pixels[(y+1)*image->
width + x].
g =
MIN((
int)pixels[(y+1)*image->
width + x].
g + (
int)((float)gError*5.0f/16), 0xff);
1713 pixels[(y+1)*image->
width + x].
b =
MIN((
int)pixels[(y+1)*image->
width + x].
b + (
int)((float)bError*5.0f/16), 0xff);
1716 if ((x < (image->
width - 1)) && (y < (image->
height - 1)))
1718 pixels[(y+1)*image->
width + x+1].
r =
MIN((
int)pixels[(y+1)*image->
width + x+1].
r + (
int)((float)rError*1.0f/16), 0xff);
1719 pixels[(y+1)*image->
width + x+1].
g =
MIN((
int)pixels[(y+1)*image->
width + x+1].
g + (
int)((float)gError*1.0f/16), 0xff);
1720 pixels[(y+1)*image->
width + x+1].
b =
MIN((
int)pixels[(y+1)*image->
width + x+1].
b + (
int)((float)bError*1.0f/16), 0xff);
1723 rPixel = (
unsigned short)newPixel.
r;
1724 gPixel = (
unsigned short)newPixel.
g;
1725 bPixel = (
unsigned short)newPixel.
b;
1726 aPixel = (
unsigned short)newPixel.
a;
1728 ((
unsigned short *)image->
data)[y*image->
width + x] = (rPixel << (gBpp + bBpp + aBpp)) | (gPixel << (bBpp + aBpp)) | (bPixel << aBpp) | aPixel;
1747 unsigned char *flippedData = (
unsigned char *)
RL_MALLOC(image->
width*image->
height*bytesPerPixel);
1749 for (
int i = (image->
height - 1), offsetSize = 0; i >= 0; i--)
1751 memcpy(flippedData + offsetSize, ((
unsigned char *)image->
data) + i*image->
width*bytesPerPixel, image->
width*bytesPerPixel);
1752 offsetSize += image->
width*bytesPerPixel;
1756 image->
data = flippedData;
1771 unsigned char *flippedData = (
unsigned char *)
RL_MALLOC(image->
width*image->
height*bytesPerPixel);
1773 for (
int y = 0; y < image->
height; y++)
1775 for (
int x = 0; x < image->
width; x++)
1781 for (
int i = 0; i < bytesPerPixel; i++) flippedData[(y*image->
width + x)*bytesPerPixel + i] = ((
unsigned char *)image->
data)[(y*image->
width + (image->
width - 1 - x))*bytesPerPixel + i];
1786 image->
data = flippedData;
1816 unsigned char *rotatedData = (
unsigned char *)
RL_MALLOC(image->
width*image->
height*bytesPerPixel);
1818 for (
int y = 0; y < image->
height; y++)
1820 for (
int x = 0; x < image->
width; x++)
1823 for (
int i = 0; i < bytesPerPixel; i++) rotatedData[(x*image->
height + (image->
height - y - 1))*bytesPerPixel + i] = ((
unsigned char *)image->
data)[(y*image->
width + x)*bytesPerPixel + i];
1828 image->
data = rotatedData;
1829 int width = image->
width;
1830 int height = image-> height;
1832 image->
width = height;
1848 unsigned char *rotatedData = (
unsigned char *)
RL_MALLOC(image->
width*image->
height*bytesPerPixel);
1850 for (
int y = 0; y < image->
height; y++)
1852 for (
int x = 0; x < image->
width; x++)
1855 for (
int i = 0; i < bytesPerPixel; i++) rotatedData[(x*image->
height + y)*bytesPerPixel + i] = ((
unsigned char *)image->
data)[(y*image->
width + (image->
width - x - 1))*bytesPerPixel + i];
1860 image->
data = rotatedData;
1861 int width = image->
width;
1862 int height = image-> height;
1864 image->
width = height;
1877 float cR = (float)color.
r/255;
1878 float cG = (
float)color.
g/255;
1879 float cB = (float)color.
b/255;
1880 float cA = (
float)color.
a/255;
1882 for (
int y = 0; y < image->
height; y++)
1884 for (
int x = 0; x < image->
width; x++)
1886 int index = y*image->
width + x;
1887 unsigned char r = (
unsigned char)(((
float)pixels[index].
r/255*cR)*255.0f);
1888 unsigned char g = (
unsigned char)(((
float)pixels[index].
g/255*cG)*255.0f);
1889 unsigned char b = (
unsigned char)(((
float)pixels[index].
b/255*cB)*255.0f);
1890 unsigned char a = (
unsigned char)(((
float)pixels[index].
a/255*cA)*255.0f);
1892 pixels[index].
r = r;
1893 pixels[index].
g = g;
1894 pixels[index].
b = b;
1895 pixels[index].
a = a;
1899 int format = image->
format;
1902 image->
data = pixels;
1916 for (
int y = 0; y < image->
height; y++)
1918 for (
int x = 0; x < image->
width; x++)
1920 pixels[y*image->
width + x].
r = 255 - pixels[y*image->
width + x].
r;
1921 pixels[y*image->
width + x].
g = 255 - pixels[y*image->
width + x].
g;
1922 pixels[y*image->
width + x].
b = 255 - pixels[y*image->
width + x].
b;
1926 int format = image->
format;
1929 image->
data = pixels;
1948 if (contrast < -100) contrast = -100;
1949 if (contrast > 100) contrast = 100;
1951 contrast = (100.0f + contrast)/100.0f;
1952 contrast *= contrast;
1956 for (
int y = 0; y < image->
height; y++)
1958 for (
int x = 0; x < image->
width; x++)
1960 float pR = (float)pixels[y*image->
width + x].
r/255.0f;
1966 if (pR > 255) pR = 255;
1968 float pG = (float)pixels[y*image->
width + x].
g/255.0f;
1974 if (pG > 255) pG = 255;
1976 float pB = (float)pixels[y*image->
width + x].
b/255.0f;
1982 if (pB > 255) pB = 255;
1984 pixels[y*image->
width + x].
r = (
unsigned char)pR;
1985 pixels[y*image->
width + x].
g = (
unsigned char)pG;
1986 pixels[y*image->
width + x].
b = (
unsigned char)pB;
1990 int format = image->
format;
1993 image->
data = pixels;
2006 if (brightness < -255) brightness = -255;
2007 if (brightness > 255) brightness = 255;
2011 for (
int y = 0; y < image->
height; y++)
2013 for (
int x = 0; x < image->
width; x++)
2015 int cR = pixels[y*image->
width + x].
r + brightness;
2016 int cG = pixels[y*image->
width + x].
g + brightness;
2017 int cB = pixels[y*image->
width + x].
b + brightness;
2020 if (cR > 255) cR = 255;
2023 if (cG > 255) cG = 255;
2026 if (cB > 255) cB = 255;
2028 pixels[y*image->
width + x].
r = (
unsigned char)cR;
2029 pixels[y*image->
width + x].
g = (
unsigned char)cG;
2030 pixels[y*image->
width + x].
b = (
unsigned char)cB;
2034 int format = image->
format;
2037 image->
data = pixels;
2051 for (
int y = 0; y < image->
height; y++)
2053 for (
int x = 0; x < image->
width; x++)
2055 if ((pixels[y*image->
width + x].
r == color.
r) &&
2056 (pixels[y*image->
width + x].
g == color.
g) &&
2057 (pixels[y*image->
width + x].
b == color.
b) &&
2058 (pixels[y*image->
width + x].
a == color.
a))
2060 pixels[y*image->
width + x].
r = replace.
r;
2061 pixels[y*image->
width + x].
g = replace.
g;
2062 pixels[y*image->
width + x].
b = replace.
b;
2063 pixels[y*image->
width + x].
a = replace.
a;
2068 int format = image->
format;
2071 image->
data = pixels;
2093 for (
int i = 0, k = 0; i < image.
width*image.
height; i++)
2099 pixels[i].
r = ((
unsigned char *)image.
data)[i];
2100 pixels[i].
g = ((
unsigned char *)image.
data)[i];
2101 pixels[i].
b = ((
unsigned char *)image.
data)[i];
2107 pixels[i].
r = ((
unsigned char *)image.
data)[k];
2108 pixels[i].
g = ((
unsigned char *)image.
data)[k];
2109 pixels[i].
b = ((
unsigned char *)image.
data)[k];
2110 pixels[i].
a = ((
unsigned char *)image.
data)[k + 1];
2116 unsigned short pixel = ((
unsigned short *)image.
data)[i];
2118 pixels[i].
r = (
unsigned char)((
float)((pixel & 0b1111100000000000) >> 11)*(255/31));
2119 pixels[i].
g = (
unsigned char)((
float)((pixel & 0b0000011111000000) >> 6)*(255/31));
2120 pixels[i].
b = (
unsigned char)((
float)((pixel & 0b0000000000111110) >> 1)*(255/31));
2121 pixels[i].
a = (
unsigned char)((pixel & 0b0000000000000001)*255);
2126 unsigned short pixel = ((
unsigned short *)image.
data)[i];
2128 pixels[i].
r = (
unsigned char)((
float)((pixel & 0b1111100000000000) >> 11)*(255/31));
2129 pixels[i].
g = (
unsigned char)((
float)((pixel & 0b0000011111100000) >> 5)*(255/63));
2130 pixels[i].
b = (
unsigned char)((
float)(pixel & 0b0000000000011111)*(255/31));
2136 unsigned short pixel = ((
unsigned short *)image.
data)[i];
2138 pixels[i].
r = (
unsigned char)((
float)((pixel & 0b1111000000000000) >> 12)*(255/15));
2139 pixels[i].
g = (
unsigned char)((
float)((pixel & 0b0000111100000000) >> 8)*(255/15));
2140 pixels[i].
b = (
unsigned char)((
float)((pixel & 0b0000000011110000) >> 4)*(255/15));
2141 pixels[i].
a = (
unsigned char)((
float)(pixel & 0b0000000000001111)*(255/15));
2146 pixels[i].
r = ((
unsigned char *)image.
data)[k];
2147 pixels[i].
g = ((
unsigned char *)image.
data)[k + 1];
2148 pixels[i].
b = ((
unsigned char *)image.
data)[k + 2];
2149 pixels[i].
a = ((
unsigned char *)image.
data)[k + 3];
2155 pixels[i].
r = (
unsigned char)((
unsigned char *)image.
data)[k];
2156 pixels[i].
g = (
unsigned char)((
unsigned char *)image.
data)[k + 1];
2157 pixels[i].
b = (
unsigned char)((
unsigned char *)image.
data)[k + 2];
2164 pixels[i].
r = (
unsigned char)(((
float *)image.
data)[k]*255.0f);
2172 pixels[i].
r = (
unsigned char)(((
float *)image.
data)[k]*255.0f);
2173 pixels[i].
g = (
unsigned char)(((
float *)image.
data)[k + 1]*255.0f);
2174 pixels[i].
b = (
unsigned char)(((
float *)image.
data)[k + 2]*255.0f);
2181 pixels[i].
r = (
unsigned char)(((
float *)image.
data)[k]*255.0f);
2182 pixels[i].
g = (
unsigned char)(((
float *)image.
data)[k]*255.0f);
2183 pixels[i].
b = (
unsigned char)(((
float *)image.
data)[k]*255.0f);
2184 pixels[i].
a = (
unsigned char)(((
float *)image.
data)[k]*255.0f);
2200 #define COLOR_EQUAL(col1, col2) ((col1.r == col2.r)&&(col1.g == col2.g)&&(col1.b == col2.b)&&(col1.a == col2.a))
2210 for (
int i = 0; i < maxPaletteSize; i++) palette[i] =
BLANK;
2212 for (
int i = 0; i < image.
width*image.
height; i++)
2214 if (pixels[i].a > 0)
2216 bool colorInPalette =
false;
2219 for (
int j = 0; j < maxPaletteSize; j++)
2223 colorInPalette =
true;
2229 if (!colorInPalette)
2231 palette[palCount] = pixels[i];
2235 if (palCount >= maxPaletteSize)
2247 *colorCount = palCount;
2279 for (
int y = 0; y < image.
height; y++)
2281 for (
int x = 0; x < image.
width; x++)
2283 if (pixels[y*image.
width + x].
a > (
unsigned char)(threshold*255.0f))
2285 if (x < xMin) xMin = x;
2286 if (x > xMax) xMax = x;
2287 if (y < yMin) yMin = y;
2288 if (y > yMax) yMax = y;
2294 if ((xMin != 65536) && (xMax != 65536))
2296 crop = (
Rectangle){ (float)xMin, (
float)yMin, (float)((xMax + 1) - xMin), (
float)((yMax + 1) - yMin) };
2308 Color color = { 0 };
2310 if ((x >=0) && (x < image.
width) && (y >= 0) && (y < image.
height))
2316 color.
r = ((
unsigned char *)image.
data)[y*image.
width + x];
2317 color.
g = ((
unsigned char *)image.
data)[y*image.
width + x];
2318 color.
b = ((
unsigned char *)image.
data)[y*image.
width + x];
2324 color.
r = ((
unsigned char *)image.
data)[(y*image.
width + x)*2];
2325 color.
g = ((
unsigned char *)image.
data)[(y*image.
width + x)*2];
2326 color.
b = ((
unsigned char *)image.
data)[(y*image.
width + x)*2];
2327 color.
a = ((
unsigned char *)image.
data)[(y*image.
width + x)*2 + 1];
2332 unsigned short pixel = ((
unsigned short *)image.
data)[y*image.
width + x];
2334 color.
r = (
unsigned char)((
float)((pixel & 0b1111100000000000) >> 11)*(255/31));
2335 color.
g = (
unsigned char)((
float)((pixel & 0b0000011111000000) >> 6)*(255/31));
2336 color.
b = (
unsigned char)((
float)((pixel & 0b0000000000111110) >> 1)*(255/31));
2337 color.
a = (
unsigned char)((pixel & 0b0000000000000001)*255);
2342 unsigned short pixel = ((
unsigned short *)image.
data)[y*image.
width + x];
2344 color.
r = (
unsigned char)((
float)((pixel & 0b1111100000000000) >> 11)*(255/31));
2345 color.
g = (
unsigned char)((
float)((pixel & 0b0000011111100000) >> 5)*(255/63));
2346 color.
b = (
unsigned char)((
float)(pixel & 0b0000000000011111)*(255/31));
2352 unsigned short pixel = ((
unsigned short *)image.
data)[y*image.
width + x];
2354 color.
r = (
unsigned char)((
float)((pixel & 0b1111000000000000) >> 12)*(255/15));
2355 color.
g = (
unsigned char)((
float)((pixel & 0b0000111100000000) >> 8)*(255/15));
2356 color.
b = (
unsigned char)((
float)((pixel & 0b0000000011110000) >> 4)*(255/15));
2357 color.
a = (
unsigned char)((
float)(pixel & 0b0000000000001111)*(255/15));
2362 color.
r = ((
unsigned char *)image.
data)[(y*image.
width + x)*4];
2363 color.
g = ((
unsigned char *)image.
data)[(y*image.
width + x)*4 + 1];
2364 color.
b = ((
unsigned char *)image.
data)[(y*image.
width + x)*4 + 2];
2365 color.
a = ((
unsigned char *)image.
data)[(y*image.
width + x)*4 + 3];
2370 color.
r = (
unsigned char)((
unsigned char *)image.
data)[(y*image.
width + x)*3];
2371 color.
g = (
unsigned char)((
unsigned char *)image.
data)[(y*image.
width + x)*3 + 1];
2372 color.
b = (
unsigned char)((
unsigned char *)image.
data)[(y*image.
width + x)*3 + 2];
2378 color.
r = (
unsigned char)(((
float *)image.
data)[y*image.
width + x]*255.0f);
2386 color.
r = (
unsigned char)(((
float *)image.
data)[(y*image.
width + x)*3]*255.0f);
2387 color.
g = (
unsigned char)(((
float *)image.
data)[(y*image.
width + x)*3 + 1]*255.0f);
2388 color.
b = (
unsigned char)(((
float *)image.
data)[(y*image.
width + x)*3 + 2]*255.0f);
2394 color.
r = (
unsigned char)(((
float *)image.
data)[(y*image.
width + x)*4]*255.0f);
2395 color.
g = (
unsigned char)(((
float *)image.
data)[(y*image.
width + x)*4]*255.0f);
2396 color.
b = (
unsigned char)(((
float *)image.
data)[(y*image.
width + x)*4]*255.0f);
2397 color.
a = (
unsigned char)(((
float *)image.
data)[(y*image.
width + x)*4]*255.0f);
2400 default:
TRACELOG(
LOG_WARNING,
"Compressed image format does not support color reading");
break;
2420 unsigned char *pSrcPixel = (
unsigned char *)dst->
data;
2424 for (
int i = 1; i < dst->
width * dst->
height; i++)
2426 memcpy(pSrcPixel + i * bytesPerPixel, pSrcPixel, bytesPerPixel);
2435 if ((dst->
data ==
NULL) || (x < 0) || (x >= dst->
width) || (y < 0) || (y >= dst->
height))
return;
2442 Vector3 coln = { (float)color.
r/255.0f, (
float)color.
g/255.0f, (float)color.
b/255.0f };
2443 unsigned char gray = (
unsigned char)((coln.
x*0.299f + coln.
y*0.587f + coln.
z*0.114f)*255.0f);
2445 ((
unsigned char *)dst->
data)[y*dst->
width + x] = gray;
2451 Vector3 coln = { (float)color.
r/255.0f, (
float)color.
g/255.0f, (float)color.
b/255.0f };
2452 unsigned char gray = (
unsigned char)((coln.
x*0.299f + coln.
y*0.587f + coln.
z*0.114f)*255.0f);
2454 ((
unsigned char *)dst->
data)[(y*dst->
width + x)*2] = gray;
2455 ((
unsigned char *)dst->
data)[(y*dst->
width + x)*2 + 1] = color.
a;
2461 Vector3 coln = { (float)color.
r/255.0f, (
float)color.
g/255.0f, (float)color.
b/255.0f };
2463 unsigned char r = (
unsigned char)(round(coln.
x*31.0f));
2464 unsigned char g = (
unsigned char)(round(coln.
y*63.0f));
2465 unsigned char b = (
unsigned char)(round(coln.
z*31.0f));
2467 ((
unsigned short *)dst->
data)[y*dst->
width + x] = (
unsigned short)r << 11 | (
unsigned short)g << 5 | (
unsigned short)b;
2473 Vector4 coln = { (float)color.
r/255.0f, (
float)color.
g/255.0f, (float)color.
b/255.0f, (
float)color.
a/255.0f };
2475 unsigned char r = (
unsigned char)(round(coln.
x*31.0f));
2476 unsigned char g = (
unsigned char)(round(coln.
y*31.0f));
2477 unsigned char b = (
unsigned char)(round(coln.
z*31.0f));
2480 ((
unsigned short *)dst->
data)[y*dst->
width + x] = (
unsigned short)r << 11 | (
unsigned short)g << 6 | (
unsigned short)b << 1 | (
unsigned short)a;
2486 Vector4 coln = { (float)color.
r/255.0f, (
float)color.
g/255.0f, (float)color.
b/255.0f, (
float)color.
a/255.0f };
2488 unsigned char r = (
unsigned char)(round(coln.
x*15.0f));
2489 unsigned char g = (
unsigned char)(round(coln.
y*15.0f));
2490 unsigned char b = (
unsigned char)(round(coln.
z*15.0f));
2491 unsigned char a = (
unsigned char)(round(coln.
w*15.0f));
2493 ((
unsigned short *)dst->
data)[y*dst->
width + x] = (
unsigned short)r << 12 | (
unsigned short)g << 8 | (
unsigned short)b << 4 | (
unsigned short)a;
2498 ((
unsigned char *)dst->
data)[(y*dst->
width + x)*3] = color.
r;
2499 ((
unsigned char *)dst->
data)[(y*dst->
width + x)*3 + 1] = color.
g;
2500 ((
unsigned char *)dst->
data)[(y*dst->
width + x)*3 + 2] = color.
b;
2505 ((
unsigned char *)dst->
data)[(y*dst->
width + x)*4] = color.
r;
2506 ((
unsigned char *)dst->
data)[(y*dst->
width + x)*4 + 1] = color.
g;
2507 ((
unsigned char *)dst->
data)[(y*dst->
width + x)*4 + 2] = color.
b;
2508 ((
unsigned char *)dst->
data)[(y*dst->
width + x)*4 + 3] = color.
a;
2514 Vector3 coln = { (float)color.
r/255.0f, (
float)color.
g/255.0f, (float)color.
b/255.0f };
2516 ((
float *)dst->
data)[y*dst->
width + x] = coln.
x*0.299f + coln.
y*0.587f + coln.
z*0.114f;
2522 Vector3 coln = { (float)color.
r/255.0f, (
float)color.
g/255.0f, (float)color.
b/255.0f };
2524 ((
float *)dst->
data)[(y*dst->
width + x)*3] = coln.
x;
2525 ((
float *)dst->
data)[(y*dst->
width + x)*3 + 1] = coln.
y;
2526 ((
float *)dst->
data)[(y*dst->
width + x)*3 + 2] = coln.
z;
2531 Vector4 coln = { (float)color.
r/255.0f, (
float)color.
g/255.0f, (float)color.
b/255.0f, (
float)color.
a/255.0f };
2533 ((
float *)dst->
data)[(y*dst->
width + x)*4] = coln.
x;
2534 ((
float *)dst->
data)[(y*dst->
width + x)*4 + 1] = coln.
y;
2535 ((
float *)dst->
data)[(y*dst->
width + x)*4 + 2] = coln.
z;
2536 ((
float *)dst->
data)[(y*dst->
width + x)*4 + 3] = coln.
w;
2556 int changeInX = (endPosX - startPosX);
2557 int absChangeInX = (changeInX < 0)? -changeInX : changeInX;
2558 int changeInY = (endPosY - startPosY);
2559 int absChangeInY = (changeInY < 0)? -changeInY : changeInY;
2561 int startU, startV, endU, stepV;
2564 int reversedXY = (absChangeInY < absChangeInX);
2569 B = A - 2*absChangeInX;
2570 P = A - absChangeInX;
2587 changeInX = -changeInX;
2588 changeInY = -changeInY;
2591 stepV = (changeInY < 0)? -1 : 1;
2598 B = A - 2*absChangeInY;
2599 P = A - absChangeInY;
2616 changeInX = -changeInX;
2617 changeInY = -changeInY;
2620 stepV = (changeInX < 0)? -1 : 1;
2626 for (
int u = startU + 1, v = startV; u <= endU; u++)
2649 int x = 0, y = radius;
2650 int decesionParameter = 3 - 2*radius;
2664 if (decesionParameter > 0)
2667 decesionParameter = decesionParameter + 4*(x - y) + 10;
2669 else decesionParameter = decesionParameter + 4*x + 6;
2697 int sy = (int)rec.
y;
2698 int ey = sy + (
int)rec.
height;
2700 int sx = (int)rec.
x;
2704 for (
int y = sy; y < ey; y++)
2709 int bytesOffset = ((y * dst->
width) + sx) * bytesPerPixel;
2710 unsigned char *pSrcPixel = (
unsigned char *)dst->
data + bytesOffset;
2713 for (
int x = 1; x < (int)rec.
width; x++)
2715 memcpy(pSrcPixel + x * bytesPerPixel, pSrcPixel, bytesPerPixel);
2741 Image srcMod = { 0 };
2742 Image *srcPtr = &src;
2743 bool useSrcMod =
false;
2746 if (srcRec.
x < 0) { srcRec.
width += srcRec.
x; srcRec.
x = 0; }
2747 if (srcRec.
y < 0) { srcRec.
height += srcRec.
y; srcRec.
y = 0; }
2766 srcRec.
x = -dstRec.
x;
2767 srcRec.
width += dstRec.
x;
2774 srcRec.
y = -dstRec.
y;
2797 Color colSrc, colDst, blend;
2798 bool blendRequired =
true;
2804 int bytesPerPixelDst = strideDst/(dst->
width);
2807 int bytesPerPixelSrc = strideSrc/(srcPtr->
width);
2809 unsigned char *pSrcBase = (
unsigned char *)srcPtr->
data + ((
int)srcRec.
y*srcPtr->
width + (int)srcRec.
x)*bytesPerPixelSrc;
2810 unsigned char *pDstBase = (
unsigned char *)dst->
data + ((
int)dstRec.
y*dst->
width + (int)dstRec.
x)*bytesPerPixelDst;
2812 for (
int y = 0; y < (int)srcRec.
height; y++)
2814 unsigned char *pSrc = pSrcBase;
2815 unsigned char *pDst = pDstBase;
2818 if (!blendRequired && (srcPtr->
format == dst->
format)) memcpy(pDst, pSrc, (
int)(srcRec.
width)*bytesPerPixelSrc);
2821 for (
int x = 0; x < (int)srcRec.
width; x++)
2828 else blend = colSrc;
2832 pDst += bytesPerPixelDst;
2833 pSrc += bytesPerPixelSrc;
2837 pSrcBase += strideSrc;
2838 pDstBase += strideDst;
2848#if defined(SUPPORT_MODULE_RTEXT)
2849 Vector2 position = { (float)posX, (
float)posY };
2935 int size = cubemap.
width;
2937 Image faces = { 0 };
2939 for (
int i = 0; i < 6; i++) faceRecs[i] = (
Rectangle){ 0, 0, (float)size, (
float)size };
2955 faceRecs[0].
x = (float)size; faceRecs[0].
y = (float)size;
2956 faceRecs[1].
x = (float)size; faceRecs[1].
y = (float)size*3;
2957 faceRecs[2].
x = (float)size; faceRecs[2].
y = 0;
2958 faceRecs[3].
x = (float)size; faceRecs[3].
y = (float)size*2;
2959 faceRecs[4].
x = 0; faceRecs[4].
y = (float)size;
2960 faceRecs[5].
x = (float)size*2; faceRecs[5].
y = (float)size;
2964 faceRecs[0].
x = (float)size*2; faceRecs[0].
y = (float)size;
2965 faceRecs[1].
x = 0; faceRecs[1].
y = (float)size;
2966 faceRecs[2].
x = (float)size; faceRecs[2].
y = 0;
2967 faceRecs[3].
x = (float)size; faceRecs[3].
y = (float)size*2;
2968 faceRecs[4].
x = (float)size; faceRecs[4].
y = (float)size;
2969 faceRecs[5].
x = (float)size*3; faceRecs[5].
y = (float)size;
2978 for (
int i = 0; i < 6; i++)
ImageDraw(&faces, image, faceRecs[i], (
Rectangle){ 0, (float)size*i, (
float)size, (float)size },
WHITE);
3040 TRACELOG(
LOG_INFO,
"TEXTURE: [ID %i] Unloaded texture data from VRAM (GPU)", texture.
id);
3135 TRACELOG(
LOG_WARNING,
"TEXTURE: [ID %i] No mipmaps available for TRILINEAR texture filtering", texture.
id);
3199 Vector2 origin = { 0.0f, 0.0f };
3208 Vector2 origin = { 0.0f, 0.0f };
3221 Vector2 origin = { 0.0f, 0.0f };
3230 if ((texture.
id <= 0) || (scale <= 0.0f))
return;
3231 if ((source.
width == 0) || (source.
height == 0))
return;
3233 int tileWidth = (int)(source.
width*scale), tileHeight = (int)(source.
height*scale);
3234 if ((dest.
width < tileWidth) && (dest.
height < tileHeight))
3240 else if (dest.
width <= tileWidth)
3244 for (;dy+tileHeight < dest.
height; dy += tileHeight)
3246 DrawTexturePro(texture, (
Rectangle){source.
x, source.
y, ((float)dest.
width/tileWidth)*source.
width, source.
height}, (
Rectangle){dest.
x, dest.
y + dy, dest.
width, (float)tileHeight}, origin, rotation, tint);
3256 else if (dest.
height <= tileHeight)
3260 for (;dx+tileWidth < dest.
width; dx += tileWidth)
3262 DrawTexturePro(texture, (
Rectangle){source.
x, source.
y, source.
width, ((float)dest.
height/tileHeight)*source.
height}, (
Rectangle){dest.
x + dx, dest.
y, (float)tileWidth, dest.
height}, origin, rotation, tint);
3266 if (dx < dest.
width)
3276 for (;dx+tileWidth < dest.
width; dx += tileWidth)
3279 for (;dy+tileHeight < dest.
height; dy += tileHeight)
3281 DrawTexturePro(texture, source, (
Rectangle){dest.
x + dx, dest.
y + dy, (float)tileWidth, (
float)tileHeight}, origin, rotation, tint);
3287 (
Rectangle){dest.
x + dx, dest.
y + dy, (float)tileWidth, dest.
height - dy}, origin, rotation, tint);
3292 if (dx < dest.
width)
3295 for (;dy+tileHeight < dest.
height; dy += tileHeight)
3298 (
Rectangle){dest.
x + dx, dest.
y + dy, dest.
width - dx, (float)tileHeight}, origin, rotation, tint);
3318 float width = (float)texture.
width;
3319 float height = (
float)texture.
height;
3323 if (source.
width < 0) { flipX =
true; source.
width *= -1; }
3332 if (rotation == 0.0f)
3334 float x = dest.
x - origin.
x;
3335 float y = dest.
y - origin.
y;
3343 float sinRotation = sinf(rotation*
DEG2RAD);
3344 float cosRotation = cosf(rotation*
DEG2RAD);
3347 float dx = -origin.
x;
3348 float dy = -origin.
y;
3350 topLeft.
x = x + dx*cosRotation - dy*sinRotation;
3351 topLeft.
y = y + dx*sinRotation + dy*cosRotation;
3353 topRight.
x = x + (dx + dest.
width)*cosRotation - dy*sinRotation;
3354 topRight.
y = y + (dx + dest.
width)*sinRotation + dy*cosRotation;
3356 bottomLeft.
x = x + dx*cosRotation - (dy + dest.
height)*sinRotation;
3357 bottomLeft.
y = y + dx*sinRotation + (dy + dest.
height)*cosRotation;
3359 bottomRight.
x = x + (dx + dest.
width)*cosRotation - (dy + dest.
height)*sinRotation;
3360 bottomRight.
y = y + (dx + dest.
width)*sinRotation + (dy + dest.
height)*cosRotation;
3441 float width = (float)texture.
width;
3442 float height = (
float)texture.
height;
3444 float patchWidth = ((int)dest.
width <= 0)? 0.0f : dest.
width;
3445 float patchHeight = ((int)dest.
height <= 0)? 0.0f : dest.
height;
3452 bool drawCenter =
true;
3453 bool drawMiddle =
true;
3454 float leftBorder = (float)nPatchInfo.
left;
3455 float topBorder = (
float)nPatchInfo.
top;
3456 float rightBorder = (float)nPatchInfo.
right;
3457 float bottomBorder = (
float)nPatchInfo.
bottom;
3463 leftBorder = (leftBorder/(leftBorder + rightBorder))*patchWidth;
3464 rightBorder = patchWidth - leftBorder;
3471 topBorder = (topBorder/(topBorder + bottomBorder))*patchHeight;
3472 bottomBorder = patchHeight - topBorder;
3475 Vector2 vertA, vertB, vertC, vertD;
3478 vertB.
x = leftBorder;
3479 vertB.
y = topBorder;
3480 vertC.
x = patchWidth - rightBorder;
3481 vertC.
y = patchHeight - bottomBorder;
3482 vertD.
x = patchWidth;
3483 vertD.
y = patchHeight;
3485 Vector2 coordA, coordB, coordC, coordD;
3486 coordA.
x = nPatchInfo.
source.
x/width;
3487 coordA.
y = nPatchInfo.
source.
y/height;
3488 coordB.
x = (nPatchInfo.
source.
x + leftBorder)/width;
3489 coordB.
y = (nPatchInfo.
source.
y + topBorder)/height;
3649 for (
int i = 0; i < pointCount - 1; i++)
3658 rlVertex2f(points[i + 1].x + center.
x, points[i + 1].
y + center.
y);
3661 rlVertex2f(points[i + 1].x + center.
x, points[i + 1].
y + center.
y);
3671 if (alpha < 0.0f) alpha = 0.0f;
3672 else if (alpha > 1.0f) alpha = 1.0f;
3674 return (
Color){color.
r, color.
g, color.
b, (
unsigned char)(255.0f*alpha)};
3680 return (((
int)color.
r << 24) | ((
int)color.
g << 16) | ((
int)color.
b << 8) | (
int)color.
a);
3688 result.
x = (float)color.
r/255.0f;
3689 result.
y = (
float)color.
g/255.0f;
3690 result.
z = (float)color.
b/255.0f;
3691 result.
w = (
float)color.
a/255.0f;
3701 result.
r = (
unsigned char)(normalized.
x*255.0f);
3702 result.
g = (
unsigned char)(normalized.
y*255.0f);
3703 result.
b = (
unsigned char)(normalized.
z*255.0f);
3704 result.
a = (
unsigned char)(normalized.
w*255.0f);
3714 Vector3 rgb = { (float)color.
r/255.0f, (
float)color.
g/255.0f, (float)color.
b/255.0f };
3715 float min, max, delta;
3717 min = rgb.
x < rgb.
y? rgb.
x : rgb.
y;
3718 min = min < rgb.
z? min : rgb.
z;
3720 max = rgb.
x > rgb.
y? rgb.
x : rgb.
y;
3721 max = max > rgb.
z? max : rgb.
z;
3726 if (delta < 0.00001f)
3736 hsv.
y = (delta/max);
3747 if (rgb.
x >= max) hsv.
x = (rgb.
y - rgb.
z)/delta;
3750 if (rgb.
y >= max) hsv.
x = 2.0f + (rgb.
z - rgb.
x)/delta;
3751 else hsv.
x = 4.0f + (rgb.
x - rgb.
y)/delta;
3756 if (hsv.
x < 0.0f) hsv.
x += 360.0f;
3768 Color color = { 0, 0, 0, 255 };
3771 float k = fmodf((5.0f + hue/60.0f), 6);
3776 color.
r = (
unsigned char)((value - value*saturation*k)*255.0f);
3779 k = fmodf((3.0f + hue/60.0f), 6);
3784 color.
g = (
unsigned char)((value - value*saturation*k)*255.0f);
3787 k = fmodf((1.0f + hue/60.0f), 6);
3792 color.
b = (
unsigned char)((value - value*saturation*k)*255.0f);
3800 if (alpha < 0.0f) alpha = 0.0f;
3801 else if (alpha > 1.0f) alpha = 1.0f;
3803 return (
Color){color.
r, color.
g, color.
b, (
unsigned char)(255.0f*alpha)};
3812 src.
r = (
unsigned char)(((
unsigned int)src.
r*(
unsigned int)tint.
r) >> 8);
3813 src.
g = (
unsigned char)(((
unsigned int)src.
g*(
unsigned int)tint.
g) >> 8);
3814 src.
b = (
unsigned char)(((
unsigned int)src.
b*(
unsigned int)tint.
b) >> 8);
3815 src.
a = (
unsigned char)(((
unsigned int)src.
a*(
unsigned int)tint.
a) >> 8);
3818#define COLORALPHABLEND_INTEGERS
3819#if defined(COLORALPHABLEND_INTEGERS)
3820 if (src.
a == 0) out = dst;
3821 else if (src.
a == 255) out = src;
3824 unsigned int alpha = (
unsigned int)src.
a + 1;
3825 out.
a = (
unsigned char)(((
unsigned int)alpha*256 + (
unsigned int)dst.
a*(256 - alpha)) >> 8);
3829 out.
r = (
unsigned char)((((
unsigned int)src.
r*alpha*256 + (
unsigned int)dst.
r*(
unsigned int)dst.
a*(256 - alpha))/out.
a) >> 8);
3830 out.
g = (
unsigned char)((((
unsigned int)src.
g*alpha*256 + (
unsigned int)dst.
g*(
unsigned int)dst.
a*(256 - alpha))/out.
a) >> 8);
3831 out.
b = (
unsigned char)((((
unsigned int)src.
b*alpha*256 + (
unsigned int)dst.
b*(
unsigned int)dst.
a*(256 - alpha))/out.
a) >> 8);
3835#if defined(COLORALPHABLEND_FLOAT)
3836 if (src.
a == 0) out = dst;
3837 else if (src.
a == 255) out = src;
3845 fout.
w = fsrc.
w + fdst.
w*(1.0f - fsrc.
w);
3849 fout.
x = (fsrc.
x*fsrc.
w + fdst.
x*fdst.
w*(1 - fsrc.
w))/fout.
w;
3850 fout.
y = (fsrc.
y*fsrc.
w + fdst.
y*fdst.
w*(1 - fsrc.
w))/fout.
w;
3851 fout.
z = (fsrc.
z*fsrc.
w + fdst.
z*fdst.
w*(1 - fsrc.
w))/fout.
w;
3854 out = (
Color){ (
unsigned char)(fout.
x*255.0f), (
unsigned char)(fout.
y*255.0f), (
unsigned char)(fout.
z*255.0f), (
unsigned char)(fout.
w*255.0f) };
3866 color.
r = (
unsigned char)(hexValue >> 24) & 0xFF;
3867 color.
g = (
unsigned char)(hexValue >> 16) & 0xFF;
3868 color.
b = (
unsigned char)(hexValue >> 8) & 0xFF;
3869 color.
a = (
unsigned char)hexValue & 0xFF;
3877 Color color = { 0 };
3885 color.
r = (
unsigned char)((((
unsigned short *)srcPtr)[0] >> 11)*255/31);
3886 color.
g = (
unsigned char)(((((
unsigned short *)srcPtr)[0] >> 5) & 0b0000000000111111)*255/63);
3887 color.
b = (
unsigned char)((((
unsigned short *)srcPtr)[0] & 0b0000000000011111)*255/31);
3893 color.
r = (
unsigned char)((((
unsigned short *)srcPtr)[0] >> 11)*255/31);
3894 color.
g = (
unsigned char)(((((
unsigned short *)srcPtr)[0] >> 6) & 0b0000000000011111)*255/31);
3895 color.
b = (
unsigned char)((((
unsigned short *)srcPtr)[0] & 0b0000000000011111)*255/31);
3896 color.
a = (((
unsigned short *)srcPtr)[0] & 0b0000000000000001)? 255 : 0;
3901 color.
r = (
unsigned char)((((
unsigned short *)srcPtr)[0] >> 12)*255/15);
3902 color.
g = (
unsigned char)(((((
unsigned short *)srcPtr)[0] >> 8) & 0b0000000000001111)*255/15);
3903 color.
b = (
unsigned char)(((((
unsigned short *)srcPtr)[0] >> 4) & 0b0000000000001111)*255/15);
3904 color.
a = (
unsigned char)((((
unsigned short *)srcPtr)[0] & 0b0000000000001111)*255/15);
3907 case PIXELFORMAT_UNCOMPRESSED_R8G8B8A8: color = (
Color){ ((
unsigned char *)srcPtr)[0], ((
unsigned char *)srcPtr)[1], ((
unsigned char *)srcPtr)[2], ((
unsigned char *)srcPtr)[3] };
break;
3912 color.
r = (
unsigned char)(((
float *)srcPtr)[0]*255.0f);
3913 color.
g = (
unsigned char)(((
float *)srcPtr)[0]*255.0f);
3914 color.
b = (
unsigned char)(((
float *)srcPtr)[0]*255.0f);
3921 color.
r = (
unsigned char)(((
float *)srcPtr)[0]*255.0f);
3922 color.
g = (
unsigned char)(((
float *)srcPtr)[1]*255.0f);
3923 color.
b = (
unsigned char)(((
float *)srcPtr)[2]*255.0f);
3930 color.
r = (
unsigned char)(((
float *)srcPtr)[0]*255.0f);
3931 color.
g = (
unsigned char)(((
float *)srcPtr)[1]*255.0f);
3932 color.
b = (
unsigned char)(((
float *)srcPtr)[2]*255.0f);
3933 color.
a = (
unsigned char)(((
float *)srcPtr)[3]*255.0f);
3950 Vector3 coln = { (float)color.
r/255.0f, (
float)color.
g/255.0f, (float)color.
b/255.0f };
3951 unsigned char gray = (
unsigned char)((coln.
x*0.299f + coln.
y*0.587f + coln.
z*0.114f)*255.0f);
3953 ((
unsigned char *)dstPtr)[0] = gray;
3959 Vector3 coln = { (float)color.
r/255.0f, (
float)color.
g/255.0f, (float)color.
b/255.0f };
3960 unsigned char gray = (
unsigned char)((coln.
x*0.299f + coln.
y*0.587f + coln.
z*0.114f)*255.0f);
3962 ((
unsigned char *)dstPtr)[0] = gray;
3963 ((
unsigned char *)dstPtr)[1] = color.
a;
3969 Vector3 coln = { (float)color.
r/255.0f, (
float)color.
g/255.0f, (float)color.
b/255.0f };
3971 unsigned char r = (
unsigned char)(round(coln.
x*31.0f));
3972 unsigned char g = (
unsigned char)(round(coln.
y*63.0f));
3973 unsigned char b = (
unsigned char)(round(coln.
z*31.0f));
3975 ((
unsigned short *)dstPtr)[0] = (
unsigned short)r << 11 | (
unsigned short)g << 5 | (
unsigned short)b;
3981 Vector4 coln = { (float)color.
r/255.0f, (
float)color.
g/255.0f, (float)color.
b/255.0f, (
float)color.
a/255.0f };
3983 unsigned char r = (
unsigned char)(round(coln.
x*31.0f));
3984 unsigned char g = (
unsigned char)(round(coln.
y*31.0f));
3985 unsigned char b = (
unsigned char)(round(coln.
z*31.0f));
3988 ((
unsigned short *)dstPtr)[0] = (
unsigned short)r << 11 | (
unsigned short)g << 6 | (
unsigned short)b << 1 | (
unsigned short)a;
3994 Vector4 coln = { (float)color.
r/255.0f, (
float)color.
g/255.0f, (float)color.
b/255.0f, (
float)color.
a/255.0f };
3996 unsigned char r = (
unsigned char)(round(coln.
x*15.0f));
3997 unsigned char g = (
unsigned char)(round(coln.
y*15.0f));
3998 unsigned char b = (
unsigned char)(round(coln.
z*15.0f));
3999 unsigned char a = (
unsigned char)(round(coln.
w*15.0f));
4001 ((
unsigned short *)dstPtr)[0] = (
unsigned short)r << 12 | (
unsigned short)g << 8 | (
unsigned short)b << 4 | (
unsigned short)a;
4006 ((
unsigned char *)dstPtr)[0] = color.
r;
4007 ((
unsigned char *)dstPtr)[1] = color.
g;
4008 ((
unsigned char *)dstPtr)[2] = color.
b;
4013 ((
unsigned char *)dstPtr)[0] = color.
r;
4014 ((
unsigned char *)dstPtr)[1] = color.
g;
4015 ((
unsigned char *)dstPtr)[2] = color.
b;
4016 ((
unsigned char *)dstPtr)[3] = color.
a;
4056 dataSize = width*height*bpp/8;
4060 if ((width < 4) && (height < 4))
4072#if defined(SUPPORT_FILEFORMAT_DDS)
4074static Image LoadDDS(
const unsigned char *fileData,
unsigned int fileSize)
4076 unsigned char *fileDataPtr = (
unsigned char *)fileData;
4087 #define FOURCC_DXT1 0x31545844
4088 #define FOURCC_DXT3 0x33545844
4089 #define FOURCC_DXT5 0x35545844
4095 unsigned int fourCC;
4096 unsigned int rgbBitCount;
4097 unsigned int rBitMask;
4098 unsigned int gBitMask;
4099 unsigned int bBitMask;
4100 unsigned int aBitMask;
4107 unsigned int height;
4109 unsigned int pitchOrLinearSize;
4111 unsigned int mipmapCount;
4112 unsigned int reserved1[11];
4113 DDSPixelFormat ddspf;
4118 unsigned int reserved2;
4121 Image image = { 0 };
4123 if (fileDataPtr !=
NULL)
4126 unsigned char *ddsHeaderId = fileDataPtr;
4129 if ((ddsHeaderId[0] !=
'D') || (ddsHeaderId[1] !=
'D') || (ddsHeaderId[2] !=
'S') || (ddsHeaderId[3] !=
' '))
4135 DDSHeader *ddsHeader = (DDSHeader *)fileDataPtr;
4137 TRACELOGD(
"IMAGE: DDS file data info:");
4138 TRACELOGD(
" > Header size: %i",
sizeof(DDSHeader));
4139 TRACELOGD(
" > Pixel format size: %i", ddsHeader->ddspf.size);
4140 TRACELOGD(
" > Pixel format flags: 0x%x", ddsHeader->ddspf.flags);
4141 TRACELOGD(
" > File format: 0x%x", ddsHeader->ddspf.fourCC);
4142 TRACELOGD(
" > File bit count: 0x%x", ddsHeader->ddspf.rgbBitCount);
4144 fileDataPtr +=
sizeof(DDSHeader);
4146 image.
width = ddsHeader->width;
4147 image.
height = ddsHeader->height;
4149 if (ddsHeader->mipmapCount == 0) image.
mipmaps = 1;
4150 else image.
mipmaps = ddsHeader->mipmapCount;
4152 if (ddsHeader->ddspf.rgbBitCount == 16)
4154 if (ddsHeader->ddspf.flags == 0x40)
4156 int dataSize = image.
width*image.
height*
sizeof(
unsigned short);
4159 memcpy(image.
data, fileDataPtr, dataSize);
4163 else if (ddsHeader->ddspf.flags == 0x41)
4165 if (ddsHeader->ddspf.aBitMask == 0x8000)
4167 int dataSize = image.
width*image.
height*
sizeof(
unsigned short);
4170 memcpy(image.
data, fileDataPtr, dataSize);
4172 unsigned char alpha = 0;
4175 for (
int i = 0; i < image.
width*image.
height; i++)
4177 alpha = ((
unsigned short *)image.
data)[i] >> 15;
4178 ((
unsigned short *)image.
data)[i] = ((
unsigned short *)image.
data)[i] << 1;
4179 ((
unsigned short *)image.
data)[i] += alpha;
4184 else if (ddsHeader->ddspf.aBitMask == 0xf000)
4186 int dataSize = image.
width*image.
height*
sizeof(
unsigned short);
4189 memcpy(image.
data, fileDataPtr, dataSize);
4191 unsigned char alpha = 0;
4194 for (
int i = 0; i < image.
width*image.
height; i++)
4196 alpha = ((
unsigned short *)image.
data)[i] >> 12;
4197 ((
unsigned short *)image.
data)[i] = ((
unsigned short *)image.
data)[i] << 4;
4198 ((
unsigned short *)image.
data)[i] += alpha;
4205 else if (ddsHeader->ddspf.flags == 0x40 && ddsHeader->ddspf.rgbBitCount == 24)
4207 int dataSize = image.
width*image.
height*3*
sizeof(
unsigned char);
4210 memcpy(image.
data, fileDataPtr, dataSize);
4214 else if (ddsHeader->ddspf.flags == 0x41 && ddsHeader->ddspf.rgbBitCount == 32)
4216 int dataSize = image.
width*image.
height*4*
sizeof(
unsigned char);
4219 memcpy(image.
data, fileDataPtr, dataSize);
4221 unsigned char blue = 0;
4226 for (
int i = 0; i < image.
width*image.
height*4; i += 4)
4228 blue = ((
unsigned char *)image.
data)[i];
4229 ((
unsigned char *)image.
data)[i] = ((
unsigned char *)image.
data)[i + 2];
4230 ((
unsigned char *)image.
data)[i + 2] = blue;
4235 else if (((ddsHeader->ddspf.flags == 0x04) || (ddsHeader->ddspf.flags == 0x05)) && (ddsHeader->ddspf.fourCC > 0))
4240 if (ddsHeader->mipmapCount > 1) dataSize = ddsHeader->pitchOrLinearSize*2;
4241 else dataSize = ddsHeader->pitchOrLinearSize;
4243 image.
data = (
unsigned char *)
RL_MALLOC(dataSize*
sizeof(
unsigned char));
4245 memcpy(image.
data, fileDataPtr, dataSize);
4247 switch (ddsHeader->ddspf.fourCC)
4266#if defined(SUPPORT_FILEFORMAT_PKM)
4270static Image LoadPKM(
const unsigned char *fileData,
unsigned int fileSize)
4272 unsigned char *fileDataPtr = (
unsigned char *)fileData;
4287 unsigned short format;
4288 unsigned short width;
4289 unsigned short height;
4290 unsigned short origWidth;
4291 unsigned short origHeight;
4301 Image image = { 0 };
4303 if (fileDataPtr !=
NULL)
4305 PKMHeader *pkmHeader = (PKMHeader *)fileDataPtr;
4307 if ((pkmHeader->id[0] !=
'P') || (pkmHeader->id[1] !=
'K') || (pkmHeader->id[2] !=
'M') || (pkmHeader->id[3] !=
' '))
4313 fileDataPtr +=
sizeof(PKMHeader);
4316 pkmHeader->format = ((pkmHeader->format & 0x00FF) << 8) | ((pkmHeader->format & 0xFF00) >> 8);
4317 pkmHeader->width = ((pkmHeader->width & 0x00FF) << 8) | ((pkmHeader->width & 0xFF00) >> 8);
4318 pkmHeader->height = ((pkmHeader->height & 0x00FF) << 8) | ((pkmHeader->height & 0xFF00) >> 8);
4320 TRACELOGD(
"IMAGE: PKM file data info:");
4321 TRACELOGD(
" > Image width: %i", pkmHeader->width);
4322 TRACELOGD(
" > Image height: %i", pkmHeader->height);
4323 TRACELOGD(
" > Image format: %i", pkmHeader->format);
4325 image.
width = pkmHeader->width;
4326 image.
height = pkmHeader->height;
4330 if (pkmHeader->format == 3) bpp = 8;
4334 image.
data = (
unsigned char *)
RL_MALLOC(dataSize*
sizeof(
unsigned char));
4336 memcpy(image.
data, fileDataPtr, dataSize);
4348#if defined(SUPPORT_FILEFORMAT_KTX)
4351static Image LoadKTX(
const unsigned char *fileData,
unsigned int fileSize)
4353 unsigned char *fileDataPtr = (
unsigned char *)fileData;
4372 unsigned int endianness;
4373 unsigned int glType;
4374 unsigned int glTypeSize;
4375 unsigned int glFormat;
4376 unsigned int glInternalFormat;
4377 unsigned int glBaseInternalFormat;
4379 unsigned int height;
4381 unsigned int elements;
4383 unsigned int mipmapLevels;
4384 unsigned int keyValueDataSize;
4389 Image image = { 0 };
4391 if (fileDataPtr !=
NULL)
4393 KTXHeader *ktxHeader = (KTXHeader *)fileDataPtr;
4395 if ((ktxHeader->id[1] !=
'K') || (ktxHeader->id[2] !=
'T') || (ktxHeader->id[3] !=
'X') ||
4396 (ktxHeader->id[4] !=
' ') || (ktxHeader->id[5] !=
'1') || (ktxHeader->id[6] !=
'1'))
4402 fileDataPtr +=
sizeof(KTXHeader);
4404 image.
width = ktxHeader->width;
4405 image.
height = ktxHeader->height;
4406 image.
mipmaps = ktxHeader->mipmapLevels;
4408 TRACELOGD(
"IMAGE: KTX file data info:");
4409 TRACELOGD(
" > Image width: %i", ktxHeader->width);
4410 TRACELOGD(
" > Image height: %i", ktxHeader->height);
4411 TRACELOGD(
" > Image format: 0x%x", ktxHeader->glInternalFormat);
4413 fileDataPtr += ktxHeader->keyValueDataSize;
4415 int dataSize = ((
int *)fileDataPtr)[0];
4416 fileDataPtr +=
sizeof(int);
4418 image.
data = (
unsigned char *)
RL_MALLOC(dataSize*
sizeof(
unsigned char));
4420 memcpy(image.
data, fileDataPtr, dataSize);
4436static int SaveKTX(
Image image,
const char *fileName)
4443 unsigned int endianness;
4444 unsigned int glType;
4445 unsigned int glTypeSize;
4446 unsigned int glFormat;
4447 unsigned int glInternalFormat;
4448 unsigned int glBaseInternalFormat;
4450 unsigned int height;
4452 unsigned int elements;
4454 unsigned int mipmapLevels;
4455 unsigned int keyValueDataSize;
4461 int dataSize =
sizeof(KTXHeader);
4466 width /= 2; height /= 2;
4469 unsigned char *fileData =
RL_CALLOC(dataSize, 1);
4470 unsigned char *fileDataPtr = fileData;
4472 KTXHeader ktxHeader = { 0 };
4478 const char ktxIdentifier[12] = { 0xAB,
'K',
'T',
'X',
' ',
'1',
'1', 0xBB,
'\r',
'\n', 0x1A,
'\n' };
4481 memcpy(ktxHeader.id, ktxIdentifier, 12);
4482 ktxHeader.endianness = 0;
4483 ktxHeader.glType = 0;
4484 ktxHeader.glTypeSize = 1;
4485 ktxHeader.glFormat = 0;
4486 ktxHeader.glInternalFormat = 0;
4487 ktxHeader.glBaseInternalFormat = 0;
4488 ktxHeader.width = image.
width;
4489 ktxHeader.height = image.
height;
4490 ktxHeader.depth = 0;
4491 ktxHeader.elements = 0;
4492 ktxHeader.faces = 1;
4493 ktxHeader.mipmapLevels = image.
mipmaps;
4494 ktxHeader.keyValueDataSize = 0;
4497 ktxHeader.glBaseInternalFormat = ktxHeader.glFormat;
4501 if (ktxHeader.glFormat == -1)
TRACELOG(
LOG_WARNING,
"IMAGE: GL format not supported for KTX export (%i)", ktxHeader.glFormat);
4504 memcpy(fileDataPtr, &ktxHeader,
sizeof(KTXHeader));
4505 fileDataPtr +=
sizeof(KTXHeader);
4507 int width = image.
width;
4508 int height = image.
height;
4512 for (
int i = 0; i < image.
mipmaps; i++)
4516 memcpy(fileDataPtr, &dataSize,
sizeof(
unsigned int));
4517 memcpy(fileDataPtr + 4, (
unsigned char *)image.
data + dataOffset, dataSize);
4521 dataOffset += dataSize;
4522 fileDataPtr += (4 + dataSize);
4526 int success =
SaveFileData(fileName, fileData, dataSize);
4535#if defined(SUPPORT_FILEFORMAT_PVR)
4538static Image LoadPVR(
const unsigned char *fileData,
unsigned int fileSize)
4540 unsigned char *fileDataPtr = (
unsigned char *)fileData;
4552 unsigned int headerLength;
4553 unsigned int height;
4555 unsigned int numMipmaps;
4557 unsigned int dataLength;
4559 unsigned int bitmaskRed;
4560 unsigned int bitmaskGreen;
4561 unsigned int bitmaskBlue;
4562 unsigned int bitmaskAlpha;
4563 unsigned int pvrTag;
4564 unsigned int numSurfs;
4573 unsigned char channels[4];
4574 unsigned char channelDepth[4];
4575 unsigned int colourSpace;
4576 unsigned int channelType;
4577 unsigned int height;
4580 unsigned int numSurfaces;
4581 unsigned int numFaces;
4582 unsigned int numMipmaps;
4583 unsigned int metaDataSize;
4589 unsigned int devFOURCC;
4591 unsigned int dataSize;
4592 unsigned char *data;
4596 Image image = { 0 };
4598 if (fileDataPtr !=
NULL)
4601 unsigned char pvrVersion = fileDataPtr[0];
4604 if (pvrVersion == 0x50)
4606 PVRHeaderV3 *pvrHeader = (PVRHeaderV3 *)fileDataPtr;
4608 if ((pvrHeader->id[0] !=
'P') || (pvrHeader->id[1] !=
'V') || (pvrHeader->id[2] !=
'R') || (pvrHeader->id[3] != 3))
4614 fileDataPtr +=
sizeof(PVRHeaderV3);
4616 image.
width = pvrHeader->width;
4617 image.
height = pvrHeader->height;
4618 image.
mipmaps = pvrHeader->numMipmaps;
4622 else if (((pvrHeader->channels[0] ==
'l') && (pvrHeader->channels[1] ==
'a')) && ((pvrHeader->channelDepth[0] == 8) && (pvrHeader->channelDepth[1] == 8))) image.
format =
PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA;
4623 else if ((pvrHeader->channels[0] ==
'r') && (pvrHeader->channels[1] ==
'g') && (pvrHeader->channels[2] ==
'b'))
4625 if (pvrHeader->channels[3] ==
'a')
4627 if ((pvrHeader->channelDepth[0] == 5) && (pvrHeader->channelDepth[1] == 5) && (pvrHeader->channelDepth[2] == 5) && (pvrHeader->channelDepth[3] == 1)) image.
format =
PIXELFORMAT_UNCOMPRESSED_R5G5B5A1;
4628 else if ((pvrHeader->channelDepth[0] == 4) && (pvrHeader->channelDepth[1] == 4) && (pvrHeader->channelDepth[2] == 4) && (pvrHeader->channelDepth[3] == 4)) image.
format =
PIXELFORMAT_UNCOMPRESSED_R4G4B4A4;
4629 else if ((pvrHeader->channelDepth[0] == 8) && (pvrHeader->channelDepth[1] == 8) && (pvrHeader->channelDepth[2] == 8) && (pvrHeader->channelDepth[3] == 8)) image.
format =
PIXELFORMAT_UNCOMPRESSED_R8G8B8A8;
4631 else if (pvrHeader->channels[3] == 0)
4640 fileDataPtr += pvrHeader->metaDataSize;
4659 image.
data = (
unsigned char *)
RL_MALLOC(dataSize*
sizeof(
unsigned char));
4661 memcpy(image.
data, fileDataPtr, dataSize);
4664 else if (pvrVersion == 52)
TRACELOG(
LOG_INFO,
"IMAGE: PVRv2 format not supported, update your files to PVRv3");
4671#if defined(SUPPORT_FILEFORMAT_ASTC)
4673static Image LoadASTC(
const unsigned char *fileData,
unsigned int fileSize)
4675 unsigned char *fileDataPtr = (
unsigned char *)fileData;
4687 unsigned char id[4];
4688 unsigned char blockX;
4689 unsigned char blockY;
4690 unsigned char blockZ;
4691 unsigned char width[3];
4692 unsigned char height[3];
4693 unsigned char length[3];
4696 Image image = { 0 };
4698 if (fileDataPtr !=
NULL)
4700 ASTCHeader *astcHeader = (ASTCHeader *)fileDataPtr;
4702 if ((astcHeader->id[3] != 0x5c) || (astcHeader->id[2] != 0xa1) || (astcHeader->id[1] != 0xab) || (astcHeader->id[0] != 0x13))
4708 fileDataPtr +=
sizeof(ASTCHeader);
4711 image.
width = 0x00000000 | ((int)astcHeader->width[2] << 16) | ((int)astcHeader->width[1] << 8) | ((int)astcHeader->width[0]);
4712 image.
height = 0x00000000 | ((int)astcHeader->height[2] << 16) | ((int)astcHeader->height[1] << 8) | ((int)astcHeader->height[0]);
4714 TRACELOGD(
"IMAGE: ASTC file data info:");
4717 TRACELOGD(
" > Image blocks: %ix%i", astcHeader->blockX, astcHeader->blockY);
4722 int bpp = 128/(astcHeader->blockX*astcHeader->blockY);
4725 if ((bpp == 8) || (bpp == 2))
4729 image.
data = (
unsigned char *)
RL_MALLOC(dataSize*
sizeof(
unsigned char));
4731 memcpy(image.
data, fileDataPtr, dataSize);
4752 for (
int i = 0, k = 0; i < image.
width*image.
height; i++)
4758 pixels[i].
x = (float)((
unsigned char *)image.
data)[i]/255.0f;
4759 pixels[i].
y = (float)((
unsigned char *)image.
data)[i]/255.0f;
4760 pixels[i].
z = (float)((
unsigned char *)image.
data)[i]/255.0f;
4766 pixels[i].
x = (float)((
unsigned char *)image.
data)[k]/255.0f;
4767 pixels[i].
y = (float)((
unsigned char *)image.
data)[k]/255.0f;
4768 pixels[i].
z = (float)((
unsigned char *)image.
data)[k]/255.0f;
4769 pixels[i].
w = (float)((
unsigned char *)image.
data)[k + 1]/255.0f;
4775 unsigned short pixel = ((
unsigned short *)image.
data)[i];
4777 pixels[i].
x = (float)((pixel & 0b1111100000000000) >> 11)*(1.0f/31);
4778 pixels[i].
y = (float)((pixel & 0b0000011111000000) >> 6)*(1.0f/31);
4779 pixels[i].
z = (float)((pixel & 0b0000000000111110) >> 1)*(1.0f/31);
4780 pixels[i].
w = ((pixel & 0b0000000000000001) == 0)? 0.0f : 1.0f;
4785 unsigned short pixel = ((
unsigned short *)image.
data)[i];
4787 pixels[i].
x = (float)((pixel & 0b1111100000000000) >> 11)*(1.0f/31);
4788 pixels[i].
y = (float)((pixel & 0b0000011111100000) >> 5)*(1.0f/63);
4789 pixels[i].
z = (float)(pixel & 0b0000000000011111)*(1.0f/31);
4795 unsigned short pixel = ((
unsigned short *)image.
data)[i];
4797 pixels[i].
x = (float)((pixel & 0b1111000000000000) >> 12)*(1.0f/15);
4798 pixels[i].
y = (float)((pixel & 0b0000111100000000) >> 8)*(1.0f/15);
4799 pixels[i].
z = (float)((pixel & 0b0000000011110000) >> 4)*(1.0f/15);
4800 pixels[i].
w = (float)(pixel & 0b0000000000001111)*(1.0f/15);
4805 pixels[i].
x = (float)((
unsigned char *)image.
data)[k]/255.0f;
4806 pixels[i].
y = (float)((
unsigned char *)image.
data)[k + 1]/255.0f;
4807 pixels[i].
z = (float)((
unsigned char *)image.
data)[k + 2]/255.0f;
4808 pixels[i].
w = (float)((
unsigned char *)image.
data)[k + 3]/255.0f;
4814 pixels[i].
x = (float)((
unsigned char *)image.
data)[k]/255.0f;
4815 pixels[i].
y = (float)((
unsigned char *)image.
data)[k + 1]/255.0f;
4816 pixels[i].
z = (float)((
unsigned char *)image.
data)[k + 2]/255.0f;
4823 pixels[i].
x = ((
float *)image.
data)[k];
4831 pixels[i].
x = ((
float *)image.
data)[k];
4832 pixels[i].
y = ((
float *)image.
data)[k + 1];
4833 pixels[i].
z = ((
float *)image.
data)[k + 2];
4840 pixels[i].
x = ((
float *)image.
data)[k];
4841 pixels[i].
y = ((
float *)image.
data)[k + 1];
4842 pixels[i].
z = ((
float *)image.
data)[k + 2];
4843 pixels[i].
w = ((
float *)image.
data)[k + 3];
#define SUPPORT_FILEFORMAT_PNG
#define SUPPORT_FILEFORMAT_GIF
int qoi_write(const char *filename, const void *data, const qoi_desc *desc)
void * qoi_decode(const void *data, int size, qoi_desc *desc, int channels)
#define RL_MALLOC(sz)
raudio v1.0 - A simple and easy-to-use audio library based on miniaudio
#define TRACELOG(level,...)
RLAPI Vector2 MeasureTextEx(Font font, const char *text, float fontSize, float spacing)
RLAPI bool SaveFileData(const char *fileName, void *data, unsigned int bytesToWrite)
@ CUBEMAP_LAYOUT_LINE_VERTICAL
@ CUBEMAP_LAYOUT_CROSS_THREE_BY_FOUR
@ CUBEMAP_LAYOUT_AUTO_DETECT
@ CUBEMAP_LAYOUT_CROSS_FOUR_BY_THREE
@ CUBEMAP_LAYOUT_PANORAMA
@ CUBEMAP_LAYOUT_LINE_HORIZONTAL
@ PIXELFORMAT_COMPRESSED_ETC1_RGB
@ PIXELFORMAT_COMPRESSED_ASTC_4x4_RGBA
@ PIXELFORMAT_UNCOMPRESSED_R32
@ PIXELFORMAT_COMPRESSED_DXT1_RGB
@ PIXELFORMAT_UNCOMPRESSED_R8G8B8
@ PIXELFORMAT_UNCOMPRESSED_R32G32B32A32
@ PIXELFORMAT_UNCOMPRESSED_R32G32B32
@ PIXELFORMAT_COMPRESSED_DXT3_RGBA
@ PIXELFORMAT_UNCOMPRESSED_GRAYSCALE
@ PIXELFORMAT_COMPRESSED_DXT5_RGBA
@ PIXELFORMAT_COMPRESSED_ETC2_EAC_RGBA
@ PIXELFORMAT_COMPRESSED_ASTC_8x8_RGBA
@ PIXELFORMAT_UNCOMPRESSED_R5G6B5
@ PIXELFORMAT_COMPRESSED_DXT1_RGBA
@ PIXELFORMAT_COMPRESSED_PVRT_RGB
@ PIXELFORMAT_COMPRESSED_ETC2_RGB
@ PIXELFORMAT_UNCOMPRESSED_R8G8B8A8
@ PIXELFORMAT_UNCOMPRESSED_R5G5B5A1
@ PIXELFORMAT_UNCOMPRESSED_R4G4B4A4
@ PIXELFORMAT_COMPRESSED_PVRT_RGBA
@ PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA
RLAPI unsigned char * LoadFileData(const char *fileName, unsigned int *bytesRead)
#define RL_REALLOC(ptr, sz)
RLAPI Font GetFontDefault(void)
RLAPI int GetScreenWidth(void)
RLAPI bool SaveFileText(const char *fileName, char *text)
RLAPI const char * GetFileNameWithoutExt(const char *filePath)
@ NPATCH_THREE_PATCH_HORIZONTAL
@ NPATCH_THREE_PATCH_VERTICAL
@ TEXTURE_FILTER_ANISOTROPIC_8X
@ TEXTURE_FILTER_ANISOTROPIC_4X
@ TEXTURE_FILTER_BILINEAR
@ TEXTURE_FILTER_ANISOTROPIC_16X
@ TEXTURE_FILTER_TRILINEAR
RLAPI int GetScreenHeight(void)
RLAPI int GetCodepoint(const char *text, int *bytesProcessed)
RLAPI int GetRandomValue(int min, int max)
RLAPI int GetGlyphIndex(Font font, int codepoint)
RLAPI const char * GetFileExtension(const char *fileName)
@ TEXTURE_WRAP_MIRROR_REPEAT
@ TEXTURE_WRAP_MIRROR_CLAMP
RLAPI bool IsFileExtension(const char *fileName, const char *ext)
#define RL_TEXTURE_FILTER_MIP_NEAREST
RLAPI void rlNormal3f(float x, float y, float z)
@ RL_ATTACHMENT_COLOR_CHANNEL0
RLAPI unsigned int rlLoadTexture(const void *data, int width, int height, int format, int mipmapCount)
RLAPI void rlUpdateTexture(unsigned int id, int offsetX, int offsetY, int width, int height, int format, const void *data)
#define RL_TEXTURE_WRAP_T
RLAPI void rlUnloadFramebuffer(unsigned int id)
RLAPI void * rlReadTexturePixels(unsigned int id, int width, int height, int format)
RLAPI void rlColor4ub(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
#define RL_TEXTURE_FILTER_MIP_LINEAR
#define RL_TEXTURE_FILTER_LINEAR_MIP_NEAREST
RLAPI void rlGenTextureMipmaps(unsigned int id, int width, int height, int format, int *mipmaps)
RLAPI unsigned char * rlReadScreenPixels(int width, int height)
RLAPI void rlPushMatrix(void)
RLAPI const char * rlGetPixelFormatName(unsigned int format)
RLAPI unsigned int rlLoadTextureCubemap(const void *data, int size, int format)
RLAPI void rlVertex2f(float x, float y)
#define RL_TEXTURE_FILTER_LINEAR
#define RL_TEXTURE_MIN_FILTER
RLAPI unsigned int rlLoadTextureDepth(int width, int height, bool useRenderBuffer)
RLAPI void rlEnableFramebuffer(unsigned int id)
RLAPI void rlBegin(int mode)
RLAPI void rlDisableFramebuffer(void)
RLAPI void rlFramebufferAttach(unsigned int fboId, unsigned int texId, int attachType, int texType, int mipLevel)
RLAPI void rlTexCoord2f(float x, float y)
#define RL_TEXTURE_FILTER_NEAREST
RLAPI void rlRotatef(float angle, float x, float y, float z)
RLAPI unsigned int rlLoadFramebuffer(int width, int height)
RLAPI void rlUnloadTexture(unsigned int id)
#define RL_TEXTURE_WRAP_MIRROR_CLAMP
#define RL_TEXTURE_MAG_FILTER
RLAPI void rlTextureParameters(unsigned int id, int param, int value)
#define RL_TEXTURE_WRAP_S
#define RL_TEXTURE_FILTER_ANISOTROPIC
RLAPI void rlPopMatrix(void)
RLAPI void rlSetTexture(unsigned int id)
RLAPI void rlGetGlTextureFormats(int format, int *glInternalFormat, int *glFormat, int *glType)
RLAPI bool rlCheckRenderBatchLimit(int vCount)
RLAPI bool rlFramebufferComplete(unsigned int id)
#define RL_TEXTURE_WRAP_REPEAT
@ RL_ATTACHMENT_TEXTURE2D
@ RL_ATTACHMENT_RENDERBUFFER
RLAPI void rlTranslatef(float x, float y, float z)
#define RL_TEXTURE_WRAP_CLAMP
#define RL_TEXTURE_WRAP_MIRROR_REPEAT
Color ColorAlpha(Color color, float alpha)
void DrawTextureQuad(Texture2D texture, Vector2 tiling, Vector2 offset, Rectangle quad, Color tint)
Texture2D LoadTexture(const char *fileName)
Image ImageText(const char *text, int fontSize, Color color)
int ColorToInt(Color color)
Image GenImageGradientH(int width, int height, Color left, Color right)
int GetPixelDataSize(int width, int height, int format)
void ImageClearBackground(Image *dst, Color color)
Image GenImageChecked(int width, int height, int checksX, int checksY, Color col1, Color col2)
void DrawTextureRec(Texture2D texture, Rectangle source, Vector2 position, Color tint)
Image GenImageGradientRadial(int width, int height, float density, Color inner, Color outer)
Vector4 ColorNormalize(Color color)
void DrawTextureNPatch(Texture2D texture, NPatchInfo nPatchInfo, Rectangle dest, Vector2 origin, float rotation, Color tint)
void UnloadRenderTexture(RenderTexture2D target)
void ImageDrawRectangleLines(Image *dst, Rectangle rec, int thick, Color color)
Image GenImageGradientV(int width, int height, Color top, Color bottom)
#define PIXELFORMAT_UNCOMPRESSED_R5G5B5A1_ALPHA_THRESHOLD
Color ColorFromHSV(float hue, float saturation, float value)
Color GetPixelColor(void *srcPtr, int format)
void ImageColorGrayscale(Image *image)
void ImageResizeCanvas(Image *image, int newWidth, int newHeight, int offsetX, int offsetY, Color fill)
void UnloadTexture(Texture2D texture)
Image GenImageWhiteNoise(int width, int height, float factor)
Color ColorAlphaBlend(Color dst, Color src, Color tint)
void ImageDrawPixel(Image *dst, int x, int y, Color color)
void ImageDither(Image *image, int rBpp, int gBpp, int bBpp, int aBpp)
void ImageColorTint(Image *image, Color color)
void ImageDrawRectangleV(Image *dst, Vector2 position, Vector2 size, Color color)
RenderTexture2D LoadRenderTexture(int width, int height)
void ImageDrawCircle(Image *dst, int centerX, int centerY, int radius, Color color)
Image LoadImageFromMemory(const char *fileType, const unsigned char *fileData, int dataSize)
#define COLOR_EQUAL(col1, col2)
Image ImageCopy(Image image)
void UnloadImage(Image image)
Color GetColor(unsigned int hexValue)
Texture2D LoadTextureFromImage(Image image)
void UpdateTexture(Texture2D texture, const void *pixels)
void ImageDrawCircleV(Image *dst, Vector2 center, int radius, Color color)
Vector3 ColorToHSV(Color color)
void ImageDrawLine(Image *dst, int startPosX, int startPosY, int endPosX, int endPosY, Color color)
void UpdateTextureRec(Texture2D texture, Rectangle rec, const void *pixels)
void DrawTexture(Texture2D texture, int posX, int posY, Color tint)
Image LoadImageAnim(const char *fileName, int *frames)
void ImageMipmaps(Image *image)
void DrawTexturePoly(Texture2D texture, Vector2 center, Vector2 *points, Vector2 *texcoords, int pointCount, Color tint)
void ImageAlphaMask(Image *image, Image alphaMask)
void ImageResize(Image *image, int newWidth, int newHeight)
bool ExportImageAsCode(Image image, const char *fileName)
Color ColorFromNormalized(Vector4 normalized)
Image GenImageCellular(int width, int height, int tileSize)
void DrawTextureV(Texture2D texture, Vector2 position, Color tint)
Rectangle GetImageAlphaBorder(Image image, float threshold)
void DrawTexturePro(Texture2D texture, Rectangle source, Rectangle dest, Vector2 origin, float rotation, Color tint)
void ImageDrawText(Image *dst, const char *text, int posX, int posY, int fontSize, Color color)
Image GenImageColor(int width, int height, Color color)
Image LoadImageRaw(const char *fileName, int width, int height, int format, int headerSize)
void SetTextureFilter(Texture2D texture, int filter)
void ImageColorReplace(Image *image, Color color, Color replace)
#define TEXT_BYTES_PER_LINE
Image ImageTextEx(Font font, const char *text, float fontSize, float spacing, Color tint)
bool ExportImage(Image image, const char *fileName)
void UnloadImagePalette(Color *colors)
Image LoadImage(const char *fileName)
void ImageColorInvert(Image *image)
void UnloadImageColors(Color *colors)
void ImageCrop(Image *image, Rectangle crop)
void ImageDrawRectangle(Image *dst, int posX, int posY, int width, int height, Color color)
void ImageResizeNN(Image *image, int newWidth, int newHeight)
void ImageColorBrightness(Image *image, int brightness)
void SetTextureWrap(Texture2D texture, int wrap)
void ImageDraw(Image *dst, Image src, Rectangle srcRec, Rectangle dstRec, Color tint)
void ImageAlphaClear(Image *image, Color color, float threshold)
Image LoadImageFromScreen(void)
Color GetImageColor(Image image, int x, int y)
void ImageDrawLineV(Image *dst, Vector2 start, Vector2 end, Color color)
Color * LoadImageColors(Image image)
void GenTextureMipmaps(Texture2D *texture)
Image LoadImageFromTexture(Texture2D texture)
void ImageFlipHorizontal(Image *image)
void ImageRotateCW(Image *image)
void ImageDrawTextEx(Image *dst, Font font, const char *text, Vector2 position, float fontSize, float spacing, Color tint)
void ImageFlipVertical(Image *image)
TextureCubemap LoadTextureCubemap(Image image, int layout)
Color * LoadImagePalette(Image image, int maxPaletteSize, int *colorCount)
void ImageColorContrast(Image *image, float contrast)
Image ImageFromImage(Image image, Rectangle rec)
void ImageDrawRectangleRec(Image *dst, Rectangle rec, Color color)
void ImageAlphaCrop(Image *image, float threshold)
void ImageRotateCCW(Image *image)
void DrawTextureEx(Texture2D texture, Vector2 position, float rotation, float scale, Color tint)
void ImageAlphaPremultiply(Image *image)
Color Fade(Color color, float alpha)
void SetPixelColor(void *dstPtr, Color color, int format)
void ImageFormat(Image *image, int newFormat)
void DrawTextureTiled(Texture2D texture, Rectangle source, Rectangle dest, Vector2 origin, float rotation, float scale, Color tint)
void ImageDrawPixelV(Image *dst, Vector2 position, Color color)
void ImageToPOT(Image *image, Color fill)
STBIDEF float * stbi_loadf_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *channels_in_file, int desired_channels)
STBIDEF stbi_uc * stbi_load_gif_from_memory(stbi_uc const *buffer, int len, int **delays, int *x, int *y, int *z, int *comp, int req_comp)
STBIDEF stbi_uc * stbi_load_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *channels_in_file, int desired_channels)
STBIRDEF int stbir_resize_uint8(const unsigned char *input_pixels, int input_w, int input_h, int input_stride_in_bytes, unsigned char *output_pixels, int output_w, int output_h, int output_stride_in_bytes, int num_channels)
STBIWDEF int stbi_write_jpg(char const *filename, int x, int y, int comp, const void *data, int quality)
STBIWDEF int stbi_write_bmp(char const *filename, int w, int h, int comp, const void *data)
STBIWDEF int stbi_write_tga(char const *filename, int w, int h, int comp, const void *data)