From 98350618b0f1efa47264269c28b8d3406e7016ca Mon Sep 17 00:00:00 2001 From: QuzarDC Date: Sun, 7 Jun 2026 04:18:30 -0400 Subject: [PATCH 1/2] Update makefile to link to kos-ports relative paths --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 50d8e80..ffc39ef 100644 --- a/Makefile +++ b/Makefile @@ -7,5 +7,5 @@ include $(KOS_BASE)/addons/Makefile.prefab # creates the kos link to the headers create_kos_link: - rm -f ../include/imageload - ln -s ../libimageload/include ../include/imageload + rm -f $(KOS_PORTS)/include/imageload + ln -s $(CURDIR)/include $(KOS_PORTS)/include/imageload From 7ac49f59fd039de13fcdbdee9e4c09e880d5663a Mon Sep 17 00:00:00 2001 From: QuzarDC Date: Sun, 7 Jun 2026 04:19:12 -0400 Subject: [PATCH 2/2] Updated to stdint types. Only a few had been removed in the previous cleanup. Additionally narrowed the includes from kos to prevent accidentally pulling anything in as was being done with ``. --- imageload.c | 6 +-- include/imageload.h | 23 +++++++----- jitter.c | 2 +- readbmp.c | 92 ++++++++++++++++++++++----------------------- readpcx.c | 6 ++- 5 files changed, 67 insertions(+), 62 deletions(-) diff --git a/imageload.c b/imageload.c index 57578fe..73af4ec 100644 --- a/imageload.c +++ b/imageload.c @@ -1,7 +1,7 @@ -#include "imageload.h" +#include "include/imageload.h" +#include #include -#include #define LOAD565(r, g, b) (((r>>3)<<11) | ((g>>2)<<5) | ((b>>3))) #define LOAD1555(r, g, b, a) (((a>>7)<<15)|((r>>3)<<10)|((g>>3)<<5)|((b>>3))) @@ -10,7 +10,7 @@ IMG_FILE img_guess(const char *filename) { - uint32 len = strlen(filename); + uint32_t len = strlen(filename); const char *end = &filename[len-3]; if (strncasecmp(end,"jpg",3) == 0) return IMG_FILE_JPEG; diff --git a/include/imageload.h b/include/imageload.h index 4a821ef..d92e0d1 100644 --- a/include/imageload.h +++ b/include/imageload.h @@ -1,7 +1,10 @@ #ifndef __IMAGELOAD_H__ #define __IMAGELOAD_H__ -#include +#include +#include + +#include typedef enum { @@ -52,27 +55,27 @@ int img_load_file(const char *filename, IMG_INFO *info, kos_img_t *img); * create a jitter table at compile time */ void jitter_init(void); -uint8 jitter(uint8_t c, uint8_t n, uint8_t shift, uint8_t noise, uint16_t x, uint16_t y); +uint8_t jitter(uint8_t c, uint8_t n, uint8_t shift, uint8_t noise, uint16_t x, uint16_t y); /* Format specific loaders */ -uint32 readbmp_init(FILE *infile); -uint8 *readbmp_get_image(uint32_t *pChannels, uint32_t *pRowbytes, +uint32_t readbmp_init(FILE *infile); +uint8_t *readbmp_get_image(uint32_t *pChannels, uint32_t *pRowbytes, uint32_t *pWidth, uint32_t *pHeight); void readbmp_cleanup(void); -uint32 readpng_init(FILE *infile); -uint8 *readpng_get_image(uint32_t *pChannels, uint32_t *pRowbytes, +uint32_t readpng_init(FILE *infile); +uint8_t *readpng_get_image(uint32_t *pChannels, uint32_t *pRowbytes, uint32_t *pWidth, uint32_t *pHeight); void readpng_cleanup(void); -uint32 readjpeg_init(FILE *infile); -uint8 *readjpeg_get_image(uint32_t *pChannels, uint32_t *pRowbytes, +uint32_t readjpeg_init(FILE *infile); +uint8_t *readjpeg_get_image(uint32_t *pChannels, uint32_t *pRowbytes, uint32_t *pWidth, uint32_t *pHeight); void readjpeg_cleanup(void); -uint32 readpcx_init(FILE *infile); -uint8 *readpcx_get_image(uint32_t *pChannels, uint32_t *pRowbytes, +uint32_t readpcx_init(FILE *infile); +uint8_t *readpcx_get_image(uint32_t *pChannels, uint32_t *pRowbytes, uint32_t *pWidth, uint32_t *pHeight); void readpcx_cleanup(void); #endif diff --git a/jitter.c b/jitter.c index 64c9f7f..d59219f 100644 --- a/jitter.c +++ b/jitter.c @@ -1,4 +1,4 @@ -#include "jitterdefs.h" +#include "include/jitterdefs.h" #include diff --git a/readbmp.c b/readbmp.c index b520d24..7d4cfcf 100644 --- a/readbmp.c +++ b/readbmp.c @@ -1,4 +1,4 @@ -#include + #include #include @@ -11,69 +11,69 @@ #define BI_BITFIELDS 3 typedef struct { - uint16 bfType; - uint32 bfSize; - uint16 bfReserved1; - uint16 bfReserved2; - uint32 bfOffBits; + uint16_t bfType; + uint32_t bfSize; + uint16_t bfReserved1; + uint16_t bfReserved2; + uint32_t bfOffBits; } BITMAPFILEHEADER; typedef struct { - uint32 bcSize; - uint16 bcWidth; - uint16 bcHeight; - uint16 bcPlanes; - uint16 bcBitCount; + uint32_t bcSize; + uint16_t bcWidth; + uint16_t bcHeight; + uint16_t bcPlanes; + uint16_t bcBitCount; } BITMAPCOREHEADER; typedef struct tagBITMAPINFOHEADER { - uint32 biSize; - int32 biWidth; - int32 biHeight; - uint16 biPlanes; - uint16 biBitCount; - uint32 biCompression; - uint32 biSizeImage; - int32 biXPelsPerMeter; - int32 biYPelsPerMeter; - uint32 biClrUsed; - uint32 biClrImportant; + uint32_t biSize; + int32_t biWidth; + int32_t biHeight; + uint16_t biPlanes; + uint16_t biBitCount; + uint32_t biCompression; + uint32_t biSizeImage; + int32_t biXPelsPerMeter; + int32_t biYPelsPerMeter; + uint32_t biClrUsed; + uint32_t biClrImportant; } BITMAPINFOHEADER; typedef struct { - uint8 rgbBlue; - uint8 rgbGreen; - uint8 rgbRed; - uint8 rgbAlpha; + uint8_t rgbBlue; + uint8_t rgbGreen; + uint8_t rgbRed; + uint8_t rgbAlpha; }RGBQUAD; #pragma pack() FILE *bmpfile; -uint32 readbmp_init(FILE *infile) +uint32_t readbmp_init(FILE *infile) { bmpfile = infile; return 0; } -uint8 *readbmp_get_image(uint32 *pChannels, uint32 *pRowbytes, - uint32 *pWidth, uint32 *pHeight) +uint8_t *readbmp_get_image(uint32_t *pChannels, uint32_t *pRowbytes, + uint32_t *pWidth, uint32_t *pHeight) { BITMAPINFOHEADER bitmapInfo; BITMAPFILEHEADER bitmapFile; RGBQUAD *colorTable; - uint32 nNumColors; - uint8 *ourbuffer, *imageBuffer, *buffer; - uint32 rmask = 0xff, gmask = 0xff, bmask = 0xff; - uint32 rshift = 0, gshift = 0, bshift = 0; - uint32 skip, r, g, b, k; - uint32 x, y; - uint8 byte; + uint32_t nNumColors; + uint8_t *ourbuffer, *imageBuffer, *buffer; + uint32_t rmask = 0xff, gmask = 0xff, bmask = 0xff; + uint32_t rshift = 0, gshift = 0, bshift = 0; + uint32_t skip, r, g, b, k; + uint32_t x, y; + uint8_t byte; /* read the BITMAPFILEHEADER */ - uint32 bytesRead = fread(&bitmapFile, 1, sizeof(BITMAPFILEHEADER), bmpfile); + uint32_t bytesRead = fread(&bitmapFile, 1, sizeof(BITMAPFILEHEADER), bmpfile); if ( bytesRead != sizeof(BITMAPFILEHEADER) || bitmapFile.bfType != 0x4d42 /* 'BM' */) { @@ -117,11 +117,11 @@ uint8 *readbmp_get_image(uint32 *pChannels, uint32 *pRowbytes, if (bitmapFile.bfOffBits != 0) fseek(bmpfile,bitmapFile.bfOffBits,SEEK_SET); - imageBuffer = malloc(sizeof(uint8)*bitmapInfo.biSizeImage); + imageBuffer = malloc(sizeof(uint8_t) * bitmapInfo.biSizeImage); buffer = imageBuffer; bytesRead = fread(buffer, 1, bitmapInfo.biSizeImage, bmpfile); - if ( bytesRead != bitmapInfo.biSizeImage*sizeof(uint8)) + if ( bytesRead != bitmapInfo.biSizeImage * sizeof(uint8_t)) { free(colorTable); free(imageBuffer); @@ -132,7 +132,7 @@ uint8 *readbmp_get_image(uint32 *pChannels, uint32 *pRowbytes, *pRowbytes = bitmapInfo.biWidth**pChannels; *pWidth = bitmapInfo.biWidth; *pHeight = bitmapInfo.biHeight; - ourbuffer = (uint8*)malloc(*pRowbytes**pHeight); + ourbuffer = (uint8_t *)malloc(*pRowbytes**pHeight); if (bitmapInfo.biCompression == BI_BITFIELDS) { @@ -234,9 +234,9 @@ uint8 *readbmp_get_image(uint32 *pChannels, uint32 *pRowbytes, { for (x = 0; x < bitmapInfo.biWidth; x++) { - r = ((uint16)(*buffer) & rmask) >> rshift; - g = ((uint16)(*buffer) & gmask) >> gshift; - b = ((uint16)(*(buffer++)) & bmask) >> bshift; + r = ((uint16_t)(*buffer) & rmask) >> rshift; + g = ((uint16_t)(*buffer) & gmask) >> gshift; + b = ((uint16_t)(*(buffer++)) & bmask) >> bshift; ourbuffer[(bitmapInfo.biHeight-y-1)**pRowbytes+3*x] = r; ourbuffer[(bitmapInfo.biHeight-y-1)**pRowbytes+3*x+1] = g; @@ -270,9 +270,9 @@ uint8 *readbmp_get_image(uint32 *pChannels, uint32 *pRowbytes, { for (x = 0; x < bitmapInfo.biWidth; x++) { - r = ((uint32)(*buffer) & rmask) >> rshift; - g = ((uint32)(*buffer) & gmask) >> gshift; - b = ((uint32)(*buffer) & bmask) >> bshift; + r = ((uint32_t)(*buffer) & rmask) >> rshift; + g = ((uint32_t)(*buffer) & gmask) >> gshift; + b = ((uint32_t)(*buffer) & bmask) >> bshift; ourbuffer[(bitmapInfo.biHeight-y-1)**pRowbytes+3*x] = r; ourbuffer[(bitmapInfo.biHeight-y-1)**pRowbytes+3*x+1] = g; diff --git a/readpcx.c b/readpcx.c index fdcb3a4..27bcb0a 100644 --- a/readpcx.c +++ b/readpcx.c @@ -2,10 +2,12 @@ readpcx.c - PCX image loader (_heavily_ stolen from Dan Potters code) + PCX image loader (_heavily_ stolen from Megan Potters code) */ -#include +#include +#include +#include typedef struct { char mfg; /* manufacturer, always 0xa0 */