From 6fb75c1ea764e6838d88bfcf3693ac68a7c2dac0 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 18 Mar 2024 11:49:12 -0700 Subject: [PATCH] Updated for the SDL3 RW -> IO changes Fixes https://github.com/libsdl-org/SDL_image/issues/436 --- CHANGES.txt | 2 +- README.txt | 6 +- external/SDL | 2 +- include/SDL3_image/SDL_image.h | 1191 ++++++++++++++++---------------- src/IMG.c | 122 ++-- src/IMG_ImageIO.m | 98 +-- src/IMG_WIC.c | 44 +- src/IMG_avif.c | 50 +- src/IMG_bmp.c | 74 +- src/IMG_gif.c | 56 +- src/IMG_jpg.c | 106 +-- src/IMG_jxl.c | 24 +- src/IMG_lbm.c | 46 +- src/IMG_pcx.c | 34 +- src/IMG_png.c | 72 +- src/IMG_pnm.c | 34 +- src/IMG_qoi.c | 16 +- src/IMG_stb.c | 34 +- src/IMG_svg.c | 20 +- src/IMG_tga.c | 26 +- src/IMG_tif.c | 38 +- src/IMG_webp.c | 38 +- src/IMG_xcf.c | 80 +-- src/IMG_xpm.c | 34 +- src/IMG_xv.c | 26 +- src/IMG_xxx.c | 18 +- src/SDL_image.sym | 62 +- test/main.c | 96 +-- 28 files changed, 1225 insertions(+), 1224 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index c485d4ce..5084189b 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,4 @@ 3.0.0: * Added support for loading HDR AVIF images * Added AVIF save support: - IMG_SaveAVIF() and IMG_SaveAVIF_RW() + IMG_SaveAVIF() and IMG_SaveAVIF_IO() diff --git a/README.txt b/README.txt index 4a5ebc6a..9fe97809 100644 --- a/README.txt +++ b/README.txt @@ -12,12 +12,12 @@ API: SDL_Surface *IMG_Load(const char *file); or - SDL_Surface *IMG_Load_RW(SDL_RWops *src, SDL_bool freesrc); + SDL_Surface *IMG_Load_IO(SDL_IOStream *src, SDL_bool closeio); or - SDL_Surface *IMG_LoadTyped_RW(SDL_RWops *src, SDL_bool freesrc, char *type); + SDL_Surface *IMG_LoadTyped_IO(SDL_IOStream *src, SDL_bool closeio, char *type); where type is a string specifying the format (i.e. "PNG" or "pcx"). -Note that IMG_Load_RW cannot load TGA images. +Note that IMG_Load_IO cannot load TGA images. To create a surface from an XPM image included in C source, use: diff --git a/external/SDL b/external/SDL index 2132ba89..086a7a46 160000 --- a/external/SDL +++ b/external/SDL @@ -1 +1 @@ -Subproject commit 2132ba8985c55f9893d4b10db01fb600743bed32 +Subproject commit 086a7a468738c915f48dab940482cfe0dec1b57a diff --git a/include/SDL3_image/SDL_image.h b/include/SDL3_image/SDL_image.h index de27db4f..6ceaed69 100644 --- a/include/SDL3_image/SDL_image.h +++ b/include/SDL3_image/SDL_image.h @@ -210,9 +210,9 @@ extern DECLSPEC void SDLCALL IMG_Quit(void); * by calling: SDL_SetSurfaceColorKey(image, SDL_RLEACCEL, * image->format->colorkey); * - * If `freesrc` is SDL_TRUE, the RWops will be closed before returning, + * If `closeio` is SDL_TRUE, `src` will be closed before returning, * whether this function succeeds or not. SDL_image reads everything it needs - * from the RWops during this call in any case. + * from `src` during this call in any case. * * Even though this function accepts a file type, SDL_image may still try * other decoders that are capable of detecting file type from the contents of @@ -221,23 +221,23 @@ extern DECLSPEC void SDLCALL IMG_Quit(void); * its ability to guess the format. * * There is a separate function to read files from disk without having to deal - * with SDL_RWops: `IMG_Load("filename.jpg")` will call this function and + * with SDL_IOStream: `IMG_Load("filename.jpg")` will call this function and * manage those details for you, determining the file type from the filename's * extension. * - * There is also IMG_Load_RW(), which is equivalent to this function except + * There is also IMG_Load_IO(), which is equivalent to this function except * that it will rely on SDL_image to determine what type of data it is * loading, much like passing a NULL for type. * * If you are using SDL's 2D rendering API, there is an equivalent call to * load images directly into an SDL_Texture for use by the GPU without using a - * software surface: call IMG_LoadTextureTyped_RW() instead. + * software surface: call IMG_LoadTextureTyped_IO() instead. * * When done with the returned surface, the app should dispose of it with a * call to SDL_DestroySurface(). * - * \param src an SDL_RWops that data will be read from. - * \param freesrc SDL_TRUE to close/free the SDL_RWops before returning, + * \param src an SDL_IOStream that data will be read from. + * \param closeio SDL_TRUE to close/free the SDL_IOStream before returning, * SDL_FALSE to leave it open. * \param type a filename extension that represent this data ("BMP", "GIF", * "PNG", etc). @@ -246,10 +246,10 @@ extern DECLSPEC void SDLCALL IMG_Quit(void); * \since This function is available since SDL_image 3.0.0. * * \sa IMG_Load - * \sa IMG_Load_RW + * \sa IMG_Load_IO * \sa SDL_DestroySurface */ -extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadTyped_RW(SDL_RWops *src, SDL_bool freesrc, const char *type); +extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadTyped_IO(SDL_IOStream *src, SDL_bool closeio, const char *type); /** * Load an image from a filesystem path into a software surface. @@ -272,9 +272,9 @@ extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadTyped_RW(SDL_RWops *src, SDL_bool * by calling: SDL_SetSurfaceColorKey(image, SDL_RLEACCEL, * image->format->colorkey); * - * There is a separate function to read files from an SDL_RWops, if you need + * There is a separate function to read files from an SDL_IOStream, if you need * an i/o abstraction to provide data from anywhere instead of a simple - * filesystem read; that function is IMG_Load_RW(). + * filesystem read; that function is IMG_Load_IO(). * * If you are using SDL's 2D rendering API, there is an equivalent call to * load images directly into an SDL_Texture for use by the GPU without using a @@ -288,8 +288,8 @@ extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadTyped_RW(SDL_RWops *src, SDL_bool * * \since This function is available since SDL_image 3.0.0. * - * \sa IMG_LoadTyped_RW - * \sa IMG_Load_RW + * \sa IMG_LoadTyped_IO + * \sa IMG_Load_IO * \sa SDL_DestroySurface */ extern DECLSPEC SDL_Surface * SDLCALL IMG_Load(const char *file); @@ -315,38 +315,38 @@ extern DECLSPEC SDL_Surface * SDLCALL IMG_Load(const char *file); * by calling: SDL_SetSurfaceColorKey(image, SDL_RLEACCEL, * image->format->colorkey); * - * If `freesrc` is SDL_TRUE, the RWops will be closed before returning, + * If `closeio` is SDL_TRUE, `src` will be closed before returning, * whether this function succeeds or not. SDL_image reads everything it needs - * from the RWops during this call in any case. + * from `src` during this call in any case. * * There is a separate function to read files from disk without having to deal - * with SDL_RWops: `IMG_Load("filename.jpg")` will call this function and + * with SDL_IOStream: `IMG_Load("filename.jpg")` will call this function and * manage those details for you, determining the file type from the filename's * extension. * - * There is also IMG_LoadTyped_RW(), which is equivalent to this function + * There is also IMG_LoadTyped_IO(), which is equivalent to this function * except a file extension (like "BMP", "JPG", etc) can be specified, in case * SDL_image cannot autodetect the file format. * * If you are using SDL's 2D rendering API, there is an equivalent call to * load images directly into an SDL_Texture for use by the GPU without using a - * software surface: call IMG_LoadTexture_RW() instead. + * software surface: call IMG_LoadTexture_IO() instead. * * When done with the returned surface, the app should dispose of it with a * call to SDL_DestroySurface(). * - * \param src an SDL_RWops that data will be read from. - * \param freesrc SDL_TRUE to close/free the SDL_RWops before returning, + * \param src an SDL_IOStream that data will be read from. + * \param closeio SDL_TRUE to close/free the SDL_IOStream before returning, * SDL_FALSE to leave it open. * \returns a new SDL surface, or NULL on error. * * \since This function is available since SDL_image 3.0.0. * * \sa IMG_Load - * \sa IMG_LoadTyped_RW + * \sa IMG_LoadTyped_IO * \sa SDL_DestroySurface */ -extern DECLSPEC SDL_Surface * SDLCALL IMG_Load_RW(SDL_RWops *src, SDL_bool freesrc); +extern DECLSPEC SDL_Surface * SDLCALL IMG_Load_IO(SDL_IOStream *src, SDL_bool closeio); #if SDL_VERSION_ATLEAST(2,0,0) @@ -364,9 +364,9 @@ extern DECLSPEC SDL_Surface * SDLCALL IMG_Load_RW(SDL_RWops *src, SDL_bool frees * data (but in many cases, this will just end up being 32-bit RGB or 32-bit * RGBA). * - * There is a separate function to read files from an SDL_RWops, if you need + * There is a separate function to read files from an SDL_IOStream, if you need * an i/o abstraction to provide data from anywhere instead of a simple - * filesystem read; that function is IMG_LoadTexture_RW(). + * filesystem read; that function is IMG_LoadTexture_IO(). * * If you would rather decode an image to an SDL_Surface (a buffer of pixels * in CPU memory), call IMG_Load() instead. @@ -380,8 +380,8 @@ extern DECLSPEC SDL_Surface * SDLCALL IMG_Load_RW(SDL_RWops *src, SDL_bool frees * * \since This function is available since SDL_image 3.0.0. * - * \sa IMG_LoadTextureTyped_RW - * \sa IMG_LoadTexture_RW + * \sa IMG_LoadTextureTyped_IO + * \sa IMG_LoadTexture_IO */ extern DECLSPEC SDL_Texture * SDLCALL IMG_LoadTexture(SDL_Renderer *renderer, const char *file); @@ -399,16 +399,16 @@ extern DECLSPEC SDL_Texture * SDLCALL IMG_LoadTexture(SDL_Renderer *renderer, co * data (but in many cases, this will just end up being 32-bit RGB or 32-bit * RGBA). * - * If `freesrc` is SDL_TRUE, the RWops will be closed before returning, + * If `closeio` is SDL_TRUE, `src` will be closed before returning, * whether this function succeeds or not. SDL_image reads everything it needs - * from the RWops during this call in any case. + * from `src` during this call in any case. * * There is a separate function to read files from disk without having to deal - * with SDL_RWops: `IMG_LoadTexture(renderer, "filename.jpg")` will call this + * with SDL_IOStream: `IMG_LoadTexture(renderer, "filename.jpg")` will call this * function and manage those details for you, determining the file type from * the filename's extension. * - * There is also IMG_LoadTextureTyped_RW(), which is equivalent to this + * There is also IMG_LoadTextureTyped_IO(), which is equivalent to this * function except a file extension (like "BMP", "JPG", etc) can be specified, * in case SDL_image cannot autodetect the file format. * @@ -419,18 +419,18 @@ extern DECLSPEC SDL_Texture * SDLCALL IMG_LoadTexture(SDL_Renderer *renderer, co * call to SDL_DestroyTexture(). * * \param renderer the SDL_Renderer to use to create the GPU texture. - * \param src an SDL_RWops that data will be read from. - * \param freesrc SDL_TRUE to close/free the SDL_RWops before returning, + * \param src an SDL_IOStream that data will be read from. + * \param closeio SDL_TRUE to close/free the SDL_IOStream before returning, * SDL_FALSE to leave it open. * \returns a new texture, or NULL on error. * * \since This function is available since SDL_image 3.0.0. * * \sa IMG_LoadTexture - * \sa IMG_LoadTextureTyped_RW + * \sa IMG_LoadTextureTyped_IO * \sa SDL_DestroyTexture */ -extern DECLSPEC SDL_Texture * SDLCALL IMG_LoadTexture_RW(SDL_Renderer *renderer, SDL_RWops *src, SDL_bool freesrc); +extern DECLSPEC SDL_Texture * SDLCALL IMG_LoadTexture_IO(SDL_Renderer *renderer, SDL_IOStream *src, SDL_bool closeio); /** * Load an image from an SDL data source into a GPU texture. @@ -446,9 +446,9 @@ extern DECLSPEC SDL_Texture * SDLCALL IMG_LoadTexture_RW(SDL_Renderer *renderer, * data (but in many cases, this will just end up being 32-bit RGB or 32-bit * RGBA). * - * If `freesrc` is SDL_TRUE, the RWops will be closed before returning, + * If `closeio` is SDL_TRUE, `src` will be closed before returning, * whether this function succeeds or not. SDL_image reads everything it needs - * from the RWops during this call in any case. + * from `src` during this call in any case. * * Even though this function accepts a file type, SDL_image may still try * other decoders that are capable of detecting file type from the contents of @@ -457,23 +457,23 @@ extern DECLSPEC SDL_Texture * SDLCALL IMG_LoadTexture_RW(SDL_Renderer *renderer, * its ability to guess the format. * * There is a separate function to read files from disk without having to deal - * with SDL_RWops: `IMG_LoadTexture("filename.jpg")` will call this function + * with SDL_IOStream: `IMG_LoadTexture("filename.jpg")` will call this function * and manage those details for you, determining the file type from the * filename's extension. * - * There is also IMG_LoadTexture_RW(), which is equivalent to this function + * There is also IMG_LoadTexture_IO(), which is equivalent to this function * except that it will rely on SDL_image to determine what type of data it is * loading, much like passing a NULL for type. * * If you would rather decode an image to an SDL_Surface (a buffer of pixels - * in CPU memory), call IMG_LoadTyped_RW() instead. + * in CPU memory), call IMG_LoadTyped_IO() instead. * * When done with the returned texture, the app should dispose of it with a * call to SDL_DestroyTexture(). * * \param renderer the SDL_Renderer to use to create the GPU texture. - * \param src an SDL_RWops that data will be read from. - * \param freesrc SDL_TRUE to close/free the SDL_RWops before returning, + * \param src an SDL_IOStream that data will be read from. + * \param closeio SDL_TRUE to close/free the SDL_IOStream before returning, * SDL_FALSE to leave it open. * \param type a filename extension that represent this data ("BMP", "GIF", * "PNG", etc). @@ -482,22 +482,22 @@ extern DECLSPEC SDL_Texture * SDLCALL IMG_LoadTexture_RW(SDL_Renderer *renderer, * \since This function is available since SDL_image 3.0.0. * * \sa IMG_LoadTexture - * \sa IMG_LoadTexture_RW + * \sa IMG_LoadTexture_IO * \sa SDL_DestroyTexture */ -extern DECLSPEC SDL_Texture * SDLCALL IMG_LoadTextureTyped_RW(SDL_Renderer *renderer, SDL_RWops *src, SDL_bool freesrc, const char *type); +extern DECLSPEC SDL_Texture * SDLCALL IMG_LoadTextureTyped_IO(SDL_Renderer *renderer, SDL_IOStream *src, SDL_bool closeio, const char *type); #endif /* SDL 2.0 */ /** - * Detect AVIF image data on a readable/seekable SDL_RWops. + * Detect AVIF image data on a readable/seekable SDL_IOStream. * * This function attempts to determine if a file is a given filetype, reading - * the least amount possible from the SDL_RWops (usually a few bytes). + * the least amount possible from the SDL_IOStream (usually a few bytes). * * There is no distinction made between "not the filetype in question" and * basic i/o errors. * - * This function will always attempt to seek the RWops back to where it + * This function will always attempt to seek `src` back to where it * started when this function was called, but it will not report any errors in * doing so, but assuming seeking works, this means you can immediately use * this with a different IMG_isTYPE function, or load the image without @@ -506,7 +506,7 @@ extern DECLSPEC SDL_Texture * SDLCALL IMG_LoadTextureTyped_RW(SDL_Renderer *rend * You do not need to call this function to load data; SDL_image can work to * determine file type in many cases in its standard load functions. * - * \param src a seekable/readable SDL_RWops to provide image data. + * \param src a seekable/readable SDL_IOStream to provide image data. * \returns non-zero if this is AVIF data, zero otherwise. * * \since This function is available since SDL_image 3.0.0. @@ -530,18 +530,18 @@ extern DECLSPEC SDL_Texture * SDLCALL IMG_LoadTextureTyped_RW(SDL_Renderer *rend * \sa IMG_isXV * \sa IMG_isWEBP */ -extern DECLSPEC int SDLCALL IMG_isAVIF(SDL_RWops *src); +extern DECLSPEC int SDLCALL IMG_isAVIF(SDL_IOStream *src); /** - * Detect ICO image data on a readable/seekable SDL_RWops. + * Detect ICO image data on a readable/seekable SDL_IOStream. * * This function attempts to determine if a file is a given filetype, reading - * the least amount possible from the SDL_RWops (usually a few bytes). + * the least amount possible from the SDL_IOStream (usually a few bytes). * * There is no distinction made between "not the filetype in question" and * basic i/o errors. * - * This function will always attempt to seek the RWops back to where it + * This function will always attempt to seek `src` back to where it * started when this function was called, but it will not report any errors in * doing so, but assuming seeking works, this means you can immediately use * this with a different IMG_isTYPE function, or load the image without @@ -550,7 +550,7 @@ extern DECLSPEC int SDLCALL IMG_isAVIF(SDL_RWops *src); * You do not need to call this function to load data; SDL_image can work to * determine file type in many cases in its standard load functions. * - * \param src a seekable/readable SDL_RWops to provide image data. + * \param src a seekable/readable SDL_IOStream to provide image data. * \returns non-zero if this is ICO data, zero otherwise. * * \since This function is available since SDL_image 3.0.0. @@ -573,18 +573,18 @@ extern DECLSPEC int SDLCALL IMG_isAVIF(SDL_RWops *src); * \sa IMG_isXV * \sa IMG_isWEBP */ -extern DECLSPEC int SDLCALL IMG_isICO(SDL_RWops *src); +extern DECLSPEC int SDLCALL IMG_isICO(SDL_IOStream *src); /** - * Detect CUR image data on a readable/seekable SDL_RWops. + * Detect CUR image data on a readable/seekable SDL_IOStream. * * This function attempts to determine if a file is a given filetype, reading - * the least amount possible from the SDL_RWops (usually a few bytes). + * the least amount possible from the SDL_IOStream (usually a few bytes). * * There is no distinction made between "not the filetype in question" and * basic i/o errors. * - * This function will always attempt to seek the RWops back to where it + * This function will always attempt to seek `src` back to where it * started when this function was called, but it will not report any errors in * doing so, but assuming seeking works, this means you can immediately use * this with a different IMG_isTYPE function, or load the image without @@ -593,7 +593,7 @@ extern DECLSPEC int SDLCALL IMG_isICO(SDL_RWops *src); * You do not need to call this function to load data; SDL_image can work to * determine file type in many cases in its standard load functions. * - * \param src a seekable/readable SDL_RWops to provide image data. + * \param src a seekable/readable SDL_IOStream to provide image data. * \returns non-zero if this is CUR data, zero otherwise. * * \since This function is available since SDL_image 3.0.0. @@ -616,18 +616,18 @@ extern DECLSPEC int SDLCALL IMG_isICO(SDL_RWops *src); * \sa IMG_isXV * \sa IMG_isWEBP */ -extern DECLSPEC int SDLCALL IMG_isCUR(SDL_RWops *src); +extern DECLSPEC int SDLCALL IMG_isCUR(SDL_IOStream *src); /** - * Detect BMP image data on a readable/seekable SDL_RWops. + * Detect BMP image data on a readable/seekable SDL_IOStream. * * This function attempts to determine if a file is a given filetype, reading - * the least amount possible from the SDL_RWops (usually a few bytes). + * the least amount possible from the SDL_IOStream (usually a few bytes). * * There is no distinction made between "not the filetype in question" and * basic i/o errors. * - * This function will always attempt to seek the RWops back to where it + * This function will always attempt to seek `src` back to where it * started when this function was called, but it will not report any errors in * doing so, but assuming seeking works, this means you can immediately use * this with a different IMG_isTYPE function, or load the image without @@ -636,7 +636,7 @@ extern DECLSPEC int SDLCALL IMG_isCUR(SDL_RWops *src); * You do not need to call this function to load data; SDL_image can work to * determine file type in many cases in its standard load functions. * - * \param src a seekable/readable SDL_RWops to provide image data. + * \param src a seekable/readable SDL_IOStream to provide image data. * \returns non-zero if this is BMP data, zero otherwise. * * \since This function is available since SDL_image 3.0.0. @@ -659,18 +659,18 @@ extern DECLSPEC int SDLCALL IMG_isCUR(SDL_RWops *src); * \sa IMG_isXV * \sa IMG_isWEBP */ -extern DECLSPEC int SDLCALL IMG_isBMP(SDL_RWops *src); +extern DECLSPEC int SDLCALL IMG_isBMP(SDL_IOStream *src); /** - * Detect GIF image data on a readable/seekable SDL_RWops. + * Detect GIF image data on a readable/seekable SDL_IOStream. * * This function attempts to determine if a file is a given filetype, reading - * the least amount possible from the SDL_RWops (usually a few bytes). + * the least amount possible from the SDL_IOStream (usually a few bytes). * * There is no distinction made between "not the filetype in question" and * basic i/o errors. * - * This function will always attempt to seek the RWops back to where it + * This function will always attempt to seek `src` back to where it * started when this function was called, but it will not report any errors in * doing so, but assuming seeking works, this means you can immediately use * this with a different IMG_isTYPE function, or load the image without @@ -679,7 +679,7 @@ extern DECLSPEC int SDLCALL IMG_isBMP(SDL_RWops *src); * You do not need to call this function to load data; SDL_image can work to * determine file type in many cases in its standard load functions. * - * \param src a seekable/readable SDL_RWops to provide image data. + * \param src a seekable/readable SDL_IOStream to provide image data. * \returns non-zero if this is GIF data, zero otherwise. * * \since This function is available since SDL_image 3.0.0. @@ -702,18 +702,18 @@ extern DECLSPEC int SDLCALL IMG_isBMP(SDL_RWops *src); * \sa IMG_isXV * \sa IMG_isWEBP */ -extern DECLSPEC int SDLCALL IMG_isGIF(SDL_RWops *src); +extern DECLSPEC int SDLCALL IMG_isGIF(SDL_IOStream *src); /** - * Detect JPG image data on a readable/seekable SDL_RWops. + * Detect JPG image data on a readable/seekable SDL_IOStream. * * This function attempts to determine if a file is a given filetype, reading - * the least amount possible from the SDL_RWops (usually a few bytes). + * the least amount possible from the SDL_IOStream (usually a few bytes). * * There is no distinction made between "not the filetype in question" and * basic i/o errors. * - * This function will always attempt to seek the RWops back to where it + * This function will always attempt to seek `src` back to where it * started when this function was called, but it will not report any errors in * doing so, but assuming seeking works, this means you can immediately use * this with a different IMG_isTYPE function, or load the image without @@ -722,7 +722,7 @@ extern DECLSPEC int SDLCALL IMG_isGIF(SDL_RWops *src); * You do not need to call this function to load data; SDL_image can work to * determine file type in many cases in its standard load functions. * - * \param src a seekable/readable SDL_RWops to provide image data. + * \param src a seekable/readable SDL_IOStream to provide image data. * \returns non-zero if this is JPG data, zero otherwise. * * \since This function is available since SDL_image 3.0.0. @@ -745,18 +745,18 @@ extern DECLSPEC int SDLCALL IMG_isGIF(SDL_RWops *src); * \sa IMG_isXV * \sa IMG_isWEBP */ -extern DECLSPEC int SDLCALL IMG_isJPG(SDL_RWops *src); +extern DECLSPEC int SDLCALL IMG_isJPG(SDL_IOStream *src); /** - * Detect JXL image data on a readable/seekable SDL_RWops. + * Detect JXL image data on a readable/seekable SDL_IOStream. * * This function attempts to determine if a file is a given filetype, reading - * the least amount possible from the SDL_RWops (usually a few bytes). + * the least amount possible from the SDL_IOStream (usually a few bytes). * * There is no distinction made between "not the filetype in question" and * basic i/o errors. * - * This function will always attempt to seek the RWops back to where it + * This function will always attempt to seek `src` back to where it * started when this function was called, but it will not report any errors in * doing so, but assuming seeking works, this means you can immediately use * this with a different IMG_isTYPE function, or load the image without @@ -765,7 +765,7 @@ extern DECLSPEC int SDLCALL IMG_isJPG(SDL_RWops *src); * You do not need to call this function to load data; SDL_image can work to * determine file type in many cases in its standard load functions. * - * \param src a seekable/readable SDL_RWops to provide image data. + * \param src a seekable/readable SDL_IOStream to provide image data. * \returns non-zero if this is JXL data, zero otherwise. * * \since This function is available since SDL_image 3.0.0. @@ -788,18 +788,18 @@ extern DECLSPEC int SDLCALL IMG_isJPG(SDL_RWops *src); * \sa IMG_isXV * \sa IMG_isWEBP */ -extern DECLSPEC int SDLCALL IMG_isJXL(SDL_RWops *src); +extern DECLSPEC int SDLCALL IMG_isJXL(SDL_IOStream *src); /** - * Detect LBM image data on a readable/seekable SDL_RWops. + * Detect LBM image data on a readable/seekable SDL_IOStream. * * This function attempts to determine if a file is a given filetype, reading - * the least amount possible from the SDL_RWops (usually a few bytes). + * the least amount possible from the SDL_IOStream (usually a few bytes). * * There is no distinction made between "not the filetype in question" and * basic i/o errors. * - * This function will always attempt to seek the RWops back to where it + * This function will always attempt to seek `src` back to where it * started when this function was called, but it will not report any errors in * doing so, but assuming seeking works, this means you can immediately use * this with a different IMG_isTYPE function, or load the image without @@ -808,7 +808,7 @@ extern DECLSPEC int SDLCALL IMG_isJXL(SDL_RWops *src); * You do not need to call this function to load data; SDL_image can work to * determine file type in many cases in its standard load functions. * - * \param src a seekable/readable SDL_RWops to provide image data. + * \param src a seekable/readable SDL_IOStream to provide image data. * \returns non-zero if this is LBM data, zero otherwise. * * \since This function is available since SDL_image 3.0.0. @@ -831,18 +831,18 @@ extern DECLSPEC int SDLCALL IMG_isJXL(SDL_RWops *src); * \sa IMG_isXV * \sa IMG_isWEBP */ -extern DECLSPEC int SDLCALL IMG_isLBM(SDL_RWops *src); +extern DECLSPEC int SDLCALL IMG_isLBM(SDL_IOStream *src); /** - * Detect PCX image data on a readable/seekable SDL_RWops. + * Detect PCX image data on a readable/seekable SDL_IOStream. * * This function attempts to determine if a file is a given filetype, reading - * the least amount possible from the SDL_RWops (usually a few bytes). + * the least amount possible from the SDL_IOStream (usually a few bytes). * * There is no distinction made between "not the filetype in question" and * basic i/o errors. * - * This function will always attempt to seek the RWops back to where it + * This function will always attempt to seek `src` back to where it * started when this function was called, but it will not report any errors in * doing so, but assuming seeking works, this means you can immediately use * this with a different IMG_isTYPE function, or load the image without @@ -851,7 +851,7 @@ extern DECLSPEC int SDLCALL IMG_isLBM(SDL_RWops *src); * You do not need to call this function to load data; SDL_image can work to * determine file type in many cases in its standard load functions. * - * \param src a seekable/readable SDL_RWops to provide image data. + * \param src a seekable/readable SDL_IOStream to provide image data. * \returns non-zero if this is PCX data, zero otherwise. * * \since This function is available since SDL_image 3.0.0. @@ -874,18 +874,18 @@ extern DECLSPEC int SDLCALL IMG_isLBM(SDL_RWops *src); * \sa IMG_isXV * \sa IMG_isWEBP */ -extern DECLSPEC int SDLCALL IMG_isPCX(SDL_RWops *src); +extern DECLSPEC int SDLCALL IMG_isPCX(SDL_IOStream *src); /** - * Detect PNG image data on a readable/seekable SDL_RWops. + * Detect PNG image data on a readable/seekable SDL_IOStream. * * This function attempts to determine if a file is a given filetype, reading - * the least amount possible from the SDL_RWops (usually a few bytes). + * the least amount possible from the SDL_IOStream (usually a few bytes). * * There is no distinction made between "not the filetype in question" and * basic i/o errors. * - * This function will always attempt to seek the RWops back to where it + * This function will always attempt to seek `src` back to where it * started when this function was called, but it will not report any errors in * doing so, but assuming seeking works, this means you can immediately use * this with a different IMG_isTYPE function, or load the image without @@ -894,7 +894,7 @@ extern DECLSPEC int SDLCALL IMG_isPCX(SDL_RWops *src); * You do not need to call this function to load data; SDL_image can work to * determine file type in many cases in its standard load functions. * - * \param src a seekable/readable SDL_RWops to provide image data. + * \param src a seekable/readable SDL_IOStream to provide image data. * \returns non-zero if this is PNG data, zero otherwise. * * \since This function is available since SDL_image 3.0.0. @@ -917,18 +917,18 @@ extern DECLSPEC int SDLCALL IMG_isPCX(SDL_RWops *src); * \sa IMG_isXV * \sa IMG_isWEBP */ -extern DECLSPEC int SDLCALL IMG_isPNG(SDL_RWops *src); +extern DECLSPEC int SDLCALL IMG_isPNG(SDL_IOStream *src); /** - * Detect PNM image data on a readable/seekable SDL_RWops. + * Detect PNM image data on a readable/seekable SDL_IOStream. * * This function attempts to determine if a file is a given filetype, reading - * the least amount possible from the SDL_RWops (usually a few bytes). + * the least amount possible from the SDL_IOStream (usually a few bytes). * * There is no distinction made between "not the filetype in question" and * basic i/o errors. * - * This function will always attempt to seek the RWops back to where it + * This function will always attempt to seek `src` back to where it * started when this function was called, but it will not report any errors in * doing so, but assuming seeking works, this means you can immediately use * this with a different IMG_isTYPE function, or load the image without @@ -937,7 +937,7 @@ extern DECLSPEC int SDLCALL IMG_isPNG(SDL_RWops *src); * You do not need to call this function to load data; SDL_image can work to * determine file type in many cases in its standard load functions. * - * \param src a seekable/readable SDL_RWops to provide image data. + * \param src a seekable/readable SDL_IOStream to provide image data. * \returns non-zero if this is PNM data, zero otherwise. * * \since This function is available since SDL_image 3.0.0. @@ -960,18 +960,18 @@ extern DECLSPEC int SDLCALL IMG_isPNG(SDL_RWops *src); * \sa IMG_isXV * \sa IMG_isWEBP */ -extern DECLSPEC int SDLCALL IMG_isPNM(SDL_RWops *src); +extern DECLSPEC int SDLCALL IMG_isPNM(SDL_IOStream *src); /** - * Detect SVG image data on a readable/seekable SDL_RWops. + * Detect SVG image data on a readable/seekable SDL_IOStream. * * This function attempts to determine if a file is a given filetype, reading - * the least amount possible from the SDL_RWops (usually a few bytes). + * the least amount possible from the SDL_IOStream (usually a few bytes). * * There is no distinction made between "not the filetype in question" and * basic i/o errors. * - * This function will always attempt to seek the RWops back to where it + * This function will always attempt to seek `src` back to where it * started when this function was called, but it will not report any errors in * doing so, but assuming seeking works, this means you can immediately use * this with a different IMG_isTYPE function, or load the image without @@ -980,7 +980,7 @@ extern DECLSPEC int SDLCALL IMG_isPNM(SDL_RWops *src); * You do not need to call this function to load data; SDL_image can work to * determine file type in many cases in its standard load functions. * - * \param src a seekable/readable SDL_RWops to provide image data. + * \param src a seekable/readable SDL_IOStream to provide image data. * \returns non-zero if this is SVG data, zero otherwise. * * \since This function is available since SDL_image 3.0.0. @@ -1003,18 +1003,18 @@ extern DECLSPEC int SDLCALL IMG_isPNM(SDL_RWops *src); * \sa IMG_isXV * \sa IMG_isWEBP */ -extern DECLSPEC int SDLCALL IMG_isSVG(SDL_RWops *src); +extern DECLSPEC int SDLCALL IMG_isSVG(SDL_IOStream *src); /** - * Detect QOI image data on a readable/seekable SDL_RWops. + * Detect QOI image data on a readable/seekable SDL_IOStream. * * This function attempts to determine if a file is a given filetype, reading - * the least amount possible from the SDL_RWops (usually a few bytes). + * the least amount possible from the SDL_IOStream (usually a few bytes). * * There is no distinction made between "not the filetype in question" and * basic i/o errors. * - * This function will always attempt to seek the RWops back to where it + * This function will always attempt to seek `src` back to where it * started when this function was called, but it will not report any errors in * doing so, but assuming seeking works, this means you can immediately use * this with a different IMG_isTYPE function, or load the image without @@ -1023,7 +1023,7 @@ extern DECLSPEC int SDLCALL IMG_isSVG(SDL_RWops *src); * You do not need to call this function to load data; SDL_image can work to * determine file type in many cases in its standard load functions. * - * \param src a seekable/readable SDL_RWops to provide image data. + * \param src a seekable/readable SDL_IOStream to provide image data. * \returns non-zero if this is QOI data, zero otherwise. * * \since This function is available since SDL_image 3.0.0. @@ -1046,18 +1046,18 @@ extern DECLSPEC int SDLCALL IMG_isSVG(SDL_RWops *src); * \sa IMG_isXV * \sa IMG_isWEBP */ -extern DECLSPEC int SDLCALL IMG_isQOI(SDL_RWops *src); +extern DECLSPEC int SDLCALL IMG_isQOI(SDL_IOStream *src); /** - * Detect TIFF image data on a readable/seekable SDL_RWops. + * Detect TIFF image data on a readable/seekable SDL_IOStream. * * This function attempts to determine if a file is a given filetype, reading - * the least amount possible from the SDL_RWops (usually a few bytes). + * the least amount possible from the SDL_IOStream (usually a few bytes). * * There is no distinction made between "not the filetype in question" and * basic i/o errors. * - * This function will always attempt to seek the RWops back to where it + * This function will always attempt to seek `src` back to where it * started when this function was called, but it will not report any errors in * doing so, but assuming seeking works, this means you can immediately use * this with a different IMG_isTYPE function, or load the image without @@ -1066,7 +1066,7 @@ extern DECLSPEC int SDLCALL IMG_isQOI(SDL_RWops *src); * You do not need to call this function to load data; SDL_image can work to * determine file type in many cases in its standard load functions. * - * \param src a seekable/readable SDL_RWops to provide image data. + * \param src a seekable/readable SDL_IOStream to provide image data. * \returns non-zero if this is TIFF data, zero otherwise. * * \since This function is available since SDL_image 3.0.0. @@ -1089,18 +1089,18 @@ extern DECLSPEC int SDLCALL IMG_isQOI(SDL_RWops *src); * \sa IMG_isXV * \sa IMG_isWEBP */ -extern DECLSPEC int SDLCALL IMG_isTIF(SDL_RWops *src); +extern DECLSPEC int SDLCALL IMG_isTIF(SDL_IOStream *src); /** - * Detect XCF image data on a readable/seekable SDL_RWops. + * Detect XCF image data on a readable/seekable SDL_IOStream. * * This function attempts to determine if a file is a given filetype, reading - * the least amount possible from the SDL_RWops (usually a few bytes). + * the least amount possible from the SDL_IOStream (usually a few bytes). * * There is no distinction made between "not the filetype in question" and * basic i/o errors. * - * This function will always attempt to seek the RWops back to where it + * This function will always attempt to seek `src` back to where it * started when this function was called, but it will not report any errors in * doing so, but assuming seeking works, this means you can immediately use * this with a different IMG_isTYPE function, or load the image without @@ -1109,7 +1109,7 @@ extern DECLSPEC int SDLCALL IMG_isTIF(SDL_RWops *src); * You do not need to call this function to load data; SDL_image can work to * determine file type in many cases in its standard load functions. * - * \param src a seekable/readable SDL_RWops to provide image data. + * \param src a seekable/readable SDL_IOStream to provide image data. * \returns non-zero if this is XCF data, zero otherwise. * * \since This function is available since SDL_image 3.0.0. @@ -1132,18 +1132,18 @@ extern DECLSPEC int SDLCALL IMG_isTIF(SDL_RWops *src); * \sa IMG_isXV * \sa IMG_isWEBP */ -extern DECLSPEC int SDLCALL IMG_isXCF(SDL_RWops *src); +extern DECLSPEC int SDLCALL IMG_isXCF(SDL_IOStream *src); /** - * Detect XPM image data on a readable/seekable SDL_RWops. + * Detect XPM image data on a readable/seekable SDL_IOStream. * * This function attempts to determine if a file is a given filetype, reading - * the least amount possible from the SDL_RWops (usually a few bytes). + * the least amount possible from the SDL_IOStream (usually a few bytes). * * There is no distinction made between "not the filetype in question" and * basic i/o errors. * - * This function will always attempt to seek the RWops back to where it + * This function will always attempt to seek `src` back to where it * started when this function was called, but it will not report any errors in * doing so, but assuming seeking works, this means you can immediately use * this with a different IMG_isTYPE function, or load the image without @@ -1152,7 +1152,7 @@ extern DECLSPEC int SDLCALL IMG_isXCF(SDL_RWops *src); * You do not need to call this function to load data; SDL_image can work to * determine file type in many cases in its standard load functions. * - * \param src a seekable/readable SDL_RWops to provide image data. + * \param src a seekable/readable SDL_IOStream to provide image data. * \returns non-zero if this is XPM data, zero otherwise. * * \since This function is available since SDL_image 3.0.0. @@ -1175,18 +1175,18 @@ extern DECLSPEC int SDLCALL IMG_isXCF(SDL_RWops *src); * \sa IMG_isXV * \sa IMG_isWEBP */ -extern DECLSPEC int SDLCALL IMG_isXPM(SDL_RWops *src); +extern DECLSPEC int SDLCALL IMG_isXPM(SDL_IOStream *src); /** - * Detect XV image data on a readable/seekable SDL_RWops. + * Detect XV image data on a readable/seekable SDL_IOStream. * * This function attempts to determine if a file is a given filetype, reading - * the least amount possible from the SDL_RWops (usually a few bytes). + * the least amount possible from the SDL_IOStream (usually a few bytes). * * There is no distinction made between "not the filetype in question" and * basic i/o errors. * - * This function will always attempt to seek the RWops back to where it + * This function will always attempt to seek `src` back to where it * started when this function was called, but it will not report any errors in * doing so, but assuming seeking works, this means you can immediately use * this with a different IMG_isTYPE function, or load the image without @@ -1195,7 +1195,7 @@ extern DECLSPEC int SDLCALL IMG_isXPM(SDL_RWops *src); * You do not need to call this function to load data; SDL_image can work to * determine file type in many cases in its standard load functions. * - * \param src a seekable/readable SDL_RWops to provide image data. + * \param src a seekable/readable SDL_IOStream to provide image data. * \returns non-zero if this is XV data, zero otherwise. * * \since This function is available since SDL_image 3.0.0. @@ -1218,18 +1218,18 @@ extern DECLSPEC int SDLCALL IMG_isXPM(SDL_RWops *src); * \sa IMG_isXPM * \sa IMG_isWEBP */ -extern DECLSPEC int SDLCALL IMG_isXV(SDL_RWops *src); +extern DECLSPEC int SDLCALL IMG_isXV(SDL_IOStream *src); /** - * Detect WEBP image data on a readable/seekable SDL_RWops. + * Detect WEBP image data on a readable/seekable SDL_IOStream. * * This function attempts to determine if a file is a given filetype, reading - * the least amount possible from the SDL_RWops (usually a few bytes). + * the least amount possible from the SDL_IOStream (usually a few bytes). * * There is no distinction made between "not the filetype in question" and * basic i/o errors. * - * This function will always attempt to seek the RWops back to where it + * This function will always attempt to seek `src` back to where it * started when this function was called, but it will not report any errors in * doing so, but assuming seeking works, this means you can immediately use * this with a different IMG_isTYPE function, or load the image without @@ -1238,7 +1238,7 @@ extern DECLSPEC int SDLCALL IMG_isXV(SDL_RWops *src); * You do not need to call this function to load data; SDL_image can work to * determine file type in many cases in its standard load functions. * - * \param src a seekable/readable SDL_RWops to provide image data. + * \param src a seekable/readable SDL_IOStream to provide image data. * \returns non-zero if this is WEBP data, zero otherwise. * * \since This function is available since SDL_image 3.0.0. @@ -1261,653 +1261,653 @@ extern DECLSPEC int SDLCALL IMG_isXV(SDL_RWops *src); * \sa IMG_isXPM * \sa IMG_isXV */ -extern DECLSPEC int SDLCALL IMG_isWEBP(SDL_RWops *src); +extern DECLSPEC int SDLCALL IMG_isWEBP(SDL_IOStream *src); /** * Load a AVIF image directly. * * If you know you definitely have a AVIF image, you can call this function, * which will skip SDL_image's file format detection routines. Generally it's - * better to use the abstract interfaces; also, there is only an SDL_RWops + * better to use the abstract interfaces; also, there is only an SDL_IOStream * interface available here. * - * \param src an SDL_RWops to load image data from. + * \param src an SDL_IOStream to load image data from. * \returns SDL surface, or NULL on error * * \since This function is available since SDL_image 3.0.0. * - * \sa IMG_LoadICO_RW - * \sa IMG_LoadCUR_RW - * \sa IMG_LoadBMP_RW - * \sa IMG_LoadGIF_RW - * \sa IMG_LoadJPG_RW - * \sa IMG_LoadJXL_RW - * \sa IMG_LoadLBM_RW - * \sa IMG_LoadPCX_RW - * \sa IMG_LoadPNG_RW - * \sa IMG_LoadPNM_RW - * \sa IMG_LoadSVG_RW - * \sa IMG_LoadQOI_RW - * \sa IMG_LoadTGA_RW - * \sa IMG_LoadTIF_RW - * \sa IMG_LoadXCF_RW - * \sa IMG_LoadXPM_RW - * \sa IMG_LoadXV_RW - * \sa IMG_LoadWEBP_RW - */ -extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadAVIF_RW(SDL_RWops *src); + * \sa IMG_LoadICO_IO + * \sa IMG_LoadCUR_IO + * \sa IMG_LoadBMP_IO + * \sa IMG_LoadGIF_IO + * \sa IMG_LoadJPG_IO + * \sa IMG_LoadJXL_IO + * \sa IMG_LoadLBM_IO + * \sa IMG_LoadPCX_IO + * \sa IMG_LoadPNG_IO + * \sa IMG_LoadPNM_IO + * \sa IMG_LoadSVG_IO + * \sa IMG_LoadQOI_IO + * \sa IMG_LoadTGA_IO + * \sa IMG_LoadTIF_IO + * \sa IMG_LoadXCF_IO + * \sa IMG_LoadXPM_IO + * \sa IMG_LoadXV_IO + * \sa IMG_LoadWEBP_IO + */ +extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadAVIF_IO(SDL_IOStream *src); /** * Load a ICO image directly. * * If you know you definitely have a ICO image, you can call this function, * which will skip SDL_image's file format detection routines. Generally it's - * better to use the abstract interfaces; also, there is only an SDL_RWops + * better to use the abstract interfaces; also, there is only an SDL_IOStream * interface available here. * - * \param src an SDL_RWops to load image data from. + * \param src an SDL_IOStream to load image data from. * \returns SDL surface, or NULL on error * * \since This function is available since SDL_image 3.0.0. * - * \sa IMG_LoadAVIF_RW - * \sa IMG_LoadCUR_RW - * \sa IMG_LoadBMP_RW - * \sa IMG_LoadGIF_RW - * \sa IMG_LoadJPG_RW - * \sa IMG_LoadJXL_RW - * \sa IMG_LoadLBM_RW - * \sa IMG_LoadPCX_RW - * \sa IMG_LoadPNG_RW - * \sa IMG_LoadPNM_RW - * \sa IMG_LoadSVG_RW - * \sa IMG_LoadQOI_RW - * \sa IMG_LoadTGA_RW - * \sa IMG_LoadTIF_RW - * \sa IMG_LoadXCF_RW - * \sa IMG_LoadXPM_RW - * \sa IMG_LoadXV_RW - * \sa IMG_LoadWEBP_RW - */ -extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadICO_RW(SDL_RWops *src); + * \sa IMG_LoadAVIF_IO + * \sa IMG_LoadCUR_IO + * \sa IMG_LoadBMP_IO + * \sa IMG_LoadGIF_IO + * \sa IMG_LoadJPG_IO + * \sa IMG_LoadJXL_IO + * \sa IMG_LoadLBM_IO + * \sa IMG_LoadPCX_IO + * \sa IMG_LoadPNG_IO + * \sa IMG_LoadPNM_IO + * \sa IMG_LoadSVG_IO + * \sa IMG_LoadQOI_IO + * \sa IMG_LoadTGA_IO + * \sa IMG_LoadTIF_IO + * \sa IMG_LoadXCF_IO + * \sa IMG_LoadXPM_IO + * \sa IMG_LoadXV_IO + * \sa IMG_LoadWEBP_IO + */ +extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadICO_IO(SDL_IOStream *src); /** * Load a CUR image directly. * * If you know you definitely have a CUR image, you can call this function, * which will skip SDL_image's file format detection routines. Generally it's - * better to use the abstract interfaces; also, there is only an SDL_RWops + * better to use the abstract interfaces; also, there is only an SDL_IOStream * interface available here. * - * \param src an SDL_RWops to load image data from. + * \param src an SDL_IOStream to load image data from. * \returns SDL surface, or NULL on error * * \since This function is available since SDL_image 3.0.0. * - * \sa IMG_LoadAVIF_RW - * \sa IMG_LoadICO_RW - * \sa IMG_LoadBMP_RW - * \sa IMG_LoadGIF_RW - * \sa IMG_LoadJPG_RW - * \sa IMG_LoadJXL_RW - * \sa IMG_LoadLBM_RW - * \sa IMG_LoadPCX_RW - * \sa IMG_LoadPNG_RW - * \sa IMG_LoadPNM_RW - * \sa IMG_LoadSVG_RW - * \sa IMG_LoadQOI_RW - * \sa IMG_LoadTGA_RW - * \sa IMG_LoadTIF_RW - * \sa IMG_LoadXCF_RW - * \sa IMG_LoadXPM_RW - * \sa IMG_LoadXV_RW - * \sa IMG_LoadWEBP_RW - */ -extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadCUR_RW(SDL_RWops *src); + * \sa IMG_LoadAVIF_IO + * \sa IMG_LoadICO_IO + * \sa IMG_LoadBMP_IO + * \sa IMG_LoadGIF_IO + * \sa IMG_LoadJPG_IO + * \sa IMG_LoadJXL_IO + * \sa IMG_LoadLBM_IO + * \sa IMG_LoadPCX_IO + * \sa IMG_LoadPNG_IO + * \sa IMG_LoadPNM_IO + * \sa IMG_LoadSVG_IO + * \sa IMG_LoadQOI_IO + * \sa IMG_LoadTGA_IO + * \sa IMG_LoadTIF_IO + * \sa IMG_LoadXCF_IO + * \sa IMG_LoadXPM_IO + * \sa IMG_LoadXV_IO + * \sa IMG_LoadWEBP_IO + */ +extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadCUR_IO(SDL_IOStream *src); /** * Load a BMP image directly. * * If you know you definitely have a BMP image, you can call this function, * which will skip SDL_image's file format detection routines. Generally it's - * better to use the abstract interfaces; also, there is only an SDL_RWops + * better to use the abstract interfaces; also, there is only an SDL_IOStream * interface available here. * - * \param src an SDL_RWops to load image data from. + * \param src an SDL_IOStream to load image data from. * \returns SDL surface, or NULL on error * * \since This function is available since SDL_image 3.0.0. * - * \sa IMG_LoadAVIF_RW - * \sa IMG_LoadICO_RW - * \sa IMG_LoadCUR_RW - * \sa IMG_LoadGIF_RW - * \sa IMG_LoadJPG_RW - * \sa IMG_LoadJXL_RW - * \sa IMG_LoadLBM_RW - * \sa IMG_LoadPCX_RW - * \sa IMG_LoadPNG_RW - * \sa IMG_LoadPNM_RW - * \sa IMG_LoadSVG_RW - * \sa IMG_LoadQOI_RW - * \sa IMG_LoadTGA_RW - * \sa IMG_LoadTIF_RW - * \sa IMG_LoadXCF_RW - * \sa IMG_LoadXPM_RW - * \sa IMG_LoadXV_RW - * \sa IMG_LoadWEBP_RW - */ -extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadBMP_RW(SDL_RWops *src); + * \sa IMG_LoadAVIF_IO + * \sa IMG_LoadICO_IO + * \sa IMG_LoadCUR_IO + * \sa IMG_LoadGIF_IO + * \sa IMG_LoadJPG_IO + * \sa IMG_LoadJXL_IO + * \sa IMG_LoadLBM_IO + * \sa IMG_LoadPCX_IO + * \sa IMG_LoadPNG_IO + * \sa IMG_LoadPNM_IO + * \sa IMG_LoadSVG_IO + * \sa IMG_LoadQOI_IO + * \sa IMG_LoadTGA_IO + * \sa IMG_LoadTIF_IO + * \sa IMG_LoadXCF_IO + * \sa IMG_LoadXPM_IO + * \sa IMG_LoadXV_IO + * \sa IMG_LoadWEBP_IO + */ +extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadBMP_IO(SDL_IOStream *src); /** * Load a GIF image directly. * * If you know you definitely have a GIF image, you can call this function, * which will skip SDL_image's file format detection routines. Generally it's - * better to use the abstract interfaces; also, there is only an SDL_RWops + * better to use the abstract interfaces; also, there is only an SDL_IOStream * interface available here. * - * \param src an SDL_RWops to load image data from. + * \param src an SDL_IOStream to load image data from. * \returns SDL surface, or NULL on error * * \since This function is available since SDL_image 3.0.0. * - * \sa IMG_LoadAVIF_RW - * \sa IMG_LoadICO_RW - * \sa IMG_LoadCUR_RW - * \sa IMG_LoadBMP_RW - * \sa IMG_LoadJPG_RW - * \sa IMG_LoadJXL_RW - * \sa IMG_LoadLBM_RW - * \sa IMG_LoadPCX_RW - * \sa IMG_LoadPNG_RW - * \sa IMG_LoadPNM_RW - * \sa IMG_LoadSVG_RW - * \sa IMG_LoadQOI_RW - * \sa IMG_LoadTGA_RW - * \sa IMG_LoadTIF_RW - * \sa IMG_LoadXCF_RW - * \sa IMG_LoadXPM_RW - * \sa IMG_LoadXV_RW - * \sa IMG_LoadWEBP_RW - */ -extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadGIF_RW(SDL_RWops *src); + * \sa IMG_LoadAVIF_IO + * \sa IMG_LoadICO_IO + * \sa IMG_LoadCUR_IO + * \sa IMG_LoadBMP_IO + * \sa IMG_LoadJPG_IO + * \sa IMG_LoadJXL_IO + * \sa IMG_LoadLBM_IO + * \sa IMG_LoadPCX_IO + * \sa IMG_LoadPNG_IO + * \sa IMG_LoadPNM_IO + * \sa IMG_LoadSVG_IO + * \sa IMG_LoadQOI_IO + * \sa IMG_LoadTGA_IO + * \sa IMG_LoadTIF_IO + * \sa IMG_LoadXCF_IO + * \sa IMG_LoadXPM_IO + * \sa IMG_LoadXV_IO + * \sa IMG_LoadWEBP_IO + */ +extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadGIF_IO(SDL_IOStream *src); /** * Load a JPG image directly. * * If you know you definitely have a JPG image, you can call this function, * which will skip SDL_image's file format detection routines. Generally it's - * better to use the abstract interfaces; also, there is only an SDL_RWops + * better to use the abstract interfaces; also, there is only an SDL_IOStream * interface available here. * - * \param src an SDL_RWops to load image data from. + * \param src an SDL_IOStream to load image data from. * \returns SDL surface, or NULL on error * * \since This function is available since SDL_image 3.0.0. * - * \sa IMG_LoadAVIF_RW - * \sa IMG_LoadICO_RW - * \sa IMG_LoadCUR_RW - * \sa IMG_LoadBMP_RW - * \sa IMG_LoadGIF_RW - * \sa IMG_LoadJXL_RW - * \sa IMG_LoadLBM_RW - * \sa IMG_LoadPCX_RW - * \sa IMG_LoadPNG_RW - * \sa IMG_LoadPNM_RW - * \sa IMG_LoadSVG_RW - * \sa IMG_LoadQOI_RW - * \sa IMG_LoadTGA_RW - * \sa IMG_LoadTIF_RW - * \sa IMG_LoadXCF_RW - * \sa IMG_LoadXPM_RW - * \sa IMG_LoadXV_RW - * \sa IMG_LoadWEBP_RW - */ -extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadJPG_RW(SDL_RWops *src); + * \sa IMG_LoadAVIF_IO + * \sa IMG_LoadICO_IO + * \sa IMG_LoadCUR_IO + * \sa IMG_LoadBMP_IO + * \sa IMG_LoadGIF_IO + * \sa IMG_LoadJXL_IO + * \sa IMG_LoadLBM_IO + * \sa IMG_LoadPCX_IO + * \sa IMG_LoadPNG_IO + * \sa IMG_LoadPNM_IO + * \sa IMG_LoadSVG_IO + * \sa IMG_LoadQOI_IO + * \sa IMG_LoadTGA_IO + * \sa IMG_LoadTIF_IO + * \sa IMG_LoadXCF_IO + * \sa IMG_LoadXPM_IO + * \sa IMG_LoadXV_IO + * \sa IMG_LoadWEBP_IO + */ +extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadJPG_IO(SDL_IOStream *src); /** * Load a JXL image directly. * * If you know you definitely have a JXL image, you can call this function, * which will skip SDL_image's file format detection routines. Generally it's - * better to use the abstract interfaces; also, there is only an SDL_RWops + * better to use the abstract interfaces; also, there is only an SDL_IOStream * interface available here. * - * \param src an SDL_RWops to load image data from. + * \param src an SDL_IOStream to load image data from. * \returns SDL surface, or NULL on error * * \since This function is available since SDL_image 3.0.0. * - * \sa IMG_LoadAVIF_RW - * \sa IMG_LoadICO_RW - * \sa IMG_LoadCUR_RW - * \sa IMG_LoadBMP_RW - * \sa IMG_LoadGIF_RW - * \sa IMG_LoadJPG_RW - * \sa IMG_LoadLBM_RW - * \sa IMG_LoadPCX_RW - * \sa IMG_LoadPNG_RW - * \sa IMG_LoadPNM_RW - * \sa IMG_LoadSVG_RW - * \sa IMG_LoadQOI_RW - * \sa IMG_LoadTGA_RW - * \sa IMG_LoadTIF_RW - * \sa IMG_LoadXCF_RW - * \sa IMG_LoadXPM_RW - * \sa IMG_LoadXV_RW - * \sa IMG_LoadWEBP_RW - */ -extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadJXL_RW(SDL_RWops *src); + * \sa IMG_LoadAVIF_IO + * \sa IMG_LoadICO_IO + * \sa IMG_LoadCUR_IO + * \sa IMG_LoadBMP_IO + * \sa IMG_LoadGIF_IO + * \sa IMG_LoadJPG_IO + * \sa IMG_LoadLBM_IO + * \sa IMG_LoadPCX_IO + * \sa IMG_LoadPNG_IO + * \sa IMG_LoadPNM_IO + * \sa IMG_LoadSVG_IO + * \sa IMG_LoadQOI_IO + * \sa IMG_LoadTGA_IO + * \sa IMG_LoadTIF_IO + * \sa IMG_LoadXCF_IO + * \sa IMG_LoadXPM_IO + * \sa IMG_LoadXV_IO + * \sa IMG_LoadWEBP_IO + */ +extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadJXL_IO(SDL_IOStream *src); /** * Load a LBM image directly. * * If you know you definitely have a LBM image, you can call this function, * which will skip SDL_image's file format detection routines. Generally it's - * better to use the abstract interfaces; also, there is only an SDL_RWops + * better to use the abstract interfaces; also, there is only an SDL_IOStream * interface available here. * - * \param src an SDL_RWops to load image data from. + * \param src an SDL_IOStream to load image data from. * \returns SDL surface, or NULL on error * * \since This function is available since SDL_image 3.0.0. * - * \sa IMG_LoadAVIF_RW - * \sa IMG_LoadICO_RW - * \sa IMG_LoadCUR_RW - * \sa IMG_LoadBMP_RW - * \sa IMG_LoadGIF_RW - * \sa IMG_LoadJPG_RW - * \sa IMG_LoadJXL_RW - * \sa IMG_LoadPCX_RW - * \sa IMG_LoadPNG_RW - * \sa IMG_LoadPNM_RW - * \sa IMG_LoadSVG_RW - * \sa IMG_LoadQOI_RW - * \sa IMG_LoadTGA_RW - * \sa IMG_LoadTIF_RW - * \sa IMG_LoadXCF_RW - * \sa IMG_LoadXPM_RW - * \sa IMG_LoadXV_RW - * \sa IMG_LoadWEBP_RW - */ -extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadLBM_RW(SDL_RWops *src); + * \sa IMG_LoadAVIF_IO + * \sa IMG_LoadICO_IO + * \sa IMG_LoadCUR_IO + * \sa IMG_LoadBMP_IO + * \sa IMG_LoadGIF_IO + * \sa IMG_LoadJPG_IO + * \sa IMG_LoadJXL_IO + * \sa IMG_LoadPCX_IO + * \sa IMG_LoadPNG_IO + * \sa IMG_LoadPNM_IO + * \sa IMG_LoadSVG_IO + * \sa IMG_LoadQOI_IO + * \sa IMG_LoadTGA_IO + * \sa IMG_LoadTIF_IO + * \sa IMG_LoadXCF_IO + * \sa IMG_LoadXPM_IO + * \sa IMG_LoadXV_IO + * \sa IMG_LoadWEBP_IO + */ +extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadLBM_IO(SDL_IOStream *src); /** * Load a PCX image directly. * * If you know you definitely have a PCX image, you can call this function, * which will skip SDL_image's file format detection routines. Generally it's - * better to use the abstract interfaces; also, there is only an SDL_RWops + * better to use the abstract interfaces; also, there is only an SDL_IOStream * interface available here. * - * \param src an SDL_RWops to load image data from. + * \param src an SDL_IOStream to load image data from. * \returns SDL surface, or NULL on error * * \since This function is available since SDL_image 3.0.0. * - * \sa IMG_LoadAVIF_RW - * \sa IMG_LoadICO_RW - * \sa IMG_LoadCUR_RW - * \sa IMG_LoadBMP_RW - * \sa IMG_LoadGIF_RW - * \sa IMG_LoadJPG_RW - * \sa IMG_LoadJXL_RW - * \sa IMG_LoadLBM_RW - * \sa IMG_LoadPNG_RW - * \sa IMG_LoadPNM_RW - * \sa IMG_LoadSVG_RW - * \sa IMG_LoadQOI_RW - * \sa IMG_LoadTGA_RW - * \sa IMG_LoadTIF_RW - * \sa IMG_LoadXCF_RW - * \sa IMG_LoadXPM_RW - * \sa IMG_LoadXV_RW - * \sa IMG_LoadWEBP_RW - */ -extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadPCX_RW(SDL_RWops *src); + * \sa IMG_LoadAVIF_IO + * \sa IMG_LoadICO_IO + * \sa IMG_LoadCUR_IO + * \sa IMG_LoadBMP_IO + * \sa IMG_LoadGIF_IO + * \sa IMG_LoadJPG_IO + * \sa IMG_LoadJXL_IO + * \sa IMG_LoadLBM_IO + * \sa IMG_LoadPNG_IO + * \sa IMG_LoadPNM_IO + * \sa IMG_LoadSVG_IO + * \sa IMG_LoadQOI_IO + * \sa IMG_LoadTGA_IO + * \sa IMG_LoadTIF_IO + * \sa IMG_LoadXCF_IO + * \sa IMG_LoadXPM_IO + * \sa IMG_LoadXV_IO + * \sa IMG_LoadWEBP_IO + */ +extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadPCX_IO(SDL_IOStream *src); /** * Load a PNG image directly. * * If you know you definitely have a PNG image, you can call this function, * which will skip SDL_image's file format detection routines. Generally it's - * better to use the abstract interfaces; also, there is only an SDL_RWops + * better to use the abstract interfaces; also, there is only an SDL_IOStream * interface available here. * - * \param src an SDL_RWops to load image data from. + * \param src an SDL_IOStream to load image data from. * \returns SDL surface, or NULL on error * * \since This function is available since SDL_image 3.0.0. * - * \sa IMG_LoadAVIF_RW - * \sa IMG_LoadICO_RW - * \sa IMG_LoadCUR_RW - * \sa IMG_LoadBMP_RW - * \sa IMG_LoadGIF_RW - * \sa IMG_LoadJPG_RW - * \sa IMG_LoadJXL_RW - * \sa IMG_LoadLBM_RW - * \sa IMG_LoadPCX_RW - * \sa IMG_LoadPNM_RW - * \sa IMG_LoadSVG_RW - * \sa IMG_LoadQOI_RW - * \sa IMG_LoadTGA_RW - * \sa IMG_LoadTIF_RW - * \sa IMG_LoadXCF_RW - * \sa IMG_LoadXPM_RW - * \sa IMG_LoadXV_RW - * \sa IMG_LoadWEBP_RW - */ -extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadPNG_RW(SDL_RWops *src); + * \sa IMG_LoadAVIF_IO + * \sa IMG_LoadICO_IO + * \sa IMG_LoadCUR_IO + * \sa IMG_LoadBMP_IO + * \sa IMG_LoadGIF_IO + * \sa IMG_LoadJPG_IO + * \sa IMG_LoadJXL_IO + * \sa IMG_LoadLBM_IO + * \sa IMG_LoadPCX_IO + * \sa IMG_LoadPNM_IO + * \sa IMG_LoadSVG_IO + * \sa IMG_LoadQOI_IO + * \sa IMG_LoadTGA_IO + * \sa IMG_LoadTIF_IO + * \sa IMG_LoadXCF_IO + * \sa IMG_LoadXPM_IO + * \sa IMG_LoadXV_IO + * \sa IMG_LoadWEBP_IO + */ +extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadPNG_IO(SDL_IOStream *src); /** * Load a PNM image directly. * * If you know you definitely have a PNM image, you can call this function, * which will skip SDL_image's file format detection routines. Generally it's - * better to use the abstract interfaces; also, there is only an SDL_RWops + * better to use the abstract interfaces; also, there is only an SDL_IOStream * interface available here. * - * \param src an SDL_RWops to load image data from. + * \param src an SDL_IOStream to load image data from. * \returns SDL surface, or NULL on error * * \since This function is available since SDL_image 3.0.0. * - * \sa IMG_LoadAVIF_RW - * \sa IMG_LoadICO_RW - * \sa IMG_LoadCUR_RW - * \sa IMG_LoadBMP_RW - * \sa IMG_LoadGIF_RW - * \sa IMG_LoadJPG_RW - * \sa IMG_LoadJXL_RW - * \sa IMG_LoadLBM_RW - * \sa IMG_LoadPCX_RW - * \sa IMG_LoadPNG_RW - * \sa IMG_LoadSVG_RW - * \sa IMG_LoadQOI_RW - * \sa IMG_LoadTGA_RW - * \sa IMG_LoadTIF_RW - * \sa IMG_LoadXCF_RW - * \sa IMG_LoadXPM_RW - * \sa IMG_LoadXV_RW - * \sa IMG_LoadWEBP_RW - */ -extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadPNM_RW(SDL_RWops *src); + * \sa IMG_LoadAVIF_IO + * \sa IMG_LoadICO_IO + * \sa IMG_LoadCUR_IO + * \sa IMG_LoadBMP_IO + * \sa IMG_LoadGIF_IO + * \sa IMG_LoadJPG_IO + * \sa IMG_LoadJXL_IO + * \sa IMG_LoadLBM_IO + * \sa IMG_LoadPCX_IO + * \sa IMG_LoadPNG_IO + * \sa IMG_LoadSVG_IO + * \sa IMG_LoadQOI_IO + * \sa IMG_LoadTGA_IO + * \sa IMG_LoadTIF_IO + * \sa IMG_LoadXCF_IO + * \sa IMG_LoadXPM_IO + * \sa IMG_LoadXV_IO + * \sa IMG_LoadWEBP_IO + */ +extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadPNM_IO(SDL_IOStream *src); /** * Load a SVG image directly. * * If you know you definitely have a SVG image, you can call this function, * which will skip SDL_image's file format detection routines. Generally it's - * better to use the abstract interfaces; also, there is only an SDL_RWops + * better to use the abstract interfaces; also, there is only an SDL_IOStream * interface available here. * - * \param src an SDL_RWops to load image data from. + * \param src an SDL_IOStream to load image data from. * \returns SDL surface, or NULL on error * * \since This function is available since SDL_image 3.0.0. * - * \sa IMG_LoadAVIF_RW - * \sa IMG_LoadICO_RW - * \sa IMG_LoadCUR_RW - * \sa IMG_LoadBMP_RW - * \sa IMG_LoadGIF_RW - * \sa IMG_LoadJPG_RW - * \sa IMG_LoadJXL_RW - * \sa IMG_LoadLBM_RW - * \sa IMG_LoadPCX_RW - * \sa IMG_LoadPNG_RW - * \sa IMG_LoadPNM_RW - * \sa IMG_LoadQOI_RW - * \sa IMG_LoadTGA_RW - * \sa IMG_LoadTIF_RW - * \sa IMG_LoadXCF_RW - * \sa IMG_LoadXPM_RW - * \sa IMG_LoadXV_RW - * \sa IMG_LoadWEBP_RW - */ -extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadSVG_RW(SDL_RWops *src); + * \sa IMG_LoadAVIF_IO + * \sa IMG_LoadICO_IO + * \sa IMG_LoadCUR_IO + * \sa IMG_LoadBMP_IO + * \sa IMG_LoadGIF_IO + * \sa IMG_LoadJPG_IO + * \sa IMG_LoadJXL_IO + * \sa IMG_LoadLBM_IO + * \sa IMG_LoadPCX_IO + * \sa IMG_LoadPNG_IO + * \sa IMG_LoadPNM_IO + * \sa IMG_LoadQOI_IO + * \sa IMG_LoadTGA_IO + * \sa IMG_LoadTIF_IO + * \sa IMG_LoadXCF_IO + * \sa IMG_LoadXPM_IO + * \sa IMG_LoadXV_IO + * \sa IMG_LoadWEBP_IO + */ +extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadSVG_IO(SDL_IOStream *src); /** * Load a QOI image directly. * * If you know you definitely have a QOI image, you can call this function, * which will skip SDL_image's file format detection routines. Generally it's - * better to use the abstract interfaces; also, there is only an SDL_RWops + * better to use the abstract interfaces; also, there is only an SDL_IOStream * interface available here. * - * \param src an SDL_RWops to load image data from. + * \param src an SDL_IOStream to load image data from. * \returns SDL surface, or NULL on error * * \since This function is available since SDL_image 3.0.0. * - * \sa IMG_LoadAVIF_RW - * \sa IMG_LoadICO_RW - * \sa IMG_LoadCUR_RW - * \sa IMG_LoadBMP_RW - * \sa IMG_LoadGIF_RW - * \sa IMG_LoadJPG_RW - * \sa IMG_LoadJXL_RW - * \sa IMG_LoadLBM_RW - * \sa IMG_LoadPCX_RW - * \sa IMG_LoadPNG_RW - * \sa IMG_LoadPNM_RW - * \sa IMG_LoadSVG_RW - * \sa IMG_LoadTGA_RW - * \sa IMG_LoadTIF_RW - * \sa IMG_LoadXCF_RW - * \sa IMG_LoadXPM_RW - * \sa IMG_LoadXV_RW - * \sa IMG_LoadWEBP_RW - */ -extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadQOI_RW(SDL_RWops *src); + * \sa IMG_LoadAVIF_IO + * \sa IMG_LoadICO_IO + * \sa IMG_LoadCUR_IO + * \sa IMG_LoadBMP_IO + * \sa IMG_LoadGIF_IO + * \sa IMG_LoadJPG_IO + * \sa IMG_LoadJXL_IO + * \sa IMG_LoadLBM_IO + * \sa IMG_LoadPCX_IO + * \sa IMG_LoadPNG_IO + * \sa IMG_LoadPNM_IO + * \sa IMG_LoadSVG_IO + * \sa IMG_LoadTGA_IO + * \sa IMG_LoadTIF_IO + * \sa IMG_LoadXCF_IO + * \sa IMG_LoadXPM_IO + * \sa IMG_LoadXV_IO + * \sa IMG_LoadWEBP_IO + */ +extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadQOI_IO(SDL_IOStream *src); /** * Load a TGA image directly. * * If you know you definitely have a TGA image, you can call this function, * which will skip SDL_image's file format detection routines. Generally it's - * better to use the abstract interfaces; also, there is only an SDL_RWops + * better to use the abstract interfaces; also, there is only an SDL_IOStream * interface available here. * - * \param src an SDL_RWops to load image data from. + * \param src an SDL_IOStream to load image data from. * \returns SDL surface, or NULL on error * * \since This function is available since SDL_image 3.0.0. * - * \sa IMG_LoadAVIF_RW - * \sa IMG_LoadICO_RW - * \sa IMG_LoadCUR_RW - * \sa IMG_LoadBMP_RW - * \sa IMG_LoadGIF_RW - * \sa IMG_LoadJPG_RW - * \sa IMG_LoadJXL_RW - * \sa IMG_LoadLBM_RW - * \sa IMG_LoadPCX_RW - * \sa IMG_LoadPNG_RW - * \sa IMG_LoadPNM_RW - * \sa IMG_LoadSVG_RW - * \sa IMG_LoadQOI_RW - * \sa IMG_LoadTIF_RW - * \sa IMG_LoadXCF_RW - * \sa IMG_LoadXPM_RW - * \sa IMG_LoadXV_RW - * \sa IMG_LoadWEBP_RW - */ -extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadTGA_RW(SDL_RWops *src); + * \sa IMG_LoadAVIF_IO + * \sa IMG_LoadICO_IO + * \sa IMG_LoadCUR_IO + * \sa IMG_LoadBMP_IO + * \sa IMG_LoadGIF_IO + * \sa IMG_LoadJPG_IO + * \sa IMG_LoadJXL_IO + * \sa IMG_LoadLBM_IO + * \sa IMG_LoadPCX_IO + * \sa IMG_LoadPNG_IO + * \sa IMG_LoadPNM_IO + * \sa IMG_LoadSVG_IO + * \sa IMG_LoadQOI_IO + * \sa IMG_LoadTIF_IO + * \sa IMG_LoadXCF_IO + * \sa IMG_LoadXPM_IO + * \sa IMG_LoadXV_IO + * \sa IMG_LoadWEBP_IO + */ +extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadTGA_IO(SDL_IOStream *src); /** * Load a TIFF image directly. * * If you know you definitely have a TIFF image, you can call this function, * which will skip SDL_image's file format detection routines. Generally it's - * better to use the abstract interfaces; also, there is only an SDL_RWops + * better to use the abstract interfaces; also, there is only an SDL_IOStream * interface available here. * - * \param src an SDL_RWops to load image data from. + * \param src an SDL_IOStream to load image data from. * \returns SDL surface, or NULL on error * * \since This function is available since SDL_image 3.0.0. * - * \sa IMG_LoadAVIF_RW - * \sa IMG_LoadICO_RW - * \sa IMG_LoadCUR_RW - * \sa IMG_LoadBMP_RW - * \sa IMG_LoadGIF_RW - * \sa IMG_LoadJPG_RW - * \sa IMG_LoadJXL_RW - * \sa IMG_LoadLBM_RW - * \sa IMG_LoadPCX_RW - * \sa IMG_LoadPNG_RW - * \sa IMG_LoadPNM_RW - * \sa IMG_LoadSVG_RW - * \sa IMG_LoadQOI_RW - * \sa IMG_LoadTGA_RW - * \sa IMG_LoadXCF_RW - * \sa IMG_LoadXPM_RW - * \sa IMG_LoadXV_RW - * \sa IMG_LoadWEBP_RW - */ -extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadTIF_RW(SDL_RWops *src); + * \sa IMG_LoadAVIF_IO + * \sa IMG_LoadICO_IO + * \sa IMG_LoadCUR_IO + * \sa IMG_LoadBMP_IO + * \sa IMG_LoadGIF_IO + * \sa IMG_LoadJPG_IO + * \sa IMG_LoadJXL_IO + * \sa IMG_LoadLBM_IO + * \sa IMG_LoadPCX_IO + * \sa IMG_LoadPNG_IO + * \sa IMG_LoadPNM_IO + * \sa IMG_LoadSVG_IO + * \sa IMG_LoadQOI_IO + * \sa IMG_LoadTGA_IO + * \sa IMG_LoadXCF_IO + * \sa IMG_LoadXPM_IO + * \sa IMG_LoadXV_IO + * \sa IMG_LoadWEBP_IO + */ +extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadTIF_IO(SDL_IOStream *src); /** * Load a XCF image directly. * * If you know you definitely have a XCF image, you can call this function, * which will skip SDL_image's file format detection routines. Generally it's - * better to use the abstract interfaces; also, there is only an SDL_RWops + * better to use the abstract interfaces; also, there is only an SDL_IOStream * interface available here. * - * \param src an SDL_RWops to load image data from. + * \param src an SDL_IOStream to load image data from. * \returns SDL surface, or NULL on error * * \since This function is available since SDL_image 3.0.0. * - * \sa IMG_LoadAVIF_RW - * \sa IMG_LoadICO_RW - * \sa IMG_LoadCUR_RW - * \sa IMG_LoadBMP_RW - * \sa IMG_LoadGIF_RW - * \sa IMG_LoadJPG_RW - * \sa IMG_LoadJXL_RW - * \sa IMG_LoadLBM_RW - * \sa IMG_LoadPCX_RW - * \sa IMG_LoadPNG_RW - * \sa IMG_LoadPNM_RW - * \sa IMG_LoadSVG_RW - * \sa IMG_LoadQOI_RW - * \sa IMG_LoadTGA_RW - * \sa IMG_LoadTIF_RW - * \sa IMG_LoadXPM_RW - * \sa IMG_LoadXV_RW - * \sa IMG_LoadWEBP_RW - */ -extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadXCF_RW(SDL_RWops *src); + * \sa IMG_LoadAVIF_IO + * \sa IMG_LoadICO_IO + * \sa IMG_LoadCUR_IO + * \sa IMG_LoadBMP_IO + * \sa IMG_LoadGIF_IO + * \sa IMG_LoadJPG_IO + * \sa IMG_LoadJXL_IO + * \sa IMG_LoadLBM_IO + * \sa IMG_LoadPCX_IO + * \sa IMG_LoadPNG_IO + * \sa IMG_LoadPNM_IO + * \sa IMG_LoadSVG_IO + * \sa IMG_LoadQOI_IO + * \sa IMG_LoadTGA_IO + * \sa IMG_LoadTIF_IO + * \sa IMG_LoadXPM_IO + * \sa IMG_LoadXV_IO + * \sa IMG_LoadWEBP_IO + */ +extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadXCF_IO(SDL_IOStream *src); /** * Load a XPM image directly. * * If you know you definitely have a XPM image, you can call this function, * which will skip SDL_image's file format detection routines. Generally it's - * better to use the abstract interfaces; also, there is only an SDL_RWops + * better to use the abstract interfaces; also, there is only an SDL_IOStream * interface available here. * - * \param src an SDL_RWops to load image data from. + * \param src an SDL_IOStream to load image data from. * \returns SDL surface, or NULL on error * * \since This function is available since SDL_image 3.0.0. * - * \sa IMG_LoadAVIF_RW - * \sa IMG_LoadICO_RW - * \sa IMG_LoadCUR_RW - * \sa IMG_LoadBMP_RW - * \sa IMG_LoadGIF_RW - * \sa IMG_LoadJPG_RW - * \sa IMG_LoadJXL_RW - * \sa IMG_LoadLBM_RW - * \sa IMG_LoadPCX_RW - * \sa IMG_LoadPNG_RW - * \sa IMG_LoadPNM_RW - * \sa IMG_LoadSVG_RW - * \sa IMG_LoadQOI_RW - * \sa IMG_LoadTGA_RW - * \sa IMG_LoadTIF_RW - * \sa IMG_LoadXCF_RW - * \sa IMG_LoadXV_RW - * \sa IMG_LoadWEBP_RW - */ -extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadXPM_RW(SDL_RWops *src); + * \sa IMG_LoadAVIF_IO + * \sa IMG_LoadICO_IO + * \sa IMG_LoadCUR_IO + * \sa IMG_LoadBMP_IO + * \sa IMG_LoadGIF_IO + * \sa IMG_LoadJPG_IO + * \sa IMG_LoadJXL_IO + * \sa IMG_LoadLBM_IO + * \sa IMG_LoadPCX_IO + * \sa IMG_LoadPNG_IO + * \sa IMG_LoadPNM_IO + * \sa IMG_LoadSVG_IO + * \sa IMG_LoadQOI_IO + * \sa IMG_LoadTGA_IO + * \sa IMG_LoadTIF_IO + * \sa IMG_LoadXCF_IO + * \sa IMG_LoadXV_IO + * \sa IMG_LoadWEBP_IO + */ +extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadXPM_IO(SDL_IOStream *src); /** * Load a XV image directly. * * If you know you definitely have a XV image, you can call this function, * which will skip SDL_image's file format detection routines. Generally it's - * better to use the abstract interfaces; also, there is only an SDL_RWops + * better to use the abstract interfaces; also, there is only an SDL_IOStream * interface available here. * - * \param src an SDL_RWops to load image data from. + * \param src an SDL_IOStream to load image data from. * \returns SDL surface, or NULL on error * * \since This function is available since SDL_image 3.0.0. * - * \sa IMG_LoadAVIF_RW - * \sa IMG_LoadICO_RW - * \sa IMG_LoadCUR_RW - * \sa IMG_LoadBMP_RW - * \sa IMG_LoadGIF_RW - * \sa IMG_LoadJPG_RW - * \sa IMG_LoadJXL_RW - * \sa IMG_LoadLBM_RW - * \sa IMG_LoadPCX_RW - * \sa IMG_LoadPNG_RW - * \sa IMG_LoadPNM_RW - * \sa IMG_LoadSVG_RW - * \sa IMG_LoadQOI_RW - * \sa IMG_LoadTGA_RW - * \sa IMG_LoadTIF_RW - * \sa IMG_LoadXCF_RW - * \sa IMG_LoadXPM_RW - * \sa IMG_LoadWEBP_RW - */ -extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadXV_RW(SDL_RWops *src); + * \sa IMG_LoadAVIF_IO + * \sa IMG_LoadICO_IO + * \sa IMG_LoadCUR_IO + * \sa IMG_LoadBMP_IO + * \sa IMG_LoadGIF_IO + * \sa IMG_LoadJPG_IO + * \sa IMG_LoadJXL_IO + * \sa IMG_LoadLBM_IO + * \sa IMG_LoadPCX_IO + * \sa IMG_LoadPNG_IO + * \sa IMG_LoadPNM_IO + * \sa IMG_LoadSVG_IO + * \sa IMG_LoadQOI_IO + * \sa IMG_LoadTGA_IO + * \sa IMG_LoadTIF_IO + * \sa IMG_LoadXCF_IO + * \sa IMG_LoadXPM_IO + * \sa IMG_LoadWEBP_IO + */ +extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadXV_IO(SDL_IOStream *src); /** * Load a WEBP image directly. * * If you know you definitely have a WEBP image, you can call this function, * which will skip SDL_image's file format detection routines. Generally it's - * better to use the abstract interfaces; also, there is only an SDL_RWops + * better to use the abstract interfaces; also, there is only an SDL_IOStream * interface available here. * - * \param src an SDL_RWops to load image data from. + * \param src an SDL_IOStream to load image data from. * \returns SDL surface, or NULL on error * * \since This function is available since SDL_image 3.0.0. * - * \sa IMG_LoadAVIF_RW - * \sa IMG_LoadICO_RW - * \sa IMG_LoadCUR_RW - * \sa IMG_LoadBMP_RW - * \sa IMG_LoadGIF_RW - * \sa IMG_LoadJPG_RW - * \sa IMG_LoadJXL_RW - * \sa IMG_LoadLBM_RW - * \sa IMG_LoadPCX_RW - * \sa IMG_LoadPNG_RW - * \sa IMG_LoadPNM_RW - * \sa IMG_LoadSVG_RW - * \sa IMG_LoadQOI_RW - * \sa IMG_LoadTGA_RW - * \sa IMG_LoadTIF_RW - * \sa IMG_LoadXCF_RW - * \sa IMG_LoadXPM_RW - * \sa IMG_LoadXV_RW - */ -extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadWEBP_RW(SDL_RWops *src); + * \sa IMG_LoadAVIF_IO + * \sa IMG_LoadICO_IO + * \sa IMG_LoadCUR_IO + * \sa IMG_LoadBMP_IO + * \sa IMG_LoadGIF_IO + * \sa IMG_LoadJPG_IO + * \sa IMG_LoadJXL_IO + * \sa IMG_LoadLBM_IO + * \sa IMG_LoadPCX_IO + * \sa IMG_LoadPNG_IO + * \sa IMG_LoadPNM_IO + * \sa IMG_LoadSVG_IO + * \sa IMG_LoadQOI_IO + * \sa IMG_LoadTGA_IO + * \sa IMG_LoadTIF_IO + * \sa IMG_LoadXCF_IO + * \sa IMG_LoadXPM_IO + * \sa IMG_LoadXV_IO + */ +extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadWEBP_IO(SDL_IOStream *src); /** * Load an SVG image, scaled to a specific size. @@ -1921,14 +1921,14 @@ extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadWEBP_RW(SDL_RWops *src); * When done with the returned surface, the app should dispose of it with a * call to SDL_DestroySurface(). * - * \param src an SDL_RWops to load SVG data from. + * \param src an SDL_IOStream to load SVG data from. * \param width desired width of the generated surface, in pixels. * \param height desired height of the generated surface, in pixels. * \returns a new SDL surface, or NULL on error. * * \since This function is available since SDL_image 3.0.0. */ -extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadSizedSVG_RW(SDL_RWops *src, int width, int height); +extern DECLSPEC SDL_Surface * SDLCALL IMG_LoadSizedSVG_IO(SDL_IOStream *src, int width, int height); /** * Load an XPM image from a memory array. @@ -1981,21 +1981,21 @@ extern DECLSPEC SDL_Surface * SDLCALL IMG_ReadXPMFromArrayToRGB888(char **xpm); * * \since This function is available since SDL_image 3.0.0. * - * \sa IMG_SaveAVIF_RW + * \sa IMG_SaveAVIF_IO */ extern DECLSPEC int SDLCALL IMG_SaveAVIF(SDL_Surface *surface, const char *file, int quality); /** - * Save an SDL_Surface into AVIF image data, via an SDL_RWops. + * Save an SDL_Surface into AVIF image data, via an SDL_IOStream. * * If you just want to save to a filename, you can use IMG_SaveAVIF() instead. * - * If `freedst` is SDL_TRUE, the RWops will be closed before returning, + * If `closeio` is SDL_TRUE, `dst` will be closed before returning, * whether this function succeeds or not. * * \param surface the SDL surface to save - * \param dst the SDL_RWops to save the image data to. - * \param freedst SDL_TRUE to close/free the SDL_RWops before returning, + * \param dst the SDL_IOStream to save the image data to. + * \param closeio SDL_TRUE to close/free the SDL_IOStream before returning, * SDL_FALSE to leave it open. * \param quality the desired quality, ranging between 0 (lowest) and 100 * (highest) @@ -2005,7 +2005,7 @@ extern DECLSPEC int SDLCALL IMG_SaveAVIF(SDL_Surface *surface, const char *file, * * \sa IMG_SaveAVIF */ -extern DECLSPEC int SDLCALL IMG_SaveAVIF_RW(SDL_Surface *surface, SDL_RWops *dst, int freedst, int quality); +extern DECLSPEC int SDLCALL IMG_SaveAVIF_IO(SDL_Surface *surface, SDL_IOStream *dst, int closeio, int quality); /** * Save an SDL_Surface into a PNG image file. @@ -2018,21 +2018,21 @@ extern DECLSPEC int SDLCALL IMG_SaveAVIF_RW(SDL_Surface *surface, SDL_RWops *dst * * \since This function is available since SDL_image 3.0.0. * - * \sa IMG_SavePNG_RW + * \sa IMG_SavePNG_IO */ extern DECLSPEC int SDLCALL IMG_SavePNG(SDL_Surface *surface, const char *file); /** - * Save an SDL_Surface into PNG image data, via an SDL_RWops. + * Save an SDL_Surface into PNG image data, via an SDL_IOStream. * * If you just want to save to a filename, you can use IMG_SavePNG() instead. * - * If `freedst` is SDL_TRUE, the RWops will be closed before returning, + * If `closeio` is SDL_TRUE, `dst` will be closed before returning, * whether this function succeeds or not. * * \param surface the SDL surface to save - * \param dst the SDL_RWops to save the image data to. - * \param freedst SDL_TRUE to close/free the SDL_RWops before returning, + * \param dst the SDL_IOStream to save the image data to. + * \param closeio SDL_TRUE to close/free the SDL_IOStream before returning, * SDL_FALSE to leave it open. * \returns 0 if successful, -1 on error. * @@ -2040,7 +2040,7 @@ extern DECLSPEC int SDLCALL IMG_SavePNG(SDL_Surface *surface, const char *file); * * \sa IMG_SavePNG */ -extern DECLSPEC int SDLCALL IMG_SavePNG_RW(SDL_Surface *surface, SDL_RWops *dst, int freedst); +extern DECLSPEC int SDLCALL IMG_SavePNG_IO(SDL_Surface *surface, SDL_IOStream *dst, int closeio); /** * Save an SDL_Surface into a JPEG image file. @@ -2055,18 +2055,21 @@ extern DECLSPEC int SDLCALL IMG_SavePNG_RW(SDL_Surface *surface, SDL_RWops *dst, * * \since This function is available since SDL_image 3.0.0. * - * \sa IMG_SaveJPG_RW + * \sa IMG_SaveJPG_IO */ extern DECLSPEC int SDLCALL IMG_SaveJPG(SDL_Surface *surface, const char *file, int quality); /** - * Save an SDL_Surface into JPEG image data, via an SDL_RWops. + * Save an SDL_Surface into JPEG image data, via an SDL_IOStream. * * If you just want to save to a filename, you can use IMG_SaveJPG() instead. * + * If `closeio` is SDL_TRUE, `dst` will be closed before returning, + * whether this function succeeds or not. + * * \param surface the SDL surface to save - * \param dst the SDL_RWops to save the image data to. - * \param freedst SDL_TRUE to close/free the SDL_RWops before returning, + * \param dst the SDL_IOStream to save the image data to. + * \param closeio SDL_TRUE to close/free the SDL_IOStream before returning, * SDL_FALSE to leave it open. * \param quality [0; 33] is Lowest quality, [34; 66] is Middle quality, [67; * 100] is Highest quality @@ -2076,7 +2079,7 @@ extern DECLSPEC int SDLCALL IMG_SaveJPG(SDL_Surface *surface, const char *file, * * \sa IMG_SaveJPG */ -extern DECLSPEC int SDLCALL IMG_SaveJPG_RW(SDL_Surface *surface, SDL_RWops *dst, int freedst, int quality); +extern DECLSPEC int SDLCALL IMG_SaveJPG_IO(SDL_Surface *surface, SDL_IOStream *dst, int closeio, int quality); /** * Animated image support @@ -2106,17 +2109,17 @@ typedef struct extern DECLSPEC IMG_Animation * SDLCALL IMG_LoadAnimation(const char *file); /** - * Load an animation from an SDL_RWops. + * Load an animation from an SDL_IOStream. * - * If `freesrc` is SDL_TRUE, the RWops will be closed before returning, + * If `closeio` is SDL_TRUE, `src` will be closed before returning, * whether this function succeeds or not. SDL_image reads everything it needs - * from the RWops during this call in any case. + * from `src` during this call in any case. * * When done with the returned animation, the app should dispose of it with a * call to IMG_FreeAnimation(). * - * \param src an SDL_RWops that data will be read from. - * \param freesrc SDL_TRUE to close/free the SDL_RWops before returning, + * \param src an SDL_IOStream that data will be read from. + * \param closeio SDL_TRUE to close/free the SDL_IOStream before returning, * SDL_FALSE to leave it open. * \returns a new IMG_Animation, or NULL on error. * @@ -2124,7 +2127,7 @@ extern DECLSPEC IMG_Animation * SDLCALL IMG_LoadAnimation(const char *file); * * \sa IMG_FreeAnimation */ -extern DECLSPEC IMG_Animation * SDLCALL IMG_LoadAnimation_RW(SDL_RWops *src, SDL_bool freesrc); +extern DECLSPEC IMG_Animation * SDLCALL IMG_LoadAnimation_IO(SDL_IOStream *src, SDL_bool closeio); /** * Load an animation from an SDL datasource @@ -2135,15 +2138,15 @@ extern DECLSPEC IMG_Animation * SDLCALL IMG_LoadAnimation_RW(SDL_RWops *src, SDL * that it cannot autodetect. If `type` is NULL, SDL_image will rely solely on * its ability to guess the format. * - * If `freesrc` is SDL_TRUE, the RWops will be closed before returning, + * If `closeio` is SDL_TRUE, `src` will be closed before returning, * whether this function succeeds or not. SDL_image reads everything it needs - * from the RWops during this call in any case. + * from `src` during this call in any case. * * When done with the returned animation, the app should dispose of it with a * call to IMG_FreeAnimation(). * - * \param src an SDL_RWops that data will be read from. - * \param freesrc SDL_TRUE to close/free the SDL_RWops before returning, + * \param src an SDL_IOStream that data will be read from. + * \param closeio SDL_TRUE to close/free the SDL_IOStream before returning, * SDL_FALSE to leave it open. * \param type a filename extension that represent this data ("GIF", etc). * \returns a new IMG_Animation, or NULL on error. @@ -2151,10 +2154,10 @@ extern DECLSPEC IMG_Animation * SDLCALL IMG_LoadAnimation_RW(SDL_RWops *src, SDL * \since This function is available since SDL_image 3.0.0. * * \sa IMG_LoadAnimation - * \sa IMG_LoadAnimation_RW + * \sa IMG_LoadAnimation_IO * \sa IMG_FreeAnimation */ -extern DECLSPEC IMG_Animation * SDLCALL IMG_LoadAnimationTyped_RW(SDL_RWops *src, SDL_bool freesrc, const char *type); +extern DECLSPEC IMG_Animation * SDLCALL IMG_LoadAnimationTyped_IO(SDL_IOStream *src, SDL_bool closeio, const char *type); /** * Dispose of an IMG_Animation and free its resources. @@ -2166,8 +2169,8 @@ extern DECLSPEC IMG_Animation * SDLCALL IMG_LoadAnimationTyped_RW(SDL_RWops *src * \since This function is available since SDL_image 3.0.0. * * \sa IMG_LoadAnimation - * \sa IMG_LoadAnimation_RW - * \sa IMG_LoadAnimationTyped_RW + * \sa IMG_LoadAnimation_IO + * \sa IMG_LoadAnimationTyped_IO */ extern DECLSPEC void SDLCALL IMG_FreeAnimation(IMG_Animation *anim); @@ -2176,40 +2179,40 @@ extern DECLSPEC void SDLCALL IMG_FreeAnimation(IMG_Animation *anim); * * If you know you definitely have a GIF image, you can call this function, * which will skip SDL_image's file format detection routines. Generally it's - * better to use the abstract interfaces; also, there is only an SDL_RWops + * better to use the abstract interfaces; also, there is only an SDL_IOStream * interface available here. * - * \param src an SDL_RWops that data will be read from. + * \param src an SDL_IOStream that data will be read from. * \returns a new IMG_Animation, or NULL on error. * * \since This function is available since SDL_image 3.0.0. * * \sa IMG_LoadAnimation - * \sa IMG_LoadAnimation_RW - * \sa IMG_LoadAnimationTyped_RW + * \sa IMG_LoadAnimation_IO + * \sa IMG_LoadAnimationTyped_IO * \sa IMG_FreeAnimation */ -extern DECLSPEC IMG_Animation * SDLCALL IMG_LoadGIFAnimation_RW(SDL_RWops *src); +extern DECLSPEC IMG_Animation * SDLCALL IMG_LoadGIFAnimation_IO(SDL_IOStream *src); /** * Load a WEBP animation directly. * * If you know you definitely have a WEBP image, you can call this function, * which will skip SDL_image's file format detection routines. Generally it's - * better to use the abstract interfaces; also, there is only an SDL_RWops + * better to use the abstract interfaces; also, there is only an SDL_IOStream * interface available here. * - * \param src an SDL_RWops that data will be read from. + * \param src an SDL_IOStream that data will be read from. * \returns a new IMG_Animation, or NULL on error. * * \since This function is available since SDL_image 3.0.0. * * \sa IMG_LoadAnimation - * \sa IMG_LoadAnimation_RW - * \sa IMG_LoadAnimationTyped_RW + * \sa IMG_LoadAnimation_IO + * \sa IMG_LoadAnimationTyped_IO * \sa IMG_FreeAnimation */ -extern DECLSPEC IMG_Animation * SDLCALL IMG_LoadWEBPAnimation_RW(SDL_RWops *src); +extern DECLSPEC IMG_Animation * SDLCALL IMG_LoadWEBPAnimation_IO(SDL_IOStream *src); /** * Report SDL_image errors diff --git a/src/IMG.c b/src/IMG.c index 90026bb1..60d90c1e 100644 --- a/src/IMG.c +++ b/src/IMG.c @@ -54,40 +54,40 @@ SDL_COMPILE_TIME_ASSERT(SDL_IMAGE_PATCHLEVEL_max, SDL_IMAGE_PATCHLEVEL <= 99); /* Table of image detection and loading functions */ static struct { const char *type; - int (SDLCALL *is)(SDL_RWops *src); - SDL_Surface *(SDLCALL *load)(SDL_RWops *src); + int (SDLCALL *is)(SDL_IOStream *src); + SDL_Surface *(SDLCALL *load)(SDL_IOStream *src); } supported[] = { /* keep magicless formats first */ - { "TGA", NULL, IMG_LoadTGA_RW }, - { "AVIF",IMG_isAVIF,IMG_LoadAVIF_RW }, - { "CUR", IMG_isCUR, IMG_LoadCUR_RW }, - { "ICO", IMG_isICO, IMG_LoadICO_RW }, - { "BMP", IMG_isBMP, IMG_LoadBMP_RW }, - { "GIF", IMG_isGIF, IMG_LoadGIF_RW }, - { "JPG", IMG_isJPG, IMG_LoadJPG_RW }, - { "JXL", IMG_isJXL, IMG_LoadJXL_RW }, - { "LBM", IMG_isLBM, IMG_LoadLBM_RW }, - { "PCX", IMG_isPCX, IMG_LoadPCX_RW }, - { "PNG", IMG_isPNG, IMG_LoadPNG_RW }, - { "PNM", IMG_isPNM, IMG_LoadPNM_RW }, /* P[BGP]M share code */ - { "SVG", IMG_isSVG, IMG_LoadSVG_RW }, - { "TIF", IMG_isTIF, IMG_LoadTIF_RW }, - { "XCF", IMG_isXCF, IMG_LoadXCF_RW }, - { "XPM", IMG_isXPM, IMG_LoadXPM_RW }, - { "XV", IMG_isXV, IMG_LoadXV_RW }, - { "WEBP", IMG_isWEBP, IMG_LoadWEBP_RW }, - { "QOI", IMG_isQOI, IMG_LoadQOI_RW }, + { "TGA", NULL, IMG_LoadTGA_IO }, + { "AVIF",IMG_isAVIF,IMG_LoadAVIF_IO }, + { "CUR", IMG_isCUR, IMG_LoadCUR_IO }, + { "ICO", IMG_isICO, IMG_LoadICO_IO }, + { "BMP", IMG_isBMP, IMG_LoadBMP_IO }, + { "GIF", IMG_isGIF, IMG_LoadGIF_IO }, + { "JPG", IMG_isJPG, IMG_LoadJPG_IO }, + { "JXL", IMG_isJXL, IMG_LoadJXL_IO }, + { "LBM", IMG_isLBM, IMG_LoadLBM_IO }, + { "PCX", IMG_isPCX, IMG_LoadPCX_IO }, + { "PNG", IMG_isPNG, IMG_LoadPNG_IO }, + { "PNM", IMG_isPNM, IMG_LoadPNM_IO }, /* P[BGP]M share code */ + { "SVG", IMG_isSVG, IMG_LoadSVG_IO }, + { "TIF", IMG_isTIF, IMG_LoadTIF_IO }, + { "XCF", IMG_isXCF, IMG_LoadXCF_IO }, + { "XPM", IMG_isXPM, IMG_LoadXPM_IO }, + { "XV", IMG_isXV, IMG_LoadXV_IO }, + { "WEBP", IMG_isWEBP, IMG_LoadWEBP_IO }, + { "QOI", IMG_isQOI, IMG_LoadQOI_IO }, }; /* Table of animation detection and loading functions */ static struct { const char *type; - int (SDLCALL *is)(SDL_RWops *src); - IMG_Animation *(SDLCALL *load)(SDL_RWops *src); + int (SDLCALL *is)(SDL_IOStream *src); + IMG_Animation *(SDLCALL *load)(SDL_IOStream *src); } supported_anims[] = { /* keep magicless formats first */ - { "GIF", IMG_isGIF, IMG_LoadGIFAnimation_RW }, - { "WEBP", IMG_isWEBP, IMG_LoadWEBPAnimation_RW }, + { "GIF", IMG_isGIF, IMG_LoadGIFAnimation_IO }, + { "WEBP", IMG_isWEBP, IMG_LoadWEBPAnimation_IO }, }; const SDL_Version *IMG_Linked_Version(void) @@ -181,23 +181,23 @@ SDL_Surface *IMG_Load(const char *file) } #endif - SDL_RWops *src = SDL_RWFromFile(file, "rb"); + SDL_IOStream *src = SDL_IOFromFile(file, "rb"); const char *ext = SDL_strrchr(file, '.'); if (ext) { ext++; } if (!src) { - /* The error message has been set in SDL_RWFromFile */ + /* The error message has been set in SDL_IOFromFile */ return NULL; } - return IMG_LoadTyped_RW(src, SDL_TRUE, ext); + return IMG_LoadTyped_IO(src, SDL_TRUE, ext); } #endif /* Load an image from an SDL datasource (for compatibility) */ -SDL_Surface *IMG_Load_RW(SDL_RWops *src, SDL_bool freesrc) +SDL_Surface *IMG_Load_IO(SDL_IOStream *src, SDL_bool closeio) { - return IMG_LoadTyped_RW(src, freesrc, NULL); + return IMG_LoadTyped_IO(src, closeio, NULL); } /* Portable case-insensitive string compare function */ @@ -214,7 +214,7 @@ static int IMG_string_equals(const char *str1, const char *str2) } /* Load an image from an SDL datasource, optionally specifying the type */ -SDL_Surface *IMG_LoadTyped_RW(SDL_RWops *src, SDL_bool freesrc, const char *type) +SDL_Surface *IMG_LoadTyped_IO(SDL_IOStream *src, SDL_bool closeio, const char *type) { size_t i; SDL_Surface *image; @@ -226,33 +226,31 @@ SDL_Surface *IMG_LoadTyped_RW(SDL_RWops *src, SDL_bool freesrc, const char *type } /* See whether or not this data source can handle seeking */ - if ( SDL_RWseek(src, 0, SDL_RW_SEEK_CUR) < 0 ) { + if (SDL_SeekIO(src, 0, SDL_IO_SEEK_CUR) < 0 ) { IMG_SetError("Can't seek in this data source"); - if (freesrc) - SDL_RWclose(src); + if (closeio) + SDL_CloseIO(src); return(NULL); } #ifdef __EMSCRIPTEN__ /*load through preloadedImages*/ - - if ( src->type == SDL_RWOPS_STDFILE ) { + FILE *fp = (FILE *)SDL_GetProperty(SDL_GetIOProperties(src), SDL_PROP_IOSTREAM_STDIO_HANDLE_POINTER, NULL); + if (fp) { int w, h, success; char *data; SDL_Surface *surf; - data = emscripten_get_preloaded_image_data_from_FILE(src->hidden.stdio.fp, &w, &h); - - if (data) - { + data = emscripten_get_preloaded_image_data_from_FILE(fp, &w, &h); + if (data) { surf = SDL_CreateSurface(w, h, SDL_PIXELFORMAT_ABGR8888); if (surf != NULL) { SDL_memcpy(surf->pixels, data, w * h * 4); } free(data); /* This should NOT be SDL_free() */ - if (freesrc) - SDL_RWclose(src); + if (closeio) + SDL_CloseIO(src); /* If SDL_CreateSurface returns NULL, it has set the error message for us */ return surf; @@ -275,13 +273,13 @@ SDL_Surface *IMG_LoadTyped_RW(SDL_RWops *src, SDL_bool freesrc, const char *type supported[i].type); #endif image = supported[i].load(src); - if (freesrc) - SDL_RWclose(src); + if (closeio) + SDL_CloseIO(src); return image; } - if ( freesrc ) { - SDL_RWclose(src); + if ( closeio ) { + SDL_CloseIO(src); } IMG_SetError("Unsupported image format"); return NULL; @@ -299,10 +297,10 @@ SDL_Texture *IMG_LoadTexture(SDL_Renderer *renderer, const char *file) return texture; } -SDL_Texture *IMG_LoadTexture_RW(SDL_Renderer *renderer, SDL_RWops *src, SDL_bool freesrc) +SDL_Texture *IMG_LoadTexture_IO(SDL_Renderer *renderer, SDL_IOStream *src, SDL_bool closeio) { SDL_Texture *texture = NULL; - SDL_Surface *surface = IMG_Load_RW(src, freesrc); + SDL_Surface *surface = IMG_Load_IO(src, closeio); if (surface) { texture = SDL_CreateTextureFromSurface(renderer, surface); SDL_DestroySurface(surface); @@ -310,10 +308,10 @@ SDL_Texture *IMG_LoadTexture_RW(SDL_Renderer *renderer, SDL_RWops *src, SDL_bool return texture; } -SDL_Texture *IMG_LoadTextureTyped_RW(SDL_Renderer *renderer, SDL_RWops *src, SDL_bool freesrc, const char *type) +SDL_Texture *IMG_LoadTextureTyped_IO(SDL_Renderer *renderer, SDL_IOStream *src, SDL_bool closeio, const char *type) { SDL_Texture *texture = NULL; - SDL_Surface *surface = IMG_LoadTyped_RW(src, freesrc, type); + SDL_Surface *surface = IMG_LoadTyped_IO(src, closeio, type); if (surface) { texture = SDL_CreateTextureFromSurface(renderer, surface); SDL_DestroySurface(surface); @@ -325,26 +323,26 @@ SDL_Texture *IMG_LoadTextureTyped_RW(SDL_Renderer *renderer, SDL_RWops *src, SDL /* Load an animation from a file */ IMG_Animation *IMG_LoadAnimation(const char *file) { - SDL_RWops *src = SDL_RWFromFile(file, "rb"); + SDL_IOStream *src = SDL_IOFromFile(file, "rb"); const char *ext = SDL_strrchr(file, '.'); if (ext) { ext++; } if (!src) { - /* The error message has been set in SDL_RWFromFile */ + /* The error message has been set in SDL_IOFromFile */ return NULL; } - return IMG_LoadAnimationTyped_RW(src, SDL_TRUE, ext); + return IMG_LoadAnimationTyped_IO(src, SDL_TRUE, ext); } /* Load an animation from an SDL datasource (for compatibility) */ -IMG_Animation *IMG_LoadAnimation_RW(SDL_RWops *src, SDL_bool freesrc) +IMG_Animation *IMG_LoadAnimation_IO(SDL_IOStream *src, SDL_bool closeio) { - return IMG_LoadAnimationTyped_RW(src, freesrc, NULL); + return IMG_LoadAnimationTyped_IO(src, closeio, NULL); } /* Load an animation from an SDL datasource, optionally specifying the type */ -IMG_Animation *IMG_LoadAnimationTyped_RW(SDL_RWops *src, SDL_bool freesrc, const char *type) +IMG_Animation *IMG_LoadAnimationTyped_IO(SDL_IOStream *src, SDL_bool closeio, const char *type) { size_t i; IMG_Animation *anim; @@ -357,10 +355,10 @@ IMG_Animation *IMG_LoadAnimationTyped_RW(SDL_RWops *src, SDL_bool freesrc, const } /* See whether or not this data source can handle seeking */ - if ( SDL_RWseek(src, 0, SDL_RW_SEEK_CUR) < 0 ) { + if (SDL_SeekIO(src, 0, SDL_IO_SEEK_CUR) < 0 ) { IMG_SetError("Can't seek in this data source"); - if (freesrc) - SDL_RWclose(src); + if (closeio) + SDL_CloseIO(src); return(NULL); } @@ -379,13 +377,13 @@ IMG_Animation *IMG_LoadAnimationTyped_RW(SDL_RWops *src, SDL_bool freesrc, const supported_anims[i].type); #endif anim = supported_anims[i].load(src); - if (freesrc) - SDL_RWclose(src); + if (closeio) + SDL_CloseIO(src); return anim; } /* Create a single frame animation from an image */ - image = IMG_LoadTyped_RW(src, freesrc, type); + image = IMG_LoadTyped_IO(src, closeio, type); if (image) { anim = (IMG_Animation *)SDL_malloc(sizeof(*anim)); if (anim) { diff --git a/src/IMG_ImageIO.m b/src/IMG_ImageIO.m index 84dce6e5..cadd5e98 100644 --- a/src/IMG_ImageIO.m +++ b/src/IMG_ImageIO.m @@ -32,9 +32,9 @@ // This callback reads some bytes from an SDL_rwops and copies it // to a Quartz buffer (supplied by Apple framework). -static size_t MyProviderGetBytesCallback(void* rwops_userdata, void* quartz_buffer, size_t the_count) +static size_t MyProviderGetBytesCallback(void* userdata, void* quartz_buffer, size_t the_count) { - Sint64 size = SDL_RWread((struct SDL_RWops *)rwops_userdata, quartz_buffer, the_count); + Sint64 size = SDL_ReadIO((SDL_IOStream *)userdata, quartz_buffer, the_count); if (size <= 0) { return 0; } @@ -43,30 +43,30 @@ static size_t MyProviderGetBytesCallback(void* rwops_userdata, void* quartz_buff // This callback is triggered when the data provider is released // so you can clean up any resources. -static void MyProviderReleaseInfoCallback(void* rwops_userdata) +static void MyProviderReleaseInfoCallback(void* userdata) { - (void)rwops_userdata; + (void)userdata; // What should I put here? - // I think the user and SDL_RWops controls closing, so I don't do anything. + // I think the user and SDL_IOStream controls closing, so I don't do anything. } -static void MyProviderRewindCallback(void* rwops_userdata) +static void MyProviderRewindCallback(void* userdata) { - SDL_RWseek((struct SDL_RWops *)rwops_userdata, 0, SDL_RW_SEEK_SET); + SDL_SeekIO((SDL_IOStream *)userdata, 0, SDL_IO_SEEK_SET); } #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1050 // CGDataProviderCreateSequential was introduced in 10.5; CGDataProviderCreate is deprecated -off_t MyProviderSkipForwardBytesCallback(void* rwops_userdata, off_t the_count) +off_t MyProviderSkipForwardBytesCallback(void* userdata, off_t the_count) { - off_t start_position = SDL_RWtell((struct SDL_RWops *)rwops_userdata); - SDL_RWseek((struct SDL_RWops *)rwops_userdata, the_count, SDL_RW_SEEK_CUR); - off_t end_position = SDL_RWtell((struct SDL_RWops *)rwops_userdata); + off_t start_position = SDL_TellIO((SDL_IOStream *)userdata); + SDL_SeekIO((SDL_IOStream *)userdata, the_count, SDL_IO_SEEK_CUR); + off_t end_position = SDL_TellIO((SDL_IOStream *)userdata); return (end_position - start_position); } #else // CGDataProviderCreate was deprecated in 10.5 -static void MyProviderSkipBytesCallback(void* rwops_userdata, size_t the_count) +static void MyProviderSkipBytesCallback(void* userdata, size_t the_count) { - SDL_RWseek((struct SDL_RWops *)rwops_userdata, the_count, SDL_RW_SEEK_CUR); + SDL_SeekIO((SDL_IOStream *)userdata, the_count, SDL_IO_SEEK_CUR); } #endif @@ -76,11 +76,11 @@ static void MyProviderSkipBytesCallback(void* rwops_userdata, size_t the_count) // This creates a CGImageSourceRef which is a handle to an image that can be used to examine information // about the image or load the actual image data. -static CGImageSourceRef CreateCGImageSourceFromRWops(SDL_RWops* rw_ops, CFDictionaryRef hints_and_options) +static CGImageSourceRef CreateCGImageSourceFromIOStream(SDL_IOStream * rw_ops, CFDictionaryRef hints_and_options) { CGImageSourceRef source_ref; - // Similar to SDL_RWops, Apple has their own callbacks for dealing with data streams. + // Similar to SDL_IOStream, Apple has their own callbacks for dealing with data streams. #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1050 // CGDataProviderCreateSequential was introduced in 10.5; CGDataProviderCreate is deprecated CGDataProviderSequentialCallbacks provider_callbacks = @@ -384,16 +384,16 @@ void IMG_QuitTIF(void) { } -static int Internal_isType (SDL_RWops *rw_ops, CFStringRef uti_string_to_test) +static int Internal_isType (SDL_IOStream *rw_ops, CFStringRef uti_string_to_test) { int is_type = 0; if (rw_ops == NULL) return 0; - Sint64 start = SDL_RWtell(rw_ops); + Sint64 start = SDL_TellIO(rw_ops); CFDictionaryRef hint_dictionary = CreateHintDictionary(uti_string_to_test); - CGImageSourceRef image_source = CreateCGImageSourceFromRWops(rw_ops, hint_dictionary); + CGImageSourceRef image_source = CreateCGImageSourceFromIOStream(rw_ops, hint_dictionary); if (hint_dictionary != NULL) { CFRelease(hint_dictionary); @@ -401,7 +401,7 @@ static int Internal_isType (SDL_RWops *rw_ops, CFStringRef uti_string_to_test) if (NULL == image_source) { // reset the file pointer - SDL_RWseek(rw_ops, start, SEEK_SET); + SDL_SeekIO(rw_ops, start, SEEK_SET); return 0; } @@ -419,31 +419,31 @@ static int Internal_isType (SDL_RWops *rw_ops, CFStringRef uti_string_to_test) CFRelease(image_source); // reset the file pointer - SDL_RWseek(rw_ops, start, SEEK_SET); + SDL_SeekIO(rw_ops, start, SEEK_SET); return is_type; } #ifdef BMP_USES_IMAGEIO -int IMG_isCUR(SDL_RWops *src) +int IMG_isCUR(SDL_IOStream *src) { /* FIXME: Is this a supported type? */ return Internal_isType(src, CFSTR("com.microsoft.cur")); } -int IMG_isICO(SDL_RWops *src) +int IMG_isICO(SDL_IOStream *src) { return Internal_isType(src, kUTTypeICO); } -int IMG_isBMP(SDL_RWops *src) +int IMG_isBMP(SDL_IOStream *src) { return Internal_isType(src, kUTTypeBMP); } #endif /* BMP_USES_IMAGEIO */ -int IMG_isGIF(SDL_RWops *src) +int IMG_isGIF(SDL_IOStream *src) { return Internal_isType(src, kUTTypeGIF); } @@ -451,7 +451,7 @@ int IMG_isGIF(SDL_RWops *src) #ifdef JPG_USES_IMAGEIO // Note: JPEG 2000 is kUTTypeJPEG2000 -int IMG_isJPG(SDL_RWops *src) +int IMG_isJPG(SDL_IOStream *src) { return Internal_isType(src, kUTTypeJPEG); } @@ -460,7 +460,7 @@ int IMG_isJPG(SDL_RWops *src) #ifdef PNG_USES_IMAGEIO -int IMG_isPNG(SDL_RWops *src) +int IMG_isPNG(SDL_IOStream *src) { return Internal_isType(src, kUTTypePNG); } @@ -468,20 +468,20 @@ int IMG_isPNG(SDL_RWops *src) #endif /* PNG_USES_IMAGEIO */ // This isn't a public API function. Apple seems to be able to identify tga's. -int IMG_isTGA(SDL_RWops *src) +int IMG_isTGA(SDL_IOStream *src) { return Internal_isType(src, CFSTR("com.truevision.tga-image")); } -int IMG_isTIF(SDL_RWops *src) +int IMG_isTIF(SDL_IOStream *src) { return Internal_isType(src, kUTTypeTIFF); } -static SDL_Surface *LoadImageFromRWops (SDL_RWops *rw_ops, CFStringRef uti_string_hint) +static SDL_Surface *LoadImageFromIOStream (SDL_IOStream *rw_ops, CFStringRef uti_string_hint) { CFDictionaryRef hint_dictionary = CreateHintDictionary(uti_string_hint); - CGImageSourceRef image_source = CreateCGImageSourceFromRWops(rw_ops, hint_dictionary); + CGImageSourceRef image_source = CreateCGImageSourceFromIOStream(rw_ops, hint_dictionary); if (hint_dictionary != NULL) CFRelease(hint_dictionary); @@ -521,55 +521,55 @@ int IMG_isTIF(SDL_RWops *src) #ifdef BMP_USES_IMAGEIO -SDL_Surface* IMG_LoadCUR_RW (SDL_RWops *src) +SDL_Surface* IMG_LoadCUR_IO (SDL_IOStream *src) { /* FIXME: Is this a supported type? */ - return LoadImageFromRWops(src, CFSTR("com.microsoft.cur")); + return LoadImageFromIOStream(src, CFSTR("com.microsoft.cur")); } -SDL_Surface* IMG_LoadICO_RW (SDL_RWops *src) +SDL_Surface* IMG_LoadICO_IO (SDL_IOStream *src) { - return LoadImageFromRWops(src, kUTTypeICO); + return LoadImageFromIOStream(src, kUTTypeICO); } -SDL_Surface* IMG_LoadBMP_RW (SDL_RWops *src) +SDL_Surface* IMG_LoadBMP_IO (SDL_IOStream *src) { - return LoadImageFromRWops(src, kUTTypeBMP); + return LoadImageFromIOStream(src, kUTTypeBMP); } #endif /* BMP_USES_IMAGEIO */ -SDL_Surface* IMG_LoadGIF_RW (SDL_RWops *src) +SDL_Surface* IMG_LoadGIF_IO (SDL_IOStream *src) { - return LoadImageFromRWops (src, kUTTypeGIF); + return LoadImageFromIOStream (src, kUTTypeGIF); } #ifdef JPG_USES_IMAGEIO -SDL_Surface* IMG_LoadJPG_RW (SDL_RWops *src) +SDL_Surface* IMG_LoadJPG_IO (SDL_IOStream *src) { - return LoadImageFromRWops (src, kUTTypeJPEG); + return LoadImageFromIOStream (src, kUTTypeJPEG); } #endif /* JPG_USES_IMAGEIO */ #ifdef PNG_USES_IMAGEIO -SDL_Surface* IMG_LoadPNG_RW (SDL_RWops *src) +SDL_Surface* IMG_LoadPNG_IO (SDL_IOStream *src) { - return LoadImageFromRWops (src, kUTTypePNG); + return LoadImageFromIOStream (src, kUTTypePNG); } #endif /* PNG_USES_IMAGEIO */ -SDL_Surface* IMG_LoadTGA_RW (SDL_RWops *src) +SDL_Surface* IMG_LoadTGA_IO (SDL_IOStream *src) { - return LoadImageFromRWops(src, CFSTR("com.truevision.tga-image")); + return LoadImageFromIOStream(src, CFSTR("com.truevision.tga-image")); } -SDL_Surface* IMG_LoadTIF_RW (SDL_RWops *src) +SDL_Surface* IMG_LoadTIF_IO (SDL_IOStream *src) { - return LoadImageFromRWops(src, kUTTypeTIFF); + return LoadImageFromIOStream(src, kUTTypeTIFF); } // Since UIImage doesn't really support streams well, we should optimize for the file case. @@ -591,12 +591,12 @@ int IMG_isTIF(SDL_RWops *src) if (!surface) { // Either the file doesn't exist or ImageIO doesn't understand the format. // For the latter case, fallback to the native SDL_image handlers. - SDL_RWops *src = SDL_RWFromFile(file, "rb"); + SDL_IOStream *src = SDL_IOFromFile(file, "rb"); if (!src) { - /* The error message has been set in SDL_RWFromFile */ + /* The error message has been set in SDL_IOFromFile */ return NULL; } - surface = IMG_LoadTyped_RW(src, 1, ext); + surface = IMG_LoadTyped_IO(src, 1, ext); } return surface; } diff --git a/src/IMG_WIC.c b/src/IMG_WIC.c index 0833c70e..a94bc76a 100644 --- a/src/IMG_WIC.c +++ b/src/IMG_WIC.c @@ -84,7 +84,7 @@ void IMG_QuitTIF(void) WIC_Quit(); } -int IMG_isPNG(SDL_RWops *src) +int IMG_isPNG(SDL_IOStream *src) { Sint64 start; int is_PNG; @@ -94,9 +94,9 @@ int IMG_isPNG(SDL_RWops *src) return 0; } - start = SDL_RWtell(src); + start = SDL_TellIO(src); is_PNG = 0; - if ( SDL_RWread(src, magic, sizeof(magic)) == sizeof(magic) ) { + if (SDL_ReadIO(src, magic, sizeof(magic)) == sizeof(magic) ) { if ( magic[0] == 0x89 && magic[1] == 'P' && magic[2] == 'N' && @@ -104,11 +104,11 @@ int IMG_isPNG(SDL_RWops *src) is_PNG = 1; } } - SDL_RWseek(src, start, SDL_RW_SEEK_SET); + SDL_SeekIO(src, start, SDL_IO_SEEK_SET); return(is_PNG); } -int IMG_isJPG(SDL_RWops *src) +int IMG_isJPG(SDL_IOStream *src) { Sint64 start; int is_JPG; @@ -121,14 +121,14 @@ int IMG_isJPG(SDL_RWops *src) if (!src) return 0; - start = SDL_RWtell(src); + start = SDL_TellIO(src); is_JPG = 0; in_scan = 0; - if (SDL_RWread(src, magic, 2) == 2) { + if (SDL_ReadIO(src, magic, 2) == 2) { if ((magic[0] == 0xFF) && (magic[1] == 0xD8)) { is_JPG = 1; while (is_JPG == 1) { - if (SDL_RWread(src, magic, 2) != 2) { + if (SDL_ReadIO(src, magic, 2) != 2) { is_JPG = 0; } else if ((magic[0] != 0xFF) && (in_scan == 0)) { @@ -137,7 +137,7 @@ int IMG_isJPG(SDL_RWops *src) else if ((magic[0] != 0xFF) || (magic[1] == 0xFF)) { /* Extra padding in JPEG (legal) */ /* or this is data and we are scanning */ - SDL_RWseek(src, -1, SDL_RW_SEEK_CUR); + SDL_SeekIO(src, -1, SDL_IO_SEEK_CUR); } else if (magic[1] == 0xD9) { /* Got to end of good JPEG */ @@ -149,7 +149,7 @@ int IMG_isJPG(SDL_RWops *src) else if ((magic[1] >= 0xD0) && (magic[1] < 0xD9)) { /* These have nothing else */ } - else if (SDL_RWread(src, magic + 2, 2) != 2) { + else if (SDL_ReadIO(src, magic + 2, 2) != 2) { is_JPG = 0; } else { @@ -157,9 +157,9 @@ int IMG_isJPG(SDL_RWops *src) Sint64 innerStart; Uint32 size; Sint64 end; - innerStart = SDL_RWtell(src); + innerStart = SDL_TellIO(src); size = (magic[2] << 8) + magic[3]; - end = SDL_RWseek(src, size - 2, SDL_RW_SEEK_CUR); + end = SDL_SeekIO(src, size - 2, SDL_IO_SEEK_CUR); if (end != innerStart + size - 2) is_JPG = 0; if (magic[1] == 0xDA) { /* Now comes the actual JPEG meat */ @@ -175,11 +175,11 @@ int IMG_isJPG(SDL_RWops *src) } } } - SDL_RWseek(src, start, SDL_RW_SEEK_SET); + SDL_SeekIO(src, start, SDL_IO_SEEK_SET); return(is_JPG); } -int IMG_isTIF(SDL_RWops* src) +int IMG_isTIF(SDL_IOStream * src) { Sint64 start; int is_TIF; @@ -187,9 +187,9 @@ int IMG_isTIF(SDL_RWops* src) if (!src) return 0; - start = SDL_RWtell(src); + start = SDL_TellIO(src); is_TIF = 0; - if (SDL_RWread(src, magic, sizeof(magic)) == sizeof(magic)) { + if (SDL_ReadIO(src, magic, sizeof(magic)) == sizeof(magic)) { if ((magic[0] == 'I' && magic[1] == 'I' && magic[2] == 0x2a && @@ -201,11 +201,11 @@ int IMG_isTIF(SDL_RWops* src) is_TIF = 1; } } - SDL_RWseek(src, start, SDL_RW_SEEK_SET); + SDL_SeekIO(src, start, SDL_IO_SEEK_SET); return(is_TIF); } -static SDL_Surface* WIC_LoadImage(SDL_RWops *src) +static SDL_Surface* WIC_LoadImage(SDL_IOStream *src) { SDL_Surface* surface = NULL; @@ -221,7 +221,7 @@ static SDL_Surface* WIC_LoadImage(SDL_RWops *src) } size_t fileSize; - Uint8 *memoryBuffer = (Uint8 *)SDL_LoadFile_RW(src, &fileSize, SDL_FALSE); + Uint8 *memoryBuffer = (Uint8 *)SDL_LoadFile_IO(src, &fileSize, SDL_FALSE); if (!memoryBuffer) { return NULL; } @@ -278,17 +278,17 @@ static SDL_Surface* WIC_LoadImage(SDL_RWops *src) return surface; } -SDL_Surface *IMG_LoadPNG_RW(SDL_RWops *src) +SDL_Surface *IMG_LoadPNG_IO(SDL_IOStream *src) { return WIC_LoadImage(src); } -SDL_Surface *IMG_LoadJPG_RW(SDL_RWops *src) +SDL_Surface *IMG_LoadJPG_IO(SDL_IOStream *src) { return WIC_LoadImage(src); } -SDL_Surface *IMG_LoadTIF_RW(SDL_RWops *src) +SDL_Surface *IMG_LoadTIF_IO(SDL_IOStream *src) { return WIC_LoadImage(src); } diff --git a/src/IMG_avif.c b/src/IMG_avif.c index 6f8dcd1c..bb444672 100644 --- a/src/IMG_avif.c +++ b/src/IMG_avif.c @@ -132,7 +132,7 @@ void IMG_QuitAVIF(void) --lib.loaded; } -static SDL_bool ReadAVIFHeader(SDL_RWops *src, Uint8 **header_data, size_t *header_size) +static SDL_bool ReadAVIFHeader(SDL_IOStream *src, Uint8 **header_data, size_t *header_size) { Uint8 magic[16]; Uint64 size; @@ -142,7 +142,7 @@ static SDL_bool ReadAVIFHeader(SDL_RWops *src, Uint8 **header_data, size_t *head *header_data = NULL; *header_size = 0; - if (SDL_RWread(src, magic, 8) != 8) { + if (SDL_ReadIO(src, magic, 8) != 8) { return SDL_FALSE; } read += 8; @@ -157,7 +157,7 @@ static SDL_bool ReadAVIFHeader(SDL_RWops *src, Uint8 **header_data, size_t *head ((Uint64)magic[3] << 0)); if (size == 1) { /* 64-bit header size */ - if (SDL_RWread(src, &magic[8], 8) != 8) { + if (SDL_ReadIO(src, &magic[8], 8) != 8) { return SDL_FALSE; } read += 8; @@ -186,7 +186,7 @@ static SDL_bool ReadAVIFHeader(SDL_RWops *src, Uint8 **header_data, size_t *head } SDL_memcpy(data, magic, (size_t)read); - if (SDL_RWread(src, &data[read], (size_t)(size - read)) != (size_t)(size - read)) { + if (SDL_ReadIO(src, &data[read], (size_t)(size - read)) != (size_t)(size - read)) { SDL_free(data); return SDL_FALSE; } @@ -196,7 +196,7 @@ static SDL_bool ReadAVIFHeader(SDL_RWops *src, Uint8 **header_data, size_t *head } /* See if an image is contained in a data source */ -int IMG_isAVIF(SDL_RWops *src) +int IMG_isAVIF(SDL_IOStream *src) { Sint64 start; int is_AVIF; @@ -207,7 +207,7 @@ int IMG_isAVIF(SDL_RWops *src) return 0; } - start = SDL_RWtell(src); + start = SDL_TellIO(src); is_AVIF = 0; if (ReadAVIFHeader(src, &data, &size)) { /* This might be AVIF, do more thorough checks */ @@ -220,14 +220,14 @@ int IMG_isAVIF(SDL_RWops *src) } SDL_free(data); } - SDL_RWseek(src, start, SDL_RW_SEEK_SET); + SDL_SeekIO(src, start, SDL_IO_SEEK_SET); return(is_AVIF); } /* Context for AFIF I/O operations */ typedef struct { - SDL_RWops *src; + SDL_IOStream *src; Uint64 start; uint8_t *data; Sint64 size; @@ -240,7 +240,7 @@ static avifResult ReadAVIFIO(struct avifIO * io, uint32_t readFlags, uint64_t of (void) readFlags; /* not used */ /* The AVIF reader bounces all over, so always seek to the correct offset */ - if (SDL_RWseek(context->src, context->start + offset, SDL_RW_SEEK_SET) < 0) { + if (SDL_SeekIO(context->src, context->start + offset, SDL_IO_SEEK_SET) < 0) { return AVIF_RESULT_IO_ERROR; } @@ -254,9 +254,9 @@ static avifResult ReadAVIFIO(struct avifIO * io, uint32_t readFlags, uint64_t of } out->data = context->data; - out->size = SDL_RWread(context->src, context->data, size); + out->size = SDL_ReadIO(context->src, context->data, size); if (out->size == 0) { - if (context->src->status == SDL_RWOPS_STATUS_NOT_READY) { + if (SDL_GetIOStatus(context->src) == SDL_IO_STATUS_NOT_READY) { return AVIF_RESULT_WAITING_ON_IO; } else { return AVIF_RESULT_IO_ERROR; @@ -349,7 +349,7 @@ static void ConvertRGB16toXBGR2101010(avifRGBImage *image, SDL_Surface *surface) } /* Load a AVIF type image from an SDL datasource */ -SDL_Surface *IMG_LoadAVIF_RW(SDL_RWops *src) +SDL_Surface *IMG_LoadAVIF_IO(SDL_IOStream *src) { Sint64 start; avifDecoder *decoder = NULL; @@ -360,10 +360,10 @@ SDL_Surface *IMG_LoadAVIF_RW(SDL_RWops *src) SDL_Surface *surface = NULL; if (!src) { - /* The error message has been set in SDL_RWFromFile */ + /* The error message has been set in SDL_IOFromFile */ return NULL; } - start = SDL_RWtell(src); + start = SDL_TellIO(src); if ((IMG_Init(IMG_INIT_AVIF) & IMG_INIT_AVIF) == 0) { return NULL; @@ -515,12 +515,12 @@ SDL_Surface *IMG_LoadAVIF_RW(SDL_RWops *src) lib.avifDecoderDestroy(decoder); } if (!surface) { - SDL_RWseek(src, start, SDL_RW_SEEK_SET); + SDL_SeekIO(src, start, SDL_IO_SEEK_SET); } return surface; } -static int IMG_SaveAVIF_RW_libavif(SDL_Surface *surface, SDL_RWops *dst, int quality) +static int IMG_SaveAVIF_IO_libavif(SDL_Surface *surface, SDL_IOStream *dst, int quality) { avifImage *image = NULL; avifRGBImage rgb; @@ -683,7 +683,7 @@ static int IMG_SaveAVIF_RW_libavif(SDL_Surface *surface, SDL_RWops *dst, int qua goto done; } - if (SDL_RWwrite(dst, avifOutput.data, avifOutput.size) == avifOutput.size) { + if (SDL_WriteIO(dst, avifOutput.data, avifOutput.size) == avifOutput.size) { result = 0; } @@ -722,14 +722,14 @@ void IMG_QuitAVIF(void) } /* See if an image is contained in a data source */ -int IMG_isAVIF(SDL_RWops *src) +int IMG_isAVIF(SDL_IOStream *src) { (void)src; return(0); } /* Load a AVIF type image from an SDL datasource */ -SDL_Surface *IMG_LoadAVIF_RW(SDL_RWops *src) +SDL_Surface *IMG_LoadAVIF_IO(SDL_IOStream *src) { (void)src; return(NULL); @@ -739,15 +739,15 @@ SDL_Surface *IMG_LoadAVIF_RW(SDL_RWops *src) int IMG_SaveAVIF(SDL_Surface *surface, const char *file, int quality) { - SDL_RWops *dst = SDL_RWFromFile(file, "wb"); + SDL_IOStream *dst = SDL_IOFromFile(file, "wb"); if (dst) { - return IMG_SaveAVIF_RW(surface, dst, 1, quality); + return IMG_SaveAVIF_IO(surface, dst, 1, quality); } else { return -1; } } -int IMG_SaveAVIF_RW(SDL_Surface *surface, SDL_RWops *dst, int freedst, int quality) +int IMG_SaveAVIF_IO(SDL_Surface *surface, SDL_IOStream *dst, int closeio, int quality) { int result = -1; @@ -757,7 +757,7 @@ int IMG_SaveAVIF_RW(SDL_Surface *surface, SDL_RWops *dst, int freedst, int quali #if SDL_IMAGE_SAVE_AVIF if (result < 0) { - result = IMG_SaveAVIF_RW_libavif(surface, dst, quality); + result = IMG_SaveAVIF_IO_libavif(surface, dst, quality); } #else @@ -766,8 +766,8 @@ int IMG_SaveAVIF_RW(SDL_Surface *surface, SDL_RWops *dst, int freedst, int quali result = IMG_SetError("SDL_image built without AVIF save support"); #endif - if (freedst) { - SDL_RWclose(dst); + if (closeio) { + SDL_CloseIO(dst); } return result; } diff --git a/src/IMG_bmp.c b/src/IMG_bmp.c index 35a31380..dbd563c0 100644 --- a/src/IMG_bmp.c +++ b/src/IMG_bmp.c @@ -36,7 +36,7 @@ #ifdef LOAD_BMP /* See if an image is contained in a data source */ -int IMG_isBMP(SDL_RWops *src) +int IMG_isBMP(SDL_IOStream *src) { Sint64 start; int is_BMP; @@ -44,18 +44,18 @@ int IMG_isBMP(SDL_RWops *src) if ( !src ) return 0; - start = SDL_RWtell(src); + start = SDL_TellIO(src); is_BMP = 0; - if (SDL_RWread(src, magic, sizeof(magic)) == sizeof(magic)) { + if (SDL_ReadIO(src, magic, sizeof(magic)) == sizeof(magic)) { if (SDL_strncmp(magic, "BM", 2) == 0) { is_BMP = 1; } } - SDL_RWseek(src, start, SDL_RW_SEEK_SET); + SDL_SeekIO(src, start, SDL_IO_SEEK_SET); return(is_BMP); } -static int IMG_isICOCUR(SDL_RWops *src, int type) +static int IMG_isICOCUR(SDL_IOStream *src, int type) { Sint64 start; int is_ICOCUR; @@ -68,7 +68,7 @@ static int IMG_isICOCUR(SDL_RWops *src, int type) if (!src) { return 0; } - start = SDL_RWtell(src); + start = SDL_TellIO(src); is_ICOCUR = 0; if (SDL_ReadU16LE(src, &bfReserved) && SDL_ReadU16LE(src, &bfType) && @@ -76,17 +76,17 @@ static int IMG_isICOCUR(SDL_RWops *src, int type) (bfReserved == 0) && (bfType == type) && (bfCount != 0)) { is_ICOCUR = 1; } - SDL_RWseek(src, start, SDL_RW_SEEK_SET); + SDL_SeekIO(src, start, SDL_IO_SEEK_SET); return (is_ICOCUR); } -int IMG_isICO(SDL_RWops *src) +int IMG_isICO(SDL_IOStream *src) { return IMG_isICOCUR(src, 1); } -int IMG_isCUR(SDL_RWops *src) +int IMG_isCUR(SDL_IOStream *src) { return IMG_isICOCUR(src, 2); } @@ -103,13 +103,13 @@ int IMG_isCUR(SDL_RWops *src) #define BI_BITFIELDS 3 #endif -static SDL_Surface *LoadBMP_RW (SDL_RWops *src, SDL_bool freesrc) +static SDL_Surface *LoadBMP_IO (SDL_IOStream *src, SDL_bool closeio) { - return SDL_LoadBMP_RW(src, freesrc); + return SDL_LoadBMP_IO(src, closeio); } static SDL_Surface * -LoadICOCUR_RW(SDL_RWops * src, int type, SDL_bool freesrc) +LoadICOCUR_IO(SDL_IOStream * src, int type, SDL_bool closeio) { SDL_bool was_error = SDL_TRUE; Sint64 fp_offset = 0; @@ -153,7 +153,7 @@ LoadICOCUR_RW(SDL_RWops * src, int type, SDL_bool freesrc) } /* Read in the ICO file header */ - fp_offset = SDL_RWtell(src); + fp_offset = SDL_TellIO(src); if (!SDL_ReadU16LE(src, &bfReserved) || !SDL_ReadU16LE(src, &bfType) || @@ -216,7 +216,7 @@ LoadICOCUR_RW(SDL_RWops * src, int type, SDL_bool freesrc) } /* Advance to the DIB Data */ - if (SDL_RWseek(src, icoOfs, SDL_RW_SEEK_SET) < 0) { + if (SDL_SeekIO(src, icoOfs, SDL_IO_SEEK_SET) < 0) { goto done; } @@ -301,7 +301,7 @@ LoadICOCUR_RW(SDL_RWops * src, int type, SDL_bool freesrc) goto done; } for (i = 0; i < (int) biClrUsed; ++i) { - if (SDL_RWread(src, &palette[i], 4) != 4) { + if (SDL_ReadIO(src, &palette[i], 4) != 4) { goto done; } } @@ -342,7 +342,7 @@ LoadICOCUR_RW(SDL_RWops * src, int type, SDL_bool freesrc) int shift = (8 - ExpandBMP); for (i = 0; i < surface->w; ++i) { if (i % (8 / ExpandBMP) == 0) { - if (SDL_RWread(src, &pixel, 1) != 1) { + if (SDL_ReadIO(src, &pixel, 1) != 1) { goto done; } } @@ -359,7 +359,7 @@ LoadICOCUR_RW(SDL_RWops * src, int type, SDL_bool freesrc) pixel = 0; for (j = 0; j < 3; ++j) { /* Load each color channel into pixel */ - if (SDL_RWread(src, &channel, 1) != 1) { + if (SDL_ReadIO(src, &channel, 1) != 1) { goto done; } pixel |= (channel << (j * 8)); @@ -370,7 +370,7 @@ LoadICOCUR_RW(SDL_RWops * src, int type, SDL_bool freesrc) break; default: - if (SDL_RWread(src, bits, surface->pitch) != (size_t)surface->pitch) { + if (SDL_ReadIO(src, bits, surface->pitch) != (size_t)surface->pitch) { goto done; } break; @@ -379,7 +379,7 @@ LoadICOCUR_RW(SDL_RWops * src, int type, SDL_bool freesrc) if (pad) { Uint8 padbyte; for (i = 0; i < pad; ++i) { - if (SDL_RWread(src, &padbyte, 1) != 1) { + if (SDL_ReadIO(src, &padbyte, 1) != 1) { goto done; } } @@ -397,7 +397,7 @@ LoadICOCUR_RW(SDL_RWops * src, int type, SDL_bool freesrc) bits -= surface->pitch; for (i = 0; i < surface->w; ++i) { if (i % (8 / ExpandBMP) == 0) { - if (SDL_RWread(src, &pixel, 1) != 1) { + if (SDL_ReadIO(src, &pixel, 1) != 1) { goto done; } } @@ -408,7 +408,7 @@ LoadICOCUR_RW(SDL_RWops * src, int type, SDL_bool freesrc) if (pad) { Uint8 padbyte; for (i = 0; i < pad; ++i) { - if (SDL_RWread(src, &padbyte, 1) != 1) { + if (SDL_ReadIO(src, &padbyte, 1) != 1) { goto done; } } @@ -418,12 +418,12 @@ LoadICOCUR_RW(SDL_RWops * src, int type, SDL_bool freesrc) was_error = SDL_FALSE; done: - if (freesrc && src) { - SDL_RWclose(src); + if (closeio && src) { + SDL_CloseIO(src); } if (was_error) { - if (src && !freesrc) { - SDL_RWseek(src, fp_offset, SDL_RW_SEEK_SET); + if (src && !closeio) { + SDL_SeekIO(src, fp_offset, SDL_IO_SEEK_SET); } if (surface) { SDL_DestroySurface(surface); @@ -434,21 +434,21 @@ LoadICOCUR_RW(SDL_RWops * src, int type, SDL_bool freesrc) } /* Load a BMP type image from an SDL datasource */ -SDL_Surface *IMG_LoadBMP_RW(SDL_RWops *src) +SDL_Surface *IMG_LoadBMP_IO(SDL_IOStream *src) { - return(LoadBMP_RW(src, SDL_FALSE)); + return(LoadBMP_IO(src, SDL_FALSE)); } /* Load a ICO type image from an SDL datasource */ -SDL_Surface *IMG_LoadICO_RW(SDL_RWops *src) +SDL_Surface *IMG_LoadICO_IO(SDL_IOStream *src) { - return(LoadICOCUR_RW(src, 1, SDL_FALSE)); + return(LoadICOCUR_IO(src, 1, SDL_FALSE)); } /* Load a CUR type image from an SDL datasource */ -SDL_Surface *IMG_LoadCUR_RW(SDL_RWops *src) +SDL_Surface *IMG_LoadCUR_IO(SDL_IOStream *src) { - return(LoadICOCUR_RW(src, 2, SDL_FALSE)); + return(LoadICOCUR_IO(src, 2, SDL_FALSE)); } #else @@ -458,35 +458,35 @@ SDL_Surface *IMG_LoadCUR_RW(SDL_RWops *src) #endif /* See if an image is contained in a data source */ -int IMG_isBMP(SDL_RWops *src) +int IMG_isBMP(SDL_IOStream *src) { return(0); } -int IMG_isICO(SDL_RWops *src) +int IMG_isICO(SDL_IOStream *src) { return(0); } -int IMG_isCUR(SDL_RWops *src) +int IMG_isCUR(SDL_IOStream *src) { return(0); } /* Load a BMP type image from an SDL datasource */ -SDL_Surface *IMG_LoadBMP_RW(SDL_RWops *src) +SDL_Surface *IMG_LoadBMP_IO(SDL_IOStream *src) { return(NULL); } /* Load a BMP type image from an SDL datasource */ -SDL_Surface *IMG_LoadCUR_RW(SDL_RWops *src) +SDL_Surface *IMG_LoadCUR_IO(SDL_IOStream *src) { return(NULL); } /* Load a BMP type image from an SDL datasource */ -SDL_Surface *IMG_LoadICO_RW(SDL_RWops *src) +SDL_Surface *IMG_LoadICO_IO(SDL_IOStream *src) { return(NULL); } diff --git a/src/IMG_gif.c b/src/IMG_gif.c index bcca0c91..66371696 100644 --- a/src/IMG_gif.c +++ b/src/IMG_gif.c @@ -77,7 +77,7 @@ #define LOCALCOLORMAP 0x80 #define BitSet(byte, bit) (((byte) & (bit)) == (bit)) -#define ReadOK(file,buffer,len) (SDL_RWread(file, buffer, len) == len) +#define ReadOK(file,buffer,len) (SDL_ReadIO(file, buffer, len) == len) #define LM_to_uint(a,b) (((b)<<8)|(a)) @@ -128,15 +128,15 @@ typedef struct Frame_t *frames; } Anim_t; -static int ReadColorMap(SDL_RWops * src, int number, - unsigned char buffer[3][MAXCOLORMAPSIZE], int *flag); -static int DoExtension(SDL_RWops * src, int label, State_t * state); -static int GetDataBlock(SDL_RWops * src, unsigned char *buf, State_t * state); -static int GetCode(SDL_RWops * src, int code_size, int flag, State_t * state); -static int LWZReadByte(SDL_RWops * src, int flag, int input_code_size, State_t * state); -static Image *ReadImage(SDL_RWops * src, int len, int height, int, - unsigned char cmap[3][MAXCOLORMAPSIZE], - int gray, int interlace, int ignore, State_t * state); +static int ReadColorMap(SDL_IOStream * src, int number, + unsigned char buffer[3][MAXCOLORMAPSIZE], int *flag); +static int DoExtension(SDL_IOStream * src, int label, State_t * state); +static int GetDataBlock(SDL_IOStream * src, unsigned char *buf, State_t * state); +static int GetCode(SDL_IOStream * src, int code_size, int flag, State_t * state); +static int LWZReadByte(SDL_IOStream * src, int flag, int input_code_size, State_t * state); +static Image *ReadImage(SDL_IOStream * src, int len, int height, int, + unsigned char cmap[3][MAXCOLORMAPSIZE], + int gray, int interlace, int ignore, State_t * state); static SDL_bool NormalizeFrames(Frame_t *frames, int count) { @@ -201,7 +201,7 @@ static SDL_bool NormalizeFrames(Frame_t *frames, int count) } static Anim_t * -IMG_LoadGIF_RW_Internal(SDL_RWops *src, SDL_bool load_anim) +IMG_LoadGIF_IO_Internal(SDL_IOStream *src, SDL_bool load_anim) { unsigned char buf[16]; unsigned char c; @@ -366,7 +366,7 @@ IMG_LoadGIF_RW_Internal(SDL_RWops *src, SDL_bool load_anim) } static int -ReadColorMap(SDL_RWops *src, int number, +ReadColorMap(SDL_IOStream *src, int number, unsigned char buffer[3][MAXCOLORMAPSIZE], int *gray) { int i; @@ -400,7 +400,7 @@ ReadColorMap(SDL_RWops *src, int number, } static int -DoExtension(SDL_RWops *src, int label, State_t * state) +DoExtension(SDL_IOStream *src, int label, State_t * state) { unsigned char buf[256]; @@ -435,7 +435,7 @@ DoExtension(SDL_RWops *src, int label, State_t * state) } static int -GetDataBlock(SDL_RWops *src, unsigned char *buf, State_t * state) +GetDataBlock(SDL_IOStream *src, unsigned char *buf, State_t * state) { unsigned char count; @@ -453,7 +453,7 @@ GetDataBlock(SDL_RWops *src, unsigned char *buf, State_t * state) } static int -GetCode(SDL_RWops *src, int code_size, int flag, State_t * state) +GetCode(SDL_IOStream *src, int code_size, int flag, State_t * state) { int i, j, ret; unsigned char count; @@ -494,7 +494,7 @@ GetCode(SDL_RWops *src, int code_size, int flag, State_t * state) } static int -LWZReadByte(SDL_RWops *src, int flag, int input_code_size, State_t * state) +LWZReadByte(SDL_IOStream *src, int flag, int input_code_size, State_t * state) { int i, code, incode; @@ -612,7 +612,7 @@ LWZReadByte(SDL_RWops *src, int flag, int input_code_size, State_t * state) } static Image * -ReadImage(SDL_RWops * src, int len, int height, int cmapSize, +ReadImage(SDL_IOStream * src, int len, int height, int cmapSize, unsigned char cmap[3][MAXCOLORMAPSIZE], int gray, int interlace, int ignore, State_t * state) { @@ -704,9 +704,9 @@ ReadImage(SDL_RWops * src, int len, int height, int cmapSize, } /* Load a GIF type animation from an SDL datasource */ -IMG_Animation *IMG_LoadGIFAnimation_RW(SDL_RWops *src) +IMG_Animation *IMG_LoadGIFAnimation_IO(SDL_IOStream *src) { - Anim_t *internal = IMG_LoadGIF_RW_Internal(src, SDL_TRUE); + Anim_t *internal = IMG_LoadGIF_IO_Internal(src, SDL_TRUE); if (internal) { IMG_Animation *anim = (IMG_Animation *)SDL_malloc(sizeof(*anim)); if (anim) { @@ -742,7 +742,7 @@ IMG_Animation *IMG_LoadGIFAnimation_RW(SDL_RWops *src) #else /* Load a GIF type animation from an SDL datasource */ -IMG_Animation *IMG_LoadGIFAnimation_RW(SDL_RWops *src) +IMG_Animation *IMG_LoadGIFAnimation_IO(SDL_IOStream *src) { return NULL; } @@ -754,7 +754,7 @@ IMG_Animation *IMG_LoadGIFAnimation_RW(SDL_RWops *src) #ifdef LOAD_GIF /* See if an image is contained in a data source */ -int IMG_isGIF(SDL_RWops *src) +int IMG_isGIF(SDL_IOStream *src) { Sint64 start; int is_GIF; @@ -762,24 +762,24 @@ int IMG_isGIF(SDL_RWops *src) if ( !src ) return 0; - start = SDL_RWtell(src); + start = SDL_TellIO(src); is_GIF = 0; - if ( SDL_RWread(src, magic, sizeof(magic)) == sizeof(magic) ) { + if (SDL_ReadIO(src, magic, sizeof(magic)) == sizeof(magic) ) { if ( (SDL_strncmp(magic, "GIF", 3) == 0) && ((SDL_memcmp(magic + 3, "87a", 3) == 0) || (SDL_memcmp(magic + 3, "89a", 3) == 0)) ) { is_GIF = 1; } } - SDL_RWseek(src, start, SDL_RW_SEEK_SET); + SDL_SeekIO(src, start, SDL_IO_SEEK_SET); return(is_GIF); } /* Load a GIF type image from an SDL datasource */ -SDL_Surface *IMG_LoadGIF_RW(SDL_RWops *src) +SDL_Surface *IMG_LoadGIF_IO(SDL_IOStream *src) { SDL_Surface *image = NULL; - Anim_t *internal = IMG_LoadGIF_RW_Internal(src, SDL_FALSE); + Anim_t *internal = IMG_LoadGIF_IO_Internal(src, SDL_FALSE); if (internal) { image = internal->frames[0].image; SDL_free(internal->frames); @@ -794,13 +794,13 @@ SDL_Surface *IMG_LoadGIF_RW(SDL_RWops *src) #endif /* See if an image is contained in a data source */ -int IMG_isGIF(SDL_RWops *src) +int IMG_isGIF(SDL_IOStream *src) { return(0); } /* Load a GIF type image from an SDL datasource */ -SDL_Surface *IMG_LoadGIF_RW(SDL_RWops *src) +SDL_Surface *IMG_LoadGIF_IO(SDL_IOStream *src) { return(NULL); } diff --git a/src/IMG_jpg.c b/src/IMG_jpg.c index 6e78a1d5..2c66033e 100644 --- a/src/IMG_jpg.c +++ b/src/IMG_jpg.c @@ -139,7 +139,7 @@ void IMG_QuitJPG(void) } /* See if an image is contained in a data source */ -int IMG_isJPG(SDL_RWops *src) +int IMG_isJPG(SDL_IOStream *src) { Sint64 start; int is_JPG; @@ -152,21 +152,21 @@ int IMG_isJPG(SDL_RWops *src) if ( !src ) return 0; - start = SDL_RWtell(src); + start = SDL_TellIO(src); is_JPG = 0; in_scan = 0; - if (SDL_RWread(src, magic, 2) == 2) { + if (SDL_ReadIO(src, magic, 2) == 2) { if ( (magic[0] == 0xFF) && (magic[1] == 0xD8) ) { is_JPG = 1; while (is_JPG == 1) { - if(SDL_RWread(src, magic, 2) != 2) { + if(SDL_ReadIO(src, magic, 2) != 2) { is_JPG = 0; } else if( (magic[0] != 0xFF) && (in_scan == 0) ) { is_JPG = 0; } else if( (magic[0] != 0xFF) || (magic[1] == 0xFF) ) { /* Extra padding in JPEG (legal) */ /* or this is data and we are scanning */ - SDL_RWseek(src, -1, SDL_RW_SEEK_CUR); + SDL_SeekIO(src, -1, SDL_IO_SEEK_CUR); } else if(magic[1] == 0xD9) { /* Got to end of good JPEG */ break; @@ -174,16 +174,16 @@ int IMG_isJPG(SDL_RWops *src) /* This is an encoded 0xFF within the data */ } else if( (magic[1] >= 0xD0) && (magic[1] < 0xD9) ) { /* These have nothing else */ - } else if(SDL_RWread(src, magic+2, 2) != 2) { + } else if(SDL_ReadIO(src, magic+2, 2) != 2) { is_JPG = 0; } else { /* Yes, it's big-endian */ Sint64 innerStart; Uint32 size; Sint64 end; - innerStart = SDL_RWtell(src); + innerStart = SDL_TellIO(src); size = (magic[2] << 8) + magic[3]; - end = SDL_RWseek(src, size-2, SDL_RW_SEEK_CUR); + end = SDL_SeekIO(src, size-2, SDL_IO_SEEK_CUR); if ( end != innerStart + size - 2 ) is_JPG = 0; if ( magic[1] == 0xDA ) { /* Now comes the actual JPEG meat */ @@ -199,7 +199,7 @@ int IMG_isJPG(SDL_RWops *src) } } } - SDL_RWseek(src, start, SDL_RW_SEEK_SET); + SDL_SeekIO(src, start, SDL_IO_SEEK_SET); return(is_JPG); } @@ -207,7 +207,7 @@ int IMG_isJPG(SDL_RWops *src) typedef struct { struct jpeg_source_mgr pub; - SDL_RWops *ctx; + SDL_IOStream *ctx; Uint8 buffer[INPUT_BUFFER_SIZE]; } my_source_mgr; @@ -230,7 +230,7 @@ static boolean fill_input_buffer (j_decompress_ptr cinfo) my_source_mgr * src = (my_source_mgr *) cinfo->src; size_t nbytes; - nbytes = SDL_RWread(src->ctx, src->buffer, INPUT_BUFFER_SIZE); + nbytes = SDL_ReadIO(src->ctx, src->buffer, INPUT_BUFFER_SIZE); if (nbytes == 0) { /* Insert a fake EOI marker */ src->buffer[0] = (Uint8) 0xFF; @@ -292,7 +292,7 @@ static void term_source (j_decompress_ptr cinfo) * The caller must have already opened the stream, and is responsible * for closing it after finishing decompression. */ -static void jpeg_SDL_RW_src (j_decompress_ptr cinfo, SDL_RWops *ctx) +static void jpeg_SDL_IO_src (j_decompress_ptr cinfo, SDL_IOStream *ctx) { my_source_mgr *src; @@ -339,7 +339,7 @@ static void output_no_message(j_common_ptr cinfo) } /* Load a JPEG type image from an SDL datasource */ -SDL_Surface *IMG_LoadJPG_RW(SDL_RWops *src) +SDL_Surface *IMG_LoadJPG_IO(SDL_IOStream *src) { Sint64 start; struct jpeg_decompress_struct cinfo; @@ -348,10 +348,10 @@ SDL_Surface *IMG_LoadJPG_RW(SDL_RWops *src) struct my_error_mgr jerr; if ( !src ) { - /* The error message has been set in SDL_RWFromFile */ + /* The error message has been set in SDL_IOFromFile */ return NULL; } - start = SDL_RWtell(src); + start = SDL_TellIO(src); if ( (IMG_Init(IMG_INIT_JPG) & IMG_INIT_JPG) == 0 ) { return NULL; @@ -370,13 +370,13 @@ SDL_Surface *IMG_LoadJPG_RW(SDL_RWops *src) if ( surface != NULL ) { SDL_DestroySurface(surface); } - SDL_RWseek(src, start, SDL_RW_SEEK_SET); + SDL_SeekIO(src, start, SDL_IO_SEEK_SET); IMG_SetError("JPEG loading error"); return NULL; } lib.jpeg_create_decompress(&cinfo); - jpeg_SDL_RW_src(&cinfo, src); + jpeg_SDL_IO_src(&cinfo, src); lib.jpeg_read_header(&cinfo, TRUE); if(cinfo.num_components == 4) { @@ -405,7 +405,7 @@ SDL_Surface *IMG_LoadJPG_RW(SDL_RWops *src) if ( surface == NULL ) { lib.jpeg_destroy_decompress(&cinfo); - SDL_RWseek(src, start, SDL_RW_SEEK_SET); + SDL_SeekIO(src, start, SDL_IO_SEEK_SET); IMG_SetError("Out of memory"); return NULL; } @@ -427,7 +427,7 @@ SDL_Surface *IMG_LoadJPG_RW(SDL_RWops *src) typedef struct { struct jpeg_destination_mgr pub; - SDL_RWops *ctx; + SDL_IOStream *ctx; Uint8 buffer[OUTPUT_BUFFER_SIZE]; } my_destination_mgr; @@ -443,7 +443,7 @@ static boolean empty_output_buffer(j_compress_ptr cinfo) my_destination_mgr * dest = (my_destination_mgr *)cinfo->dest; /* In typical applications, it should write out the *entire* buffer */ - SDL_RWwrite(dest->ctx, dest->buffer, OUTPUT_BUFFER_SIZE); + SDL_WriteIO(dest->ctx, dest->buffer, OUTPUT_BUFFER_SIZE); dest->pub.next_output_byte = dest->buffer; dest->pub.free_in_buffer = OUTPUT_BUFFER_SIZE; @@ -455,10 +455,10 @@ static void term_destination(j_compress_ptr cinfo) my_destination_mgr * dest = (my_destination_mgr *)cinfo->dest; /* In most applications, this must flush any data remaining in the buffer */ - SDL_RWwrite(dest->ctx, dest->buffer, OUTPUT_BUFFER_SIZE - dest->pub.free_in_buffer); + SDL_WriteIO(dest->ctx, dest->buffer, OUTPUT_BUFFER_SIZE - dest->pub.free_in_buffer); } -static void jpeg_SDL_RW_dest(j_compress_ptr cinfo, SDL_RWops *ctx) +static void jpeg_SDL_IO_dest(j_compress_ptr cinfo, SDL_IOStream *ctx) { my_destination_mgr *dest; @@ -485,23 +485,23 @@ struct savejpeg_vars Sint64 original_offset; }; -static int JPEG_SaveJPEG_RW(struct savejpeg_vars *vars, SDL_Surface *jpeg_surface, SDL_RWops *dst, int quality) +static int JPEG_SaveJPEG_IO(struct savejpeg_vars *vars, SDL_Surface *jpeg_surface, SDL_IOStream *dst, int quality) { /* Create a compression structure and load the JPEG header */ vars->cinfo.err = lib.jpeg_std_error(&vars->jerr.errmgr); vars->jerr.errmgr.error_exit = my_error_exit; vars->jerr.errmgr.output_message = output_no_message; - vars->original_offset = SDL_RWtell(dst); + vars->original_offset = SDL_TellIO(dst); if(setjmp(vars->jerr.escape)) { /* If we get here, libjpeg found an error */ lib.jpeg_destroy_compress(&vars->cinfo); - SDL_RWseek(dst, vars->original_offset, SDL_RW_SEEK_SET); + SDL_SeekIO(dst, vars->original_offset, SDL_IO_SEEK_SET); return IMG_SetError("Error saving JPEG with libjpeg"); } lib.jpeg_create_compress(&vars->cinfo); - jpeg_SDL_RW_dest(&vars->cinfo, dst); + jpeg_SDL_IO_dest(&vars->cinfo, dst); vars->cinfo.image_width = jpeg_surface->w; vars->cinfo.image_height = jpeg_surface->h; @@ -525,7 +525,7 @@ static int JPEG_SaveJPEG_RW(struct savejpeg_vars *vars, SDL_Surface *jpeg_surfac return 0; } -static int IMG_SaveJPG_RW_jpeglib(SDL_Surface *surface, SDL_RWops *dst, int quality) +static int IMG_SaveJPG_IO_jpeglib(SDL_Surface *surface, SDL_IOStream *dst, int quality) { /* The JPEG library reads bytes in R,G,B order, so this is the right * encoding for either endianness */ @@ -547,7 +547,7 @@ static int IMG_SaveJPG_RW_jpeglib(SDL_Surface *surface, SDL_RWops *dst, int qual } SDL_zero(vars); - ret = JPEG_SaveJPEG_RW(&vars, jpeg_surface, dst, quality); + ret = JPEG_SaveJPEG_IO(&vars, jpeg_surface, dst, quality); if (jpeg_surface != surface) { SDL_DestroySurface(jpeg_surface); @@ -557,7 +557,7 @@ static int IMG_SaveJPG_RW_jpeglib(SDL_Surface *surface, SDL_RWops *dst, int qual #elif defined(USE_STBIMAGE) -extern SDL_Surface *IMG_LoadSTB_RW(SDL_RWops *src); +extern SDL_Surface *IMG_LoadSTB_IO(SDL_IOStream *src); int IMG_InitJPG(void) { @@ -574,7 +574,7 @@ void IMG_QuitJPG(void) /* Define this for quicker (but less perfect) JPEG identification */ #define FAST_IS_JPEG /* See if an image is contained in a data source */ -int IMG_isJPG(SDL_RWops *src) +int IMG_isJPG(SDL_IOStream *src) { Sint64 start; int is_JPG; @@ -587,21 +587,21 @@ int IMG_isJPG(SDL_RWops *src) if ( !src ) return 0; - start = SDL_RWtell(src); + start = SDL_TellIO(src); is_JPG = 0; in_scan = 0; - if ( SDL_RWread(src, magic, 2) == 2 ) { + if (SDL_ReadIO(src, magic, 2) == 2 ) { if ( (magic[0] == 0xFF) && (magic[1] == 0xD8) ) { is_JPG = 1; while (is_JPG == 1) { - if(SDL_RWread(src, magic, 2) != 2) { + if(SDL_ReadIO(src, magic, 2) != 2) { is_JPG = 0; } else if( (magic[0] != 0xFF) && (in_scan == 0) ) { is_JPG = 0; } else if( (magic[0] != 0xFF) || (magic[1] == 0xFF) ) { /* Extra padding in JPEG (legal) */ /* or this is data and we are scanning */ - SDL_RWseek(src, -1, SDL_RW_SEEK_CUR); + SDL_SeekIO(src, -1, SDL_IO_SEEK_CUR); } else if(magic[1] == 0xD9) { /* Got to end of good JPEG */ break; @@ -609,16 +609,16 @@ int IMG_isJPG(SDL_RWops *src) /* This is an encoded 0xFF within the data */ } else if( (magic[1] >= 0xD0) && (magic[1] < 0xD9) ) { /* These have nothing else */ - } else if(SDL_RWread(src, magic+2, 2) != 2) { + } else if(SDL_ReadIO(src, magic+2, 2) != 2) { is_JPG = 0; } else { /* Yes, it's big-endian */ Sint64 innerStart; Uint32 size; Sint64 end; - innerStart = SDL_RWtell(src); + innerStart = SDL_TellIO(src); size = (magic[2] << 8) + magic[3]; - end = SDL_RWseek(src, size-2, SDL_RW_SEEK_CUR); + end = SDL_SeekIO(src, size-2, SDL_IO_SEEK_CUR); if ( end != innerStart + size - 2 ) is_JPG = 0; if ( magic[1] == 0xDA ) { /* Now comes the actual JPEG meat */ @@ -634,14 +634,14 @@ int IMG_isJPG(SDL_RWops *src) } } } - SDL_RWseek(src, start, SDL_RW_SEEK_SET); + SDL_SeekIO(src, start, SDL_IO_SEEK_SET); return(is_JPG); } /* Load a JPEG type image from an SDL datasource */ -SDL_Surface *IMG_LoadJPG_RW(SDL_RWops *src) +SDL_Surface *IMG_LoadJPG_IO(SDL_IOStream *src) { - return IMG_LoadSTB_RW(src); + return IMG_LoadSTB_IO(src); } #endif /* WANT_JPEGLIB */ @@ -662,13 +662,13 @@ void IMG_QuitJPG(void) } /* See if an image is contained in a data source */ -int IMG_isJPG(SDL_RWops *src) +int IMG_isJPG(SDL_IOStream *src) { return(0); } /* Load a JPEG type image from an SDL datasource */ -SDL_Surface *IMG_LoadJPG_RW(SDL_RWops *src) +SDL_Surface *IMG_LoadJPG_IO(SDL_IOStream *src) { return(NULL); } @@ -699,12 +699,12 @@ SDL_Surface *IMG_LoadJPG_RW(SDL_RWops *src) #define TJE_IMPLEMENTATION #include "tiny_jpeg.h" -static void IMG_SaveJPG_RW_tinyjpeg_callback(void* context, void* data, int size) +static void IMG_SaveJPG_IO_tinyjpeg_callback(void* context, void* data, int size) { - SDL_RWwrite((SDL_RWops*) context, data, size); + SDL_WriteIO((SDL_IOStream*) context, data, size); } -static int IMG_SaveJPG_RW_tinyjpeg(SDL_Surface *surface, SDL_RWops *dst, int quality) +static int IMG_SaveJPG_IO_tinyjpeg(SDL_Surface *surface, SDL_IOStream *dst, int quality) { /* The JPEG library reads bytes in R,G,B order, so this is the right * encoding for either endianness */ @@ -730,7 +730,7 @@ static int IMG_SaveJPG_RW_tinyjpeg(SDL_Surface *surface, SDL_RWops *dst, int qua else quality = 3; result = tje_encode_with_func( - IMG_SaveJPG_RW_tinyjpeg_callback, + IMG_SaveJPG_IO_tinyjpeg_callback, dst, quality, jpeg_surface->w, @@ -754,15 +754,15 @@ static int IMG_SaveJPG_RW_tinyjpeg(SDL_Surface *surface, SDL_RWops *dst, int qua int IMG_SaveJPG(SDL_Surface *surface, const char *file, int quality) { - SDL_RWops *dst = SDL_RWFromFile(file, "wb"); + SDL_IOStream *dst = SDL_IOFromFile(file, "wb"); if (dst) { - return IMG_SaveJPG_RW(surface, dst, 1, quality); + return IMG_SaveJPG_IO(surface, dst, 1, quality); } else { return -1; } } -int IMG_SaveJPG_RW(SDL_Surface *surface, SDL_RWops *dst, int freedst, int quality) +int IMG_SaveJPG_IO(SDL_Surface *surface, SDL_IOStream *dst, int closeio, int quality) { int result = -1; @@ -773,13 +773,13 @@ int IMG_SaveJPG_RW(SDL_Surface *surface, SDL_RWops *dst, int freedst, int qualit #if SDL_IMAGE_SAVE_JPG #ifdef USE_JPEGLIB if (result < 0) { - result = IMG_SaveJPG_RW_jpeglib(surface, dst, quality); + result = IMG_SaveJPG_IO_jpeglib(surface, dst, quality); } #endif #if defined(LOAD_JPG_DYNAMIC) || !defined(WANT_JPEGLIB) if (result < 0) { - result = IMG_SaveJPG_RW_tinyjpeg(surface, dst, quality); + result = IMG_SaveJPG_IO_tinyjpeg(surface, dst, quality); } #endif @@ -787,8 +787,8 @@ int IMG_SaveJPG_RW(SDL_Surface *surface, SDL_RWops *dst, int freedst, int qualit result = IMG_SetError("SDL_image built without JPEG save support"); #endif - if (freedst) { - SDL_RWclose(dst); + if (closeio) { + SDL_CloseIO(dst); } return result; } diff --git a/src/IMG_jxl.c b/src/IMG_jxl.c index 3008461c..7c3e4906 100644 --- a/src/IMG_jxl.c +++ b/src/IMG_jxl.c @@ -92,7 +92,7 @@ void IMG_QuitJXL(void) } /* See if an image is contained in a data source */ -int IMG_isJXL(SDL_RWops *src) +int IMG_isJXL(SDL_IOStream *src) { Sint64 start; int is_JXL; @@ -100,14 +100,14 @@ int IMG_isJXL(SDL_RWops *src) if ( !src ) return 0; - start = SDL_RWtell(src); + start = SDL_TellIO(src); is_JXL = 0; - if ( SDL_RWread(src, magic, 2) == 2 ) { + if (SDL_ReadIO(src, magic, 2) == 2 ) { if ( magic[0] == 0xFF && magic[1] == 0x0A ) { /* This is a JXL codestream */ is_JXL = 1; } else { - if ( SDL_RWread(src, &magic[2], sizeof(magic) - 2) == (sizeof(magic) - 2) ) { + if (SDL_ReadIO(src, &magic[2], sizeof(magic) - 2) == (sizeof(magic) - 2) ) { if ( magic[0] == 0x00 && magic[1] == 0x00 && magic[2] == 0x00 && magic[3] == 0x0C && magic[4] == 'J' && magic[5] == 'X' && @@ -120,12 +120,12 @@ int IMG_isJXL(SDL_RWops *src) } } } - SDL_RWseek(src, start, SDL_RW_SEEK_SET); + SDL_SeekIO(src, start, SDL_IO_SEEK_SET); return(is_JXL); } /* Load a JXL type image from an SDL datasource */ -SDL_Surface *IMG_LoadJXL_RW(SDL_RWops *src) +SDL_Surface *IMG_LoadJXL_IO(SDL_IOStream *src) { Sint64 start; unsigned char *data; @@ -139,16 +139,16 @@ SDL_Surface *IMG_LoadJXL_RW(SDL_RWops *src) SDL_Surface *surface = NULL; if (!src) { - /* The error message has been set in SDL_RWFromFile */ + /* The error message has been set in SDL_IOFromFile */ return NULL; } - start = SDL_RWtell(src); + start = SDL_TellIO(src); if ((IMG_Init(IMG_INIT_JXL) & IMG_INIT_JXL) == 0) { return NULL; } - data = (unsigned char *)SDL_LoadFile_RW(src, &datasize, SDL_FALSE); + data = (unsigned char *)SDL_LoadFile_IO(src, &datasize, SDL_FALSE); if (!data) { return NULL; } @@ -243,7 +243,7 @@ SDL_Surface *IMG_LoadJXL_RW(SDL_RWops *src) SDL_free(pixels); } if (!surface) { - SDL_RWseek(src, start, SDL_RW_SEEK_SET); + SDL_SeekIO(src, start, SDL_IO_SEEK_SET); } return surface; } @@ -264,14 +264,14 @@ void IMG_QuitJXL(void) } /* See if an image is contained in a data source */ -int IMG_isJXL(SDL_RWops *src) +int IMG_isJXL(SDL_IOStream *src) { (void)src; return(0); } /* Load a JXL type image from an SDL datasource */ -SDL_Surface *IMG_LoadJXL_RW(SDL_RWops *src) +SDL_Surface *IMG_LoadJXL_IO(SDL_IOStream *src) { (void)src; return(NULL); diff --git a/src/IMG_lbm.c b/src/IMG_lbm.c index 9d608c08..496c27b3 100644 --- a/src/IMG_lbm.c +++ b/src/IMG_lbm.c @@ -56,7 +56,7 @@ typedef struct Sint16 Hpage; /* height of the screen in pixels */ } BMHD; -int IMG_isLBM( SDL_RWops *src ) +int IMG_isLBM(SDL_IOStream *src ) { Sint64 start; int is_LBM; @@ -64,9 +64,9 @@ int IMG_isLBM( SDL_RWops *src ) if ( !src ) return 0; - start = SDL_RWtell(src); + start = SDL_TellIO(src); is_LBM = 0; - if ( SDL_RWread( src, magic, sizeof(magic) ) == sizeof(magic) ) + if (SDL_ReadIO( src, magic, sizeof(magic) ) == sizeof(magic) ) { if ( !SDL_memcmp( magic, "FORM", 4 ) && ( !SDL_memcmp( magic + 8, "PBM ", 4 ) || @@ -75,11 +75,11 @@ int IMG_isLBM( SDL_RWops *src ) is_LBM = 1; } } - SDL_RWseek(src, start, SDL_RW_SEEK_SET); + SDL_SeekIO(src, start, SDL_IO_SEEK_SET); return( is_LBM ); } -SDL_Surface *IMG_LoadLBM_RW( SDL_RWops *src ) +SDL_Surface *IMG_LoadLBM_IO(SDL_IOStream *src ) { Sint64 start; SDL_Surface *Image; @@ -97,19 +97,19 @@ SDL_Surface *IMG_LoadLBM_RW( SDL_RWops *src ) MiniBuf = NULL; if ( !src ) { - /* The error message has been set in SDL_RWFromFile */ + /* The error message has been set in SDL_IOFromFile */ return NULL; } - start = SDL_RWtell(src); + start = SDL_TellIO(src); - if ( SDL_RWread( src, id, 4 ) != 4 ) + if (SDL_ReadIO( src, id, 4 ) != 4 ) { error="error reading IFF chunk"; goto done; } /* Should be the size of the file minus 4+4 ( 'FORM'+size ) */ - if ( SDL_RWread( src, &size, 4 ) != 4 ) + if (SDL_ReadIO( src, &size, 4 ) != 4 ) { error="error reading IFF chunk size"; goto done; @@ -123,7 +123,7 @@ SDL_Surface *IMG_LoadLBM_RW( SDL_RWops *src ) goto done; } - if ( SDL_RWread( src, id, 4 ) != 4 ) + if (SDL_ReadIO( src, id, 4 ) != 4 ) { error="error reading IFF chunk"; goto done; @@ -147,13 +147,13 @@ SDL_Surface *IMG_LoadLBM_RW( SDL_RWops *src ) while ( SDL_memcmp( id, "BODY", 4 ) != 0 ) { - if ( SDL_RWread( src, id, 4 ) != 4 ) + if (SDL_ReadIO( src, id, 4 ) != 4 ) { error="error reading IFF chunk"; goto done; } - if ( SDL_RWread( src, &size, 4 ) != 4 ) + if (SDL_ReadIO( src, &size, 4 ) != 4 ) { error="error reading IFF chunk size"; goto done; @@ -165,7 +165,7 @@ SDL_Surface *IMG_LoadLBM_RW( SDL_RWops *src ) if ( !SDL_memcmp( id, "BMHD", 4 ) ) /* Bitmap header */ { - if ( SDL_RWread( src, &bmhd, sizeof( BMHD ) ) != sizeof( BMHD ) ) + if (SDL_ReadIO( src, &bmhd, sizeof( BMHD ) ) != sizeof( BMHD ) ) { error="error reading BMHD chunk"; goto done; @@ -189,7 +189,7 @@ SDL_Surface *IMG_LoadLBM_RW( SDL_RWops *src ) goto done; } - if ( SDL_RWread( src, colormap, size ) != size ) + if (SDL_ReadIO( src, colormap, size ) != size ) { error="error reading CMAP chunk"; goto done; @@ -202,7 +202,7 @@ SDL_Surface *IMG_LoadLBM_RW( SDL_RWops *src ) if ( !SDL_memcmp( id, "CAMG", 4 ) ) /* Amiga ViewMode */ { Uint32 viewmodes; - if ( SDL_RWread( src, &viewmodes, sizeof(viewmodes) ) != sizeof(viewmodes) ) + if (SDL_ReadIO( src, &viewmodes, sizeof(viewmodes) ) != sizeof(viewmodes) ) { error="error reading CAMG chunk"; goto done; @@ -221,7 +221,7 @@ SDL_Surface *IMG_LoadLBM_RW( SDL_RWops *src ) if ( size & 1 ) ++size; /* padding ! */ size -= bytesloaded; /* skip the remaining bytes of this chunk */ - if ( size ) SDL_RWseek( src, size, SDL_RW_SEEK_CUR ); + if ( size ) SDL_SeekIO( src, size, SDL_IO_SEEK_CUR ); } } @@ -332,7 +332,7 @@ SDL_Surface *IMG_LoadLBM_RW( SDL_RWops *src ) { do { - if ( SDL_RWread( src, &count, 1 ) != 1 ) + if (SDL_ReadIO( src, &count, 1 ) != 1 ) { error="error reading BODY chunk"; goto done; @@ -343,7 +343,7 @@ SDL_Surface *IMG_LoadLBM_RW( SDL_RWops *src ) count ^= 0xFF; count += 2; /* now it */ - if ( ( count > remainingbytes ) || SDL_RWread( src, &color, 1 ) != 1 ) + if ( ( count > remainingbytes ) || SDL_ReadIO( src, &color, 1 ) != 1 ) { error="error reading BODY chunk"; goto done; @@ -354,7 +354,7 @@ SDL_Surface *IMG_LoadLBM_RW( SDL_RWops *src ) { ++count; - if ( ( count > remainingbytes ) || SDL_RWread( src, ptr, count ) != count ) + if ( ( count > remainingbytes ) || SDL_ReadIO( src, ptr, count ) != count ) { error="error reading BODY chunk"; goto done; @@ -368,7 +368,7 @@ SDL_Surface *IMG_LoadLBM_RW( SDL_RWops *src ) } else { - if ( SDL_RWread( src, ptr, bytesperline ) != bytesperline ) + if (SDL_ReadIO( src, ptr, bytesperline ) != bytesperline ) { error="error reading BODY chunk"; goto done; @@ -484,7 +484,7 @@ SDL_Surface *IMG_LoadLBM_RW( SDL_RWops *src ) if ( error ) { - SDL_RWseek(src, start, SDL_RW_SEEK_SET); + SDL_SeekIO(src, start, SDL_IO_SEEK_SET); if ( Image ) { SDL_DestroySurface( Image ); Image = NULL; @@ -501,13 +501,13 @@ SDL_Surface *IMG_LoadLBM_RW( SDL_RWops *src ) #endif /* See if an image is contained in a data source */ -int IMG_isLBM(SDL_RWops *src) +int IMG_isLBM(SDL_IOStream *src) { return(0); } /* Load an IFF type image from an SDL datasource */ -SDL_Surface *IMG_LoadLBM_RW(SDL_RWops *src) +SDL_Surface *IMG_LoadLBM_IO(SDL_IOStream *src) { return(NULL); } diff --git a/src/IMG_pcx.c b/src/IMG_pcx.c index beea62a4..bc6e10cf 100644 --- a/src/IMG_pcx.c +++ b/src/IMG_pcx.c @@ -58,7 +58,7 @@ struct PCXheader { }; /* See if an image is contained in a data source */ -int IMG_isPCX(SDL_RWops *src) +int IMG_isPCX(SDL_IOStream *src) { Sint64 start; int is_PCX; @@ -70,9 +70,9 @@ int IMG_isPCX(SDL_RWops *src) if ( !src ) return 0; - start = SDL_RWtell(src); + start = SDL_TellIO(src); is_PCX = 0; - if ( SDL_RWread(src, &pcxh, sizeof(pcxh)) == sizeof(pcxh) ) { + if (SDL_ReadIO(src, &pcxh, sizeof(pcxh)) == sizeof(pcxh) ) { if ( (pcxh.Manufacturer == ZSoft_Manufacturer) && (pcxh.Version == PC_Paintbrush_Version) && (pcxh.Encoding == PCX_RunLength_Encoding || @@ -80,12 +80,12 @@ int IMG_isPCX(SDL_RWops *src) is_PCX = 1; } } - SDL_RWseek(src, start, SDL_RW_SEEK_SET); + SDL_SeekIO(src, start, SDL_IO_SEEK_SET); return(is_PCX); } /* Load a PCX type image from an SDL datasource */ -SDL_Surface *IMG_LoadPCX_RW(SDL_RWops *src) +SDL_Surface *IMG_LoadPCX_IO(SDL_IOStream *src) { Sint64 start; struct PCXheader pcxh; @@ -101,12 +101,12 @@ SDL_Surface *IMG_LoadPCX_RW(SDL_RWops *src) Uint32 format; if ( !src ) { - /* The error message has been set in SDL_RWFromFile */ + /* The error message has been set in SDL_IOFromFile */ return NULL; } - start = SDL_RWtell(src); + start = SDL_TellIO(src); - if ( SDL_RWread(src, &pcxh, sizeof(pcxh)) != sizeof(pcxh) ) { + if (SDL_ReadIO(src, &pcxh, sizeof(pcxh)) != sizeof(pcxh) ) { error = "file truncated"; goto done; } @@ -161,7 +161,7 @@ SDL_Surface *IMG_LoadPCX_RW(SDL_RWops *src) /* decode a scan line to a temporary buffer first */ size_t i; if ( pcxh.Encoding == 0 ) { - if ( SDL_RWread(src, buf, bpl) != bpl ) { + if (SDL_ReadIO(src, buf, bpl) != bpl ) { error = "file truncated"; goto done; } @@ -169,7 +169,7 @@ SDL_Surface *IMG_LoadPCX_RW(SDL_RWops *src) for ( i = 0; i < bpl; i++ ) { if ( !count ) { - if ( SDL_RWread(src, &ch, 1) != 1 ) { + if (SDL_ReadIO(src, &ch, 1) != 1 ) { error = "file truncated"; goto done; } @@ -177,7 +177,7 @@ SDL_Surface *IMG_LoadPCX_RW(SDL_RWops *src) count = 1; } else { count = ch - 0xc0; - if ( SDL_RWread(src, &ch, 1) != 1 ) { + if (SDL_ReadIO(src, &ch, 1) != 1 ) { error = "file truncated"; goto done; } @@ -244,14 +244,14 @@ SDL_Surface *IMG_LoadPCX_RW(SDL_RWops *src) /* look for a 256-colour palette */ do { - if ( SDL_RWread(src, &pch, 1) != 1 ) { + if (SDL_ReadIO(src, &pch, 1) != 1 ) { /* Couldn't find the palette, try the end of the file */ - SDL_RWseek(src, -768, SDL_RW_SEEK_END); + SDL_SeekIO(src, -768, SDL_IO_SEEK_END); break; } } while ( pch != 12 ); - if ( SDL_RWread(src, colormap, sizeof(colormap)) != sizeof(colormap) ) { + if (SDL_ReadIO(src, colormap, sizeof(colormap)) != sizeof(colormap) ) { error = "file truncated"; goto done; } @@ -272,7 +272,7 @@ SDL_Surface *IMG_LoadPCX_RW(SDL_RWops *src) done: SDL_free(buf); if ( error ) { - SDL_RWseek(src, start, SDL_RW_SEEK_SET); + SDL_SeekIO(src, start, SDL_IO_SEEK_SET); if ( surface ) { SDL_DestroySurface(surface); surface = NULL; @@ -288,13 +288,13 @@ SDL_Surface *IMG_LoadPCX_RW(SDL_RWops *src) #endif /* See if an image is contained in a data source */ -int IMG_isPCX(SDL_RWops *src) +int IMG_isPCX(SDL_IOStream *src) { return(0); } /* Load a PCX type image from an SDL datasource */ -SDL_Surface *IMG_LoadPCX_RW(SDL_RWops *src) +SDL_Surface *IMG_LoadPCX_IO(SDL_IOStream *src) { return(NULL); } diff --git a/src/IMG_png.c b/src/IMG_png.c index 3bfbec5a..a9ff5441 100644 --- a/src/IMG_png.c +++ b/src/IMG_png.c @@ -201,7 +201,7 @@ void IMG_QuitPNG(void) } /* See if an image is contained in a data source */ -int IMG_isPNG(SDL_RWops *src) +int IMG_isPNG(SDL_IOStream *src) { Sint64 start; int is_PNG; @@ -211,9 +211,9 @@ int IMG_isPNG(SDL_RWops *src) return 0; } - start = SDL_RWtell(src); + start = SDL_TellIO(src); is_PNG = 0; - if ( SDL_RWread(src, magic, sizeof(magic)) == sizeof(magic) ) { + if (SDL_ReadIO(src, magic, sizeof(magic)) == sizeof(magic) ) { if ( magic[0] == 0x89 && magic[1] == 'P' && magic[2] == 'N' && @@ -221,17 +221,17 @@ int IMG_isPNG(SDL_RWops *src) is_PNG = 1; } } - SDL_RWseek(src, start, SDL_RW_SEEK_SET); + SDL_SeekIO(src, start, SDL_IO_SEEK_SET); return(is_PNG); } /* Load a PNG type image from an SDL datasource */ static void png_read_data(png_structp ctx, png_bytep area, png_size_t size) { - SDL_RWops *src; + SDL_IOStream *src; - src = (SDL_RWops *)lib.png_get_io_ptr(ctx); - SDL_RWread(src, area, size); + src = (SDL_IOStream *)lib.png_get_io_ptr(ctx); + SDL_ReadIO(src, area, size); } struct loadpng_vars { @@ -242,7 +242,7 @@ struct loadpng_vars { png_bytep *row_pointers; }; -static void LIBPNG_LoadPNG_RW(SDL_RWops *src, struct loadpng_vars *vars) +static void LIBPNG_LoadPNG_IO(SDL_IOStream *src, struct loadpng_vars *vars) { png_uint_32 width, height; int bit_depth, color_type, interlace_type, num_channels; @@ -448,13 +448,13 @@ static void LIBPNG_LoadPNG_RW(SDL_RWops *src, struct loadpng_vars *vars) } } -SDL_Surface *IMG_LoadPNG_RW(SDL_RWops *src) +SDL_Surface *IMG_LoadPNG_IO(SDL_IOStream *src) { Sint64 start; struct loadpng_vars vars; if ( !src ) { - /* The error message has been set in SDL_RWFromFile */ + /* The error message has been set in SDL_IOFromFile */ return NULL; } @@ -462,10 +462,10 @@ SDL_Surface *IMG_LoadPNG_RW(SDL_RWops *src) return NULL; } - start = SDL_RWtell(src); + start = SDL_TellIO(src); SDL_zero(vars); - LIBPNG_LoadPNG_RW(src, &vars); + LIBPNG_LoadPNG_IO(src, &vars); if (vars.png_ptr) { lib.png_destroy_read_struct(&vars.png_ptr, @@ -476,7 +476,7 @@ SDL_Surface *IMG_LoadPNG_RW(SDL_RWops *src) SDL_free(vars.row_pointers); } if (vars.error) { - SDL_RWseek(src, start, SDL_RW_SEEK_SET); + SDL_SeekIO(src, start, SDL_IO_SEEK_SET); if (vars.surface) { SDL_DestroySurface(vars.surface); vars.surface = NULL; @@ -489,7 +489,7 @@ SDL_Surface *IMG_LoadPNG_RW(SDL_RWops *src) #elif defined(USE_STBIMAGE) -extern SDL_Surface *IMG_LoadSTB_RW(SDL_RWops *src); +extern SDL_Surface *IMG_LoadSTB_IO(SDL_IOStream *src); int IMG_InitPNG(void) { @@ -504,7 +504,7 @@ void IMG_QuitPNG(void) /* FIXME: This is a copypaste from LIBPNG! Pull that out of the ifdefs */ /* See if an image is contained in a data source */ -int IMG_isPNG(SDL_RWops *src) +int IMG_isPNG(SDL_IOStream *src) { Sint64 start; int is_PNG; @@ -514,9 +514,9 @@ int IMG_isPNG(SDL_RWops *src) return 0; } - start = SDL_RWtell(src); + start = SDL_TellIO(src); is_PNG = 0; - if ( SDL_RWread(src, magic, sizeof(magic)) == sizeof(magic) ) { + if (SDL_ReadIO(src, magic, sizeof(magic)) == sizeof(magic) ) { if ( magic[0] == 0x89 && magic[1] == 'P' && magic[2] == 'N' && @@ -524,14 +524,14 @@ int IMG_isPNG(SDL_RWops *src) is_PNG = 1; } } - SDL_RWseek(src, start, SDL_RW_SEEK_SET); + SDL_SeekIO(src, start, SDL_IO_SEEK_SET); return(is_PNG); } /* Load a PNG type image from an SDL datasource */ -SDL_Surface *IMG_LoadPNG_RW(SDL_RWops *src) +SDL_Surface *IMG_LoadPNG_IO(SDL_IOStream *src) { - return IMG_LoadSTB_RW(src); + return IMG_LoadSTB_IO(src); } #endif /* WANT_LIBPNG */ @@ -552,13 +552,13 @@ void IMG_QuitPNG(void) } /* See if an image is contained in a data source */ -int IMG_isPNG(SDL_RWops *src) +int IMG_isPNG(SDL_IOStream *src) { return(0); } /* Load a PNG type image from an SDL datasource */ -SDL_Surface *IMG_LoadPNG_RW(SDL_RWops *src) +SDL_Surface *IMG_LoadPNG_IO(SDL_IOStream *src) { return(NULL); } @@ -573,8 +573,8 @@ static const Uint32 png_format = SDL_PIXELFORMAT_RGBA32; static void png_write_data(png_structp png_ptr, png_bytep src, png_size_t size) { - SDL_RWops *dst = (SDL_RWops *)lib.png_get_io_ptr(png_ptr); - SDL_RWwrite(dst, src, size); + SDL_IOStream *dst = (SDL_IOStream *)lib.png_get_io_ptr(png_ptr); + SDL_WriteIO(dst, src, size); } static void png_flush_data(png_structp png_ptr) @@ -591,7 +591,7 @@ struct savepng_vars { SDL_Surface *source; }; -static int LIBPNG_SavePNG_RW(struct savepng_vars *vars, SDL_Surface *surface, SDL_RWops *dst) +static int LIBPNG_SavePNG_IO(struct savepng_vars *vars, SDL_Surface *surface, SDL_IOStream *dst) { Uint8 transparent_table[256]; SDL_Palette *palette; @@ -693,7 +693,7 @@ static int LIBPNG_SavePNG_RW(struct savepng_vars *vars, SDL_Surface *surface, SD return 0; } -static int IMG_SavePNG_RW_libpng(SDL_Surface *surface, SDL_RWops *dst) +static int IMG_SavePNG_IO_libpng(SDL_Surface *surface, SDL_IOStream *dst) { struct savepng_vars vars; int ret; @@ -703,7 +703,7 @@ static int IMG_SavePNG_RW_libpng(SDL_Surface *surface, SDL_RWops *dst) } SDL_zero(vars); - ret = LIBPNG_SavePNG_RW(&vars, surface, dst); + ret = LIBPNG_SavePNG_IO(&vars, surface, dst); if (vars.png_ptr) { lib.png_destroy_write_struct(&vars.png_ptr, &vars.info_ptr); @@ -749,7 +749,7 @@ static int IMG_SavePNG_RW_libpng(SDL_Surface *surface, SDL_RWops *dst) #define MINIZ_SDL_NOUNUSED #include "miniz.h" -static int IMG_SavePNG_RW_miniz(SDL_Surface *surface, SDL_RWops *dst) +static int IMG_SavePNG_IO_miniz(SDL_Surface *surface, SDL_IOStream *dst) { size_t size = 0; void *png = NULL; @@ -769,7 +769,7 @@ static int IMG_SavePNG_RW_miniz(SDL_Surface *surface, SDL_RWops *dst) } } if (png) { - if (SDL_RWwrite(dst, png, size)) { + if (SDL_WriteIO(dst, png, size)) { result = 0; } mz_free(png); /* calls SDL_free() */ @@ -784,15 +784,15 @@ static int IMG_SavePNG_RW_miniz(SDL_Surface *surface, SDL_RWops *dst) int IMG_SavePNG(SDL_Surface *surface, const char *file) { - SDL_RWops *dst = SDL_RWFromFile(file, "wb"); + SDL_IOStream *dst = SDL_IOFromFile(file, "wb"); if (dst) { - return IMG_SavePNG_RW(surface, dst, 1); + return IMG_SavePNG_IO(surface, dst, 1); } else { return -1; } } -int IMG_SavePNG_RW(SDL_Surface *surface, SDL_RWops *dst, int freedst) +int IMG_SavePNG_IO(SDL_Surface *surface, SDL_IOStream *dst, int closeio) { int result = -1; @@ -803,13 +803,13 @@ int IMG_SavePNG_RW(SDL_Surface *surface, SDL_RWops *dst, int freedst) #if SDL_IMAGE_SAVE_PNG #ifdef USE_LIBPNG if (result < 0) { - result = IMG_SavePNG_RW_libpng(surface, dst); + result = IMG_SavePNG_IO_libpng(surface, dst); } #endif #if defined(LOAD_PNG_DYNAMIC) || !defined(WANT_LIBPNG) if (result < 0) { - result = IMG_SavePNG_RW_miniz(surface, dst); + result = IMG_SavePNG_IO_miniz(surface, dst); } #endif @@ -817,8 +817,8 @@ int IMG_SavePNG_RW(SDL_Surface *surface, SDL_RWops *dst, int freedst) result = IMG_SetError("SDL_image built without PNG save support"); #endif - if (freedst) { - SDL_RWclose(dst); + if (closeio) { + SDL_CloseIO(dst); } return result; } diff --git a/src/IMG_pnm.c b/src/IMG_pnm.c index 08dc7206..f4531508 100644 --- a/src/IMG_pnm.c +++ b/src/IMG_pnm.c @@ -33,7 +33,7 @@ #ifdef LOAD_PNM /* See if an image is contained in a data source */ -int IMG_isPNM(SDL_RWops *src) +int IMG_isPNM(SDL_IOStream *src) { Sint64 start; int is_PNM; @@ -41,9 +41,9 @@ int IMG_isPNM(SDL_RWops *src) if ( !src ) return 0; - start = SDL_RWtell(src); + start = SDL_TellIO(src); is_PNM = 0; - if ( SDL_RWread(src, magic, sizeof(magic)) == sizeof(magic) ) { + if (SDL_ReadIO(src, magic, sizeof(magic)) == sizeof(magic) ) { /* * PNM magic signatures: * P1 PBM, ascii format @@ -58,12 +58,12 @@ int IMG_isPNM(SDL_RWops *src) is_PNM = 1; } } - SDL_RWseek(src, start, SDL_RW_SEEK_SET); + SDL_SeekIO(src, start, SDL_IO_SEEK_SET); return(is_PNM); } /* read a non-negative integer from the source. return -1 upon error */ -static int ReadNumber(SDL_RWops *src) +static int ReadNumber(SDL_IOStream *src) { int number; unsigned char ch; @@ -73,13 +73,13 @@ static int ReadNumber(SDL_RWops *src) /* Skip leading whitespace */ do { - if ( SDL_RWread(src, &ch, 1) != 1 ) { + if (SDL_ReadIO(src, &ch, 1) != 1 ) { return(-1); } /* Eat comments as whitespace */ if ( ch == '#' ) { /* Comment is '#' to end of line */ do { - if ( SDL_RWread(src, &ch, 1) != 1 ) { + if (SDL_ReadIO(src, &ch, 1) != 1 ) { return -1; } } while ( (ch != '\r') && (ch != '\n') ); @@ -98,7 +98,7 @@ static int ReadNumber(SDL_RWops *src) number *= 10; number += ch-'0'; - if ( SDL_RWread(src, &ch, 1) != 1 ) { + if (SDL_ReadIO(src, &ch, 1) != 1 ) { return -1; } } while ( SDL_isdigit(ch) ); @@ -106,7 +106,7 @@ static int ReadNumber(SDL_RWops *src) return(number); } -SDL_Surface *IMG_LoadPNM_RW(SDL_RWops *src) +SDL_Surface *IMG_LoadPNM_IO(SDL_IOStream *src) { Sint64 start; SDL_Surface *surface = NULL; @@ -123,12 +123,12 @@ SDL_Surface *IMG_LoadPNM_RW(SDL_RWops *src) #define ERROR(s) do { error = (s); goto done; } while(0) if ( !src ) { - /* The error message has been set in SDL_RWFromFile */ + /* The error message has been set in SDL_IOFromFile */ return NULL; } - start = SDL_RWtell(src); + start = SDL_TellIO(src); - if ( SDL_RWread(src, magic, 2) != 2 ) { + if (SDL_ReadIO(src, magic, 2) != 2 ) { return NULL; } kind = magic[1] - '1'; @@ -190,7 +190,7 @@ SDL_Surface *IMG_LoadPNM_RW(SDL_RWops *src) for(i = 0; i < width; i++) { Uint8 ch; do { - if(SDL_RWread(src, &ch, 1) != 1) + if(SDL_ReadIO(src, &ch, 1) != 1) ERROR("file truncated"); ch -= '0'; } while(ch > 1); @@ -208,7 +208,7 @@ SDL_Surface *IMG_LoadPNM_RW(SDL_RWops *src) } } else { Uint8 *dst = (kind == PBM) ? buf : row; - if(SDL_RWread(src, dst, bpl) != bpl) + if(SDL_ReadIO(src, dst, bpl) != bpl) ERROR("file truncated"); if(kind == PBM) { /* expand bitmap to 8bpp */ @@ -230,7 +230,7 @@ SDL_Surface *IMG_LoadPNM_RW(SDL_RWops *src) done: SDL_free(buf); if(error) { - SDL_RWseek(src, start, SDL_RW_SEEK_SET); + SDL_SeekIO(src, start, SDL_IO_SEEK_SET); if ( surface ) { SDL_DestroySurface(surface); surface = NULL; @@ -246,13 +246,13 @@ SDL_Surface *IMG_LoadPNM_RW(SDL_RWops *src) #endif /* See if an image is contained in a data source */ -int IMG_isPNM(SDL_RWops *src) +int IMG_isPNM(SDL_IOStream *src) { return(0); } /* Load a PNM type image from an SDL datasource */ -SDL_Surface *IMG_LoadPNM_RW(SDL_RWops *src) +SDL_Surface *IMG_LoadPNM_IO(SDL_IOStream *src) { return(NULL); } diff --git a/src/IMG_qoi.c b/src/IMG_qoi.c index 8fd640af..340d9920 100644 --- a/src/IMG_qoi.c +++ b/src/IMG_qoi.c @@ -43,7 +43,7 @@ #include "qoi.h" /* See if an image is contained in a data source */ -int IMG_isQOI(SDL_RWops *src) +int IMG_isQOI(SDL_IOStream *src) { Sint64 start; int is_QOI; @@ -51,19 +51,19 @@ int IMG_isQOI(SDL_RWops *src) if ( !src ) return 0; - start = SDL_RWtell(src); + start = SDL_TellIO(src); is_QOI = 0; - if ( SDL_RWread(src, magic, sizeof(magic)) == sizeof(magic) ) { + if (SDL_ReadIO(src, magic, sizeof(magic)) == sizeof(magic) ) { if ( SDL_strncmp(magic, "qoif", 4) == 0 ) { is_QOI = 1; } } - SDL_RWseek(src, start, SDL_RW_SEEK_SET); + SDL_SeekIO(src, start, SDL_IO_SEEK_SET); return(is_QOI); } /* Load a QOI type image from an SDL datasource */ -SDL_Surface *IMG_LoadQOI_RW(SDL_RWops *src) +SDL_Surface *IMG_LoadQOI_IO(SDL_IOStream *src) { void *data; size_t size; @@ -71,7 +71,7 @@ SDL_Surface *IMG_LoadQOI_RW(SDL_RWops *src) qoi_desc image_info; SDL_Surface *surface = NULL; - data = (void *)SDL_LoadFile_RW(src, &size, SDL_FALSE); + data = (void *)SDL_LoadFile_IO(src, &size, SDL_FALSE); if ( !data ) { return NULL; } @@ -112,13 +112,13 @@ SDL_Surface *IMG_LoadQOI_RW(SDL_RWops *src) #endif /* See if an image is contained in a data source */ -int IMG_isQOI(SDL_RWops *src) +int IMG_isQOI(SDL_IOStream *src) { return(0); } /* Load a QOI type image from an SDL datasource */ -SDL_Surface *IMG_LoadQOI_RW(SDL_RWops *src) +SDL_Surface *IMG_LoadQOI_IO(SDL_IOStream *src) { return(NULL); } diff --git a/src/IMG_stb.c b/src/IMG_stb.c index 243c9c38..ecfeda97 100644 --- a/src/IMG_stb.c +++ b/src/IMG_stb.c @@ -57,24 +57,24 @@ #define STB_IMAGE_IMPLEMENTATION #include "stb_image.h" -static int IMG_LoadSTB_RW_read(void *user, char *data, int size) +static int IMG_LoadSTB_IO_read(void *user, char *data, int size) { - size_t amount = SDL_RWread((SDL_RWops*)user, data, size); + size_t amount = SDL_ReadIO((SDL_IOStream*)user, data, size); return (int)amount; } -static void IMG_LoadSTB_RW_skip(void *user, int n) +static void IMG_LoadSTB_IO_skip(void *user, int n) { - SDL_RWseek((SDL_RWops*)user, n, SDL_RW_SEEK_CUR); + SDL_SeekIO((SDL_IOStream*)user, n, SDL_IO_SEEK_CUR); } -static int IMG_LoadSTB_RW_eof(void *user) +static int IMG_LoadSTB_IO_eof(void *user) { - SDL_RWops *src = (SDL_RWops*)user; - return (src->status == SDL_RWOPS_STATUS_EOF); + SDL_IOStream *src = (SDL_IOStream*)user; + return (SDL_GetIOStatus(src) == SDL_IO_STATUS_EOF); } -SDL_Surface *IMG_LoadSTB_RW(SDL_RWops *src) +SDL_Surface *IMG_LoadSTB_IO(SDL_IOStream *src) { Sint64 start; Uint8 magic[26]; @@ -86,12 +86,12 @@ SDL_Surface *IMG_LoadSTB_RW(SDL_RWops *src) unsigned int palette_colors[256]; if (!src) { - /* The error message has been set in SDL_RWFromFile */ + /* The error message has been set in SDL_IOFromFile */ return NULL; } - start = SDL_RWtell(src); + start = SDL_TellIO(src); - if (SDL_RWread(src, magic, sizeof(magic)) == sizeof(magic)) { + if (SDL_ReadIO(src, magic, sizeof(magic)) == sizeof(magic)) { const Uint8 PNG_COLOR_INDEXED = 3; if (magic[0] == 0x89 && magic[1] == 'P' && @@ -105,12 +105,12 @@ SDL_Surface *IMG_LoadSTB_RW(SDL_RWops *src) use_palette = SDL_TRUE; } } - SDL_RWseek(src, start, SDL_RW_SEEK_SET); + SDL_SeekIO(src, start, SDL_IO_SEEK_SET); /* Load the image data */ - rw_callbacks.read = IMG_LoadSTB_RW_read; - rw_callbacks.skip = IMG_LoadSTB_RW_skip; - rw_callbacks.eof = IMG_LoadSTB_RW_eof; + rw_callbacks.read = IMG_LoadSTB_IO_read; + rw_callbacks.skip = IMG_LoadSTB_IO_skip; + rw_callbacks.eof = IMG_LoadSTB_IO_eof; w = h = format = 0; /* silence warning */ if (use_palette) { /* Unused palette entries will be opaque white */ @@ -135,7 +135,7 @@ SDL_Surface *IMG_LoadSTB_RW(SDL_RWops *src) ); } if (!pixels) { - SDL_RWseek(src, start, SDL_RW_SEEK_SET); + SDL_SeekIO(src, start, SDL_IO_SEEK_SET); return NULL; } @@ -245,7 +245,7 @@ SDL_Surface *IMG_LoadSTB_RW(SDL_RWops *src) if (!surface) { /* The error message should already be set */ stbi_image_free(pixels); /* calls SDL_free() */ - SDL_RWseek(src, start, SDL_RW_SEEK_SET); + SDL_SeekIO(src, start, SDL_IO_SEEK_SET); } return surface; } diff --git a/src/IMG_svg.c b/src/IMG_svg.c index 9b2470e9..535bb47e 100644 --- a/src/IMG_svg.c +++ b/src/IMG_svg.c @@ -85,7 +85,7 @@ static float SDLCALL SDL_roundf(float x) #include "nanosvgrast.h" /* See if an image is contained in a data source */ -int IMG_isSVG(SDL_RWops *src) +int IMG_isSVG(SDL_IOStream *src) { Sint64 start; int is_SVG; @@ -94,21 +94,21 @@ int IMG_isSVG(SDL_RWops *src) if (!src) return 0; - start = SDL_RWtell(src); + start = SDL_TellIO(src); is_SVG = 0; - magic_len = SDL_RWread(src, magic, sizeof(magic) - 1); + magic_len = SDL_ReadIO(src, magic, sizeof(magic) - 1); if (magic_len > 0) { magic[magic_len] = '\0'; if (SDL_strstr(magic, "> 8) /* Load a TGA type image from an SDL datasource */ -SDL_Surface *IMG_LoadTGA_RW(SDL_RWops *src) +SDL_Surface *IMG_LoadTGA_IO(SDL_IOStream *src) { Sint64 start; const char *error = NULL; @@ -102,12 +102,12 @@ SDL_Surface *IMG_LoadTGA_RW(SDL_RWops *src) int count, rep; if ( !src ) { - /* The error message has been set in SDL_RWFromFile */ + /* The error message has been set in SDL_IOFromFile */ return NULL; } - start = SDL_RWtell(src); + start = SDL_TellIO(src); - if (SDL_RWread(src, &hdr, sizeof(hdr)) != sizeof(hdr)) { + if (SDL_ReadIO(src, &hdr, sizeof(hdr)) != sizeof(hdr)) { error = "Error reading TGA data"; goto error; } @@ -175,7 +175,7 @@ SDL_Surface *IMG_LoadTGA_RW(SDL_RWops *src) goto unsupported; } - SDL_RWseek(src, hdr.infolen, SDL_RW_SEEK_CUR); /* skip info field */ + SDL_SeekIO(src, hdr.infolen, SDL_IO_SEEK_CUR); /* skip info field */ w = LE16(hdr.width); h = LE16(hdr.height); @@ -191,7 +191,7 @@ SDL_Surface *IMG_LoadTGA_RW(SDL_RWops *src) Uint8 *pal = (Uint8 *)SDL_malloc(palsiz), *p = pal; SDL_Color *colors = img->format->palette->colors; img->format->palette->ncolors = ncols; - if (SDL_RWread(src, pal, palsiz) != palsiz) { + if (SDL_ReadIO(src, pal, palsiz) != palsiz) { error = "Error reading TGA data"; goto error; } @@ -222,7 +222,7 @@ SDL_Surface *IMG_LoadTGA_RW(SDL_RWops *src) SDL_SetSurfaceColorKey(img, SDL_TRUE, ckey); } else { /* skip unneeded colormap */ - SDL_RWseek(src, palsiz, SDL_RW_SEEK_CUR); + SDL_SeekIO(src, palsiz, SDL_IO_SEEK_CUR); } } @@ -254,7 +254,7 @@ SDL_Surface *IMG_LoadTGA_RW(SDL_RWops *src) int n = count; if (n > w - x) n = w - x; - if (SDL_RWread(src, dst + x * bpp, n * bpp) != (size_t)(n * bpp)) { + if (SDL_ReadIO(src, dst + x * bpp, n * bpp) != (size_t)(n * bpp)) { error = "Error reading TGA data"; goto error; } @@ -275,12 +275,12 @@ SDL_Surface *IMG_LoadTGA_RW(SDL_RWops *src) break; } - if (SDL_RWread(src, &c, 1) != 1) { + if (SDL_ReadIO(src, &c, 1) != 1) { error = "Error reading TGA data"; goto error; } if (c & 0x80) { - if (SDL_RWread(src, &pixel, bpp) != (size_t)bpp) { + if (SDL_ReadIO(src, &pixel, bpp) != (size_t)bpp) { error = "Error reading TGA data"; goto error; } @@ -290,7 +290,7 @@ SDL_Surface *IMG_LoadTGA_RW(SDL_RWops *src) } } } else { - if (SDL_RWread(src, dst, w * bpp) != (size_t)(w * bpp)) { + if (SDL_ReadIO(src, dst, w * bpp) != (size_t)(w * bpp)) { error = "Error reading TGA data"; goto error; } @@ -312,7 +312,7 @@ SDL_Surface *IMG_LoadTGA_RW(SDL_RWops *src) error = "Unsupported TGA format"; error: - SDL_RWseek(src, start, SDL_RW_SEEK_SET); + SDL_SeekIO(src, start, SDL_IO_SEEK_SET); if ( img ) { SDL_DestroySurface(img); } @@ -326,7 +326,7 @@ SDL_Surface *IMG_LoadTGA_RW(SDL_RWops *src) #endif /* dummy TGA load routine */ -SDL_Surface *IMG_LoadTGA_RW(SDL_RWops *src) +SDL_Surface *IMG_LoadTGA_IO(SDL_IOStream *src) { return(NULL); } diff --git a/src/IMG_tif.c b/src/IMG_tif.c index e6c51a27..ccd6a525 100644 --- a/src/IMG_tif.c +++ b/src/IMG_tif.c @@ -82,30 +82,30 @@ void IMG_QuitTIF(void) } /* - * These are the thunking routine to use the SDL_RWops* routines from + * These are the thunking routine to use the SDL_IOStream* routines from * libtiff's internals. */ static tsize_t tiff_read(thandle_t fd, tdata_t buf, tsize_t size) { - return SDL_RWread((SDL_RWops*)fd, buf, size); + return SDL_ReadIO((SDL_IOStream*)fd, buf, size); } static toff_t tiff_seek(thandle_t fd, toff_t offset, int origin) { - return SDL_RWseek((SDL_RWops*)fd, offset, origin); + return SDL_SeekIO((SDL_IOStream*)fd, offset, origin); } static tsize_t tiff_write(thandle_t fd, tdata_t buf, tsize_t size) { - return SDL_RWwrite((SDL_RWops*)fd, buf, size); + return SDL_WriteIO((SDL_IOStream*)fd, buf, size); } static int tiff_close(thandle_t fd) { (void)fd; /* - * We don't want libtiff closing our SDL_RWops*, but if it's not given + * We don't want libtiff closing our SDL_IOStream*, but if it's not given * a routine to try, and if the image isn't a TIFF, it'll segfault. */ return 0; @@ -132,14 +132,14 @@ static toff_t tiff_size(thandle_t fd) Sint64 save_pos; toff_t size; - save_pos = SDL_RWtell((SDL_RWops*)fd); - SDL_RWseek((SDL_RWops*)fd, 0, SDL_RW_SEEK_END); - size = SDL_RWtell((SDL_RWops*)fd); - SDL_RWseek((SDL_RWops*)fd, save_pos, SDL_RW_SEEK_SET); + save_pos = SDL_TellIO((SDL_IOStream*)fd); + SDL_SeekIO((SDL_IOStream*)fd, 0, SDL_IO_SEEK_END); + size = SDL_TellIO((SDL_IOStream*)fd); + SDL_SeekIO((SDL_IOStream*)fd, save_pos, SDL_IO_SEEK_SET); return size; } -int IMG_isTIF(SDL_RWops* src) +int IMG_isTIF(SDL_IOStream * src) { Sint64 start; int is_TIF; @@ -147,9 +147,9 @@ int IMG_isTIF(SDL_RWops* src) if ( !src ) return 0; - start = SDL_RWtell(src); + start = SDL_TellIO(src); is_TIF = 0; - if ( SDL_RWread(src, magic, sizeof(magic)) == sizeof(magic) ) { + if (SDL_ReadIO(src, magic, sizeof(magic)) == sizeof(magic) ) { if ( (magic[0] == 'I' && magic[1] == 'I' && magic[2] == 0x2a && @@ -161,11 +161,11 @@ int IMG_isTIF(SDL_RWops* src) is_TIF = 1; } } - SDL_RWseek(src, start, SDL_RW_SEEK_SET); + SDL_SeekIO(src, start, SDL_IO_SEEK_SET); return(is_TIF); } -SDL_Surface* IMG_LoadTIF_RW(SDL_RWops* src) +SDL_Surface* IMG_LoadTIF_IO(SDL_IOStream * src) { Sint64 start; TIFF* tiff = NULL; @@ -173,10 +173,10 @@ SDL_Surface* IMG_LoadTIF_RW(SDL_RWops* src) Uint32 img_width, img_height; if ( !src ) { - /* The error message has been set in SDL_RWFromFile */ + /* The error message has been set in SDL_IOFromFile */ return NULL; } - start = SDL_RWtell(src); + start = SDL_TellIO(src); if ( (IMG_Init(IMG_INIT_TIF) & IMG_INIT_TIF) == 0 ) { return NULL; @@ -204,7 +204,7 @@ SDL_Surface* IMG_LoadTIF_RW(SDL_RWops* src) return surface; error: - SDL_RWseek(src, start, SDL_RW_SEEK_SET); + SDL_SeekIO(src, start, SDL_IO_SEEK_SET); if (surface) { SDL_DestroySurface(surface); } @@ -230,7 +230,7 @@ void IMG_QuitTIF(void) } /* See if an image is contained in a data source */ -int IMG_isTIF(SDL_RWops *src) +int IMG_isTIF(SDL_IOStream *src) { (void)src; @@ -238,7 +238,7 @@ int IMG_isTIF(SDL_RWops *src) } /* Load a TIFF type image from an SDL datasource */ -SDL_Surface *IMG_LoadTIF_RW(SDL_RWops *src) +SDL_Surface *IMG_LoadTIF_IO(SDL_IOStream *src) { (void)src; diff --git a/src/IMG_webp.c b/src/IMG_webp.c index a698dbc7..3e03134b 100644 --- a/src/IMG_webp.c +++ b/src/IMG_webp.c @@ -115,7 +115,7 @@ void IMG_QuitWEBP(void) --lib.loaded; } -static int webp_getinfo(SDL_RWops *src, size_t *datasize) { +static int webp_getinfo(SDL_IOStream *src, size_t *datasize) { Sint64 start, size; int is_WEBP; Uint8 magic[20]; @@ -123,9 +123,9 @@ static int webp_getinfo(SDL_RWops *src, size_t *datasize) { if (!src) { return 0; } - start = SDL_RWtell(src); + start = SDL_TellIO(src); is_WEBP = 0; - if (SDL_RWread(src, magic, sizeof(magic)) == sizeof(magic)) { + if (SDL_ReadIO(src, magic, sizeof(magic)) == sizeof(magic)) { if (magic[ 0] == 'R' && magic[ 1] == 'I' && magic[ 2] == 'F' && @@ -140,7 +140,7 @@ static int webp_getinfo(SDL_RWops *src, size_t *datasize) { (magic[15] == ' ' || magic[15] == 'X' || magic[15] == 'L')) { is_WEBP = 1; if (datasize) { - size = SDL_RWsize(src); + size = SDL_GetIOSize(src); if (size > 0) { *datasize = (size_t)(size - start); } else { @@ -149,17 +149,17 @@ static int webp_getinfo(SDL_RWops *src, size_t *datasize) { } } } - SDL_RWseek(src, start, SDL_RW_SEEK_SET); + SDL_SeekIO(src, start, SDL_IO_SEEK_SET); return(is_WEBP); } /* See if an image is contained in a data source */ -int IMG_isWEBP(SDL_RWops *src) +int IMG_isWEBP(SDL_IOStream *src) { return webp_getinfo(src, NULL); } -SDL_Surface *IMG_LoadWEBP_RW(SDL_RWops *src) +SDL_Surface *IMG_LoadWEBP_IO(SDL_IOStream *src) { Sint64 start; const char *error = NULL; @@ -171,11 +171,11 @@ SDL_Surface *IMG_LoadWEBP_RW(SDL_RWops *src) uint8_t *ret; if (!src) { - /* The error message has been set in SDL_RWFromFile */ + /* The error message has been set in SDL_IOFromFile */ return NULL; } - start = SDL_RWtell(src); + start = SDL_TellIO(src); if ((IMG_Init(IMG_INIT_WEBP) & IMG_INIT_WEBP) == 0) { goto error; @@ -193,7 +193,7 @@ SDL_Surface *IMG_LoadWEBP_RW(SDL_RWops *src) goto error; } - if (SDL_RWread(src, raw_data, raw_data_size) != raw_data_size) { + if (SDL_ReadIO(src, raw_data, raw_data_size) != raw_data_size) { error = "Failed to read WEBP"; goto error; } @@ -255,11 +255,11 @@ SDL_Surface *IMG_LoadWEBP_RW(SDL_RWops *src) IMG_SetError("%s", error); } - SDL_RWseek(src, start, SDL_RW_SEEK_SET); + SDL_SeekIO(src, start, SDL_IO_SEEK_SET); return NULL; } -IMG_Animation *IMG_LoadWEBPAnimation_RW(SDL_RWops *src) +IMG_Animation *IMG_LoadWEBPAnimation_IO(SDL_IOStream *src) { Sint64 start; const char *error = NULL; @@ -275,11 +275,11 @@ IMG_Animation *IMG_LoadWEBPAnimation_RW(SDL_RWops *src) WebPData wd; if (!src) { - /* The error message has been set in SDL_RWFromFile */ + /* The error message has been set in SDL_IOFromFile */ return NULL; } - start = SDL_RWtell(src); + start = SDL_TellIO(src); if ((IMG_Init(IMG_INIT_WEBP) & IMG_INIT_WEBP) == 0) { goto error; @@ -297,7 +297,7 @@ IMG_Animation *IMG_LoadWEBPAnimation_RW(SDL_RWops *src) goto error; } - if (SDL_RWread(src, raw_data, raw_data_size) != raw_data_size) { + if (SDL_ReadIO(src, raw_data, raw_data_size) != raw_data_size) { error = "Failed to read WEBP Animation"; goto error; } @@ -374,7 +374,7 @@ IMG_Animation *IMG_LoadWEBPAnimation_RW(SDL_RWops *src) if (error) { IMG_SetError("%s", error); } - SDL_RWseek(src, start, SDL_RW_SEEK_SET); + SDL_SeekIO(src, start, SDL_IO_SEEK_SET); return NULL; } @@ -394,7 +394,7 @@ void IMG_QuitWEBP(void) } /* See if an image is contained in a data source */ -int IMG_isWEBP(SDL_RWops *src) +int IMG_isWEBP(SDL_IOStream *src) { (void)src; @@ -402,14 +402,14 @@ int IMG_isWEBP(SDL_RWops *src) } /* Load a WEBP type image from an SDL datasource */ -SDL_Surface *IMG_LoadWEBP_RW(SDL_RWops *src) +SDL_Surface *IMG_LoadWEBP_IO(SDL_IOStream *src) { (void)src; return NULL; } -IMG_Animation *IMG_LoadWEBPAnimation_RW(SDL_RWops *src) +IMG_Animation *IMG_LoadWEBPAnimation_IO(SDL_IOStream *src) { (void)src; diff --git a/src/IMG_xcf.c b/src/IMG_xcf.c index f7af8942..c8cdbac0 100644 --- a/src/IMG_xcf.c +++ b/src/IMG_xcf.c @@ -209,40 +209,40 @@ typedef struct { typedef unsigned char *xcf_tile; -typedef unsigned char *(*load_tile_type)(SDL_RWops *, size_t, int, int, int); +typedef unsigned char *(*load_tile_type)(SDL_IOStream *, size_t, int, int, int); /* See if an image is contained in a data source */ -int IMG_isXCF(SDL_RWops *src) +int IMG_isXCF(SDL_IOStream *src) { Sint64 start; int is_XCF = 0; char magic[14]; if (src) { - start = SDL_RWtell(src); - if (SDL_RWread(src, magic, sizeof(magic)) == sizeof(magic)) { + start = SDL_TellIO(src); + if (SDL_ReadIO(src, magic, sizeof(magic)) == sizeof(magic)) { if (SDL_strncmp(magic, "gimp xcf ", 9) == 0) { is_XCF = 1; } } - SDL_RWseek(src, start, SDL_RW_SEEK_SET); + SDL_SeekIO(src, start, SDL_IO_SEEK_SET); } return is_XCF; } -static char *read_string(SDL_RWops *src) +static char *read_string(SDL_IOStream *src) { Sint64 remaining; Uint32 tmp; char *data = NULL; if (SDL_ReadU32BE(src, &tmp)) { - remaining = SDL_RWsize(src) - SDL_RWtell(src); + remaining = SDL_GetIOSize(src) - SDL_TellIO(src); if (tmp <= remaining) { data = (char *)SDL_malloc(tmp); if (data) { - if (SDL_RWread(src, data, tmp) == tmp) { + if (SDL_ReadIO(src, data, tmp) == tmp) { data[tmp - 1] = '\0'; } else { SDL_free(data); @@ -254,7 +254,7 @@ static char *read_string(SDL_RWops *src) return data; } -static Uint64 read_offset(SDL_RWops *src, const xcf_header *h) +static Uint64 read_offset(SDL_IOStream *src, const xcf_header *h) { Uint64 offset = 0; /* starting with version 11, offsets are 64 bits */ Uint32 offset32; @@ -271,7 +271,7 @@ static Uint64 read_offset(SDL_RWops *src, const xcf_header *h) return offset; } -static int xcf_read_property(SDL_RWops *src, xcf_prop *prop) +static int xcf_read_property(SDL_IOStream *src, xcf_prop *prop) { Uint32 len; @@ -281,7 +281,7 @@ static int xcf_read_property(SDL_RWops *src, xcf_prop *prop) } #ifdef DEBUG - SDL_Log("%.8" SDL_PRIu64 ": %s(%u): %u\n", SDL_RWtell (src), prop->id < 25 ? prop_names [prop->id] : "unknown", prop->id, prop->length); + SDL_Log("%.8" SDL_PRIu64 ": %s(%u): %u\n", SDL_TellIO (src), prop->id < 25 ? prop_names [prop->id] : "unknown", prop->id, prop->length); #endif switch (prop->id) { @@ -293,7 +293,7 @@ static int xcf_read_property(SDL_RWops *src, xcf_prop *prop) if (!prop->data.colormap.cmap) { return 0; } - if (SDL_RWread(src, prop->data.colormap.cmap, prop->data.colormap.num * 3) != prop->data.colormap.num * 3) { + if (SDL_ReadIO(src, prop->data.colormap.cmap, prop->data.colormap.num * 3) != prop->data.colormap.num * 3) { SDL_free(prop->data.colormap.cmap); return 0; } @@ -317,7 +317,7 @@ static int xcf_read_property(SDL_RWops *src, xcf_prop *prop) } else { len = prop->length; } - if (SDL_RWread(src, &prop->data, len) != len) { + if (SDL_ReadIO(src, &prop->data, len) != len) { return 0; } break; @@ -327,7 +327,7 @@ static int xcf_read_property(SDL_RWops *src, xcf_prop *prop) } break; default: - if (SDL_RWseek(src, prop->length, SDL_RW_SEEK_CUR) < 0) + if (SDL_SeekIO(src, prop->length, SDL_IO_SEEK_CUR) < 0) return 0; /* ERROR */ } return 1; /* OK */ @@ -342,7 +342,7 @@ static void free_xcf_header(xcf_header *h) } } -static xcf_header *read_xcf_header(SDL_RWops *src) +static xcf_header *read_xcf_header(SDL_IOStream *src) { xcf_header *h; xcf_prop prop; @@ -352,7 +352,7 @@ static xcf_header *read_xcf_header(SDL_RWops *src) return NULL; } - if (SDL_RWread(src, h->sign, 14) != 14) { + if (SDL_ReadIO(src, h->sign, 14) != 14) { SDL_free(h); return NULL; } @@ -424,7 +424,7 @@ static void free_xcf_layer(xcf_layer *l) } } -static xcf_layer *read_xcf_layer(SDL_RWops *src, const xcf_header *h) +static xcf_layer *read_xcf_layer(SDL_IOStream *src, const xcf_header *h) { xcf_layer *l; xcf_prop prop; @@ -474,7 +474,7 @@ static void free_xcf_channel(xcf_channel *c) } } -static xcf_channel *read_xcf_channel(SDL_RWops *src, const xcf_header *h) +static xcf_channel *read_xcf_channel(SDL_IOStream *src, const xcf_header *h) { xcf_channel *l; xcf_prop prop; @@ -533,7 +533,7 @@ static void free_xcf_hierarchy(xcf_hierarchy *h) } } -static xcf_hierarchy *read_xcf_hierarchy(SDL_RWops *src, const xcf_header *head) +static xcf_hierarchy *read_xcf_hierarchy(SDL_IOStream *src, const xcf_header *head) { xcf_hierarchy *h; int i; @@ -566,7 +566,7 @@ static void free_xcf_level(xcf_level *l) } } -static xcf_level *read_xcf_level(SDL_RWops *src, const xcf_header *h) +static xcf_level *read_xcf_level(SDL_IOStream *src, const xcf_header *h) { xcf_level *l; int i; @@ -594,7 +594,7 @@ static void free_xcf_tile(unsigned char *t) SDL_free(t); } -static unsigned char *load_xcf_tile_none (SDL_RWops *src, size_t len, int bpp, int x, int y) +static unsigned char *load_xcf_tile_none (SDL_IOStream *src, size_t len, int bpp, int x, int y) { unsigned char *load = NULL; (void)bpp; @@ -603,7 +603,7 @@ static unsigned char *load_xcf_tile_none (SDL_RWops *src, size_t len, int bpp, i load = (unsigned char *)SDL_malloc(len); if (load != NULL) { - if (SDL_RWread(src, load, len) != len) { + if (SDL_ReadIO(src, load, len) != len) { SDL_free(load); load = NULL; } @@ -611,7 +611,7 @@ static unsigned char *load_xcf_tile_none (SDL_RWops *src, size_t len, int bpp, i return load; } -static unsigned char *load_xcf_tile_rle(SDL_RWops *src, size_t len, int bpp, int x, int y) +static unsigned char *load_xcf_tile_rle(SDL_IOStream *src, size_t len, int bpp, int x, int y) { unsigned char *load, *t, *data, *d; int i, size, j, length; @@ -627,7 +627,7 @@ static unsigned char *load_xcf_tile_rle(SDL_RWops *src, size_t len, int bpp, int return NULL; } - amount_read = SDL_RWread(src, load, len); + amount_read = SDL_ReadIO(src, load, len); if (amount_read == 0) { SDL_free(load); return NULL; @@ -720,7 +720,7 @@ static void create_channel_surface(SDL_Surface *surf, xcf_image_type itype, Uint } static int -do_layer_surface(SDL_Surface *surface, SDL_RWops *src, xcf_header *head, xcf_layer *layer, load_tile_type load_tile) +do_layer_surface(SDL_Surface *surface, SDL_IOStream *src, xcf_header *head, xcf_layer *layer, load_tile_type load_tile) { xcf_hierarchy *hierarchy; xcf_level *level; @@ -732,7 +732,7 @@ do_layer_surface(SDL_Surface *surface, SDL_RWops *src, xcf_header *head, xcf_lay Uint32 *row; Uint64 length; - if (SDL_RWseek(src, layer->hierarchy_file_offset, SDL_RW_SEEK_SET) < 0) { + if (SDL_SeekIO(src, layer->hierarchy_file_offset, SDL_IO_SEEK_SET) < 0) { return 1; } hierarchy = read_xcf_hierarchy(src, head); @@ -751,7 +751,7 @@ do_layer_surface(SDL_Surface *surface, SDL_RWops *src, xcf_header *head, xcf_lay level = NULL; for (i = 0; hierarchy->level_file_offsets[i]; i++) { - if (SDL_RWseek(src, hierarchy->level_file_offsets[i], SDL_RW_SEEK_SET) < 0) + if (SDL_SeekIO(src, hierarchy->level_file_offsets[i], SDL_IO_SEEK_SET) < 0) break; if (i > 0) /* skip level except the 1st one, just like GIMP does */ continue; @@ -759,7 +759,7 @@ do_layer_surface(SDL_Surface *surface, SDL_RWops *src, xcf_header *head, xcf_lay ty = tx = 0; for (j = 0; level->tile_file_offsets[j]; j++) { - SDL_RWseek(src, level->tile_file_offsets[j], SDL_RW_SEEK_SET); + SDL_SeekIO(src, level->tile_file_offsets[j], SDL_IO_SEEK_SET); ox = tx + 64 > level->width ? level->width % 64 : 64; oy = ty + 64 > level->height ? level->height % 64 : 64; length = ox*oy*6; @@ -888,7 +888,7 @@ do_layer_surface(SDL_Surface *surface, SDL_RWops *src, xcf_header *head, xcf_lay return 0; } -SDL_Surface *IMG_LoadXCF_RW(SDL_RWops *src) +SDL_Surface *IMG_LoadXCF_IO(SDL_IOStream *src) { Sint64 start; const char *error = NULL; @@ -902,10 +902,10 @@ SDL_Surface *IMG_LoadXCF_RW(SDL_RWops *src) load_tile_type load_tile; if (!src) { - /* The error message has been set in SDL_RWFromFile */ + /* The error message has been set in SDL_IOFromFile */ return NULL; } - start = SDL_RWtell(src); + start = SDL_TellIO(src); /* Initialize the data we will clean up when we're done */ surface = NULL; @@ -942,7 +942,7 @@ SDL_Surface *IMG_LoadXCF_RW(SDL_RWops *src) head->layer_file_offsets[offsets] = offset; offsets++; } - fp = SDL_RWtell (src); + fp = SDL_TellIO (src); lays = SDL_CreateSurface(head->width, head->height, SDL_PIXELFORMAT_ARGB8888); if (lays == NULL) { @@ -953,7 +953,7 @@ SDL_Surface *IMG_LoadXCF_RW(SDL_RWops *src) /* Blit layers backwards, because Gimp saves them highest first */ for (i = offsets; i > 0; i--) { SDL_Rect rs, rd; - SDL_RWseek(src, head->layer_file_offsets[i-1], SDL_RW_SEEK_SET); + SDL_SeekIO(src, head->layer_file_offsets[i-1], SDL_IO_SEEK_SET); layer = read_xcf_layer(src, head); if (layer != NULL) { @@ -975,13 +975,13 @@ SDL_Surface *IMG_LoadXCF_RW(SDL_RWops *src) } SDL_DestroySurface(lays); - SDL_RWseek(src, fp, SDL_RW_SEEK_SET); + SDL_SeekIO(src, fp, SDL_IO_SEEK_SET); /* read channels */ while ((offset = read_offset (src, head)) != 0) { channel = (xcf_channel **)SDL_realloc(channel, sizeof(xcf_channel *) * (chnls + 1)); - fp = SDL_RWtell(src); - if (SDL_RWseek(src, offset, SDL_RW_SEEK_SET) < 0) { + fp = SDL_TellIO(src); + if (SDL_SeekIO(src, offset, SDL_IO_SEEK_SET) < 0) { error = "invalid channel offset"; goto done; } @@ -989,7 +989,7 @@ SDL_Surface *IMG_LoadXCF_RW(SDL_RWops *src) if (channel[chnls] != NULL) { chnls++; } - SDL_RWseek(src, fp, SDL_RW_SEEK_SET); + SDL_SeekIO(src, fp, SDL_IO_SEEK_SET); } if (chnls) { @@ -1019,7 +1019,7 @@ SDL_Surface *IMG_LoadXCF_RW(SDL_RWops *src) free_xcf_header(head); if (error) { - SDL_RWseek(src, start, SDL_RW_SEEK_SET); + SDL_SeekIO(src, start, SDL_IO_SEEK_SET); if (surface) { SDL_DestroySurface(surface); surface = NULL; @@ -1035,13 +1035,13 @@ SDL_Surface *IMG_LoadXCF_RW(SDL_RWops *src) #endif /* See if an image is contained in a data source */ -int IMG_isXCF(SDL_RWops *src) +int IMG_isXCF(SDL_IOStream *src) { return 0; } /* Load a XCF type image from an SDL datasource */ -SDL_Surface *IMG_LoadXCF_RW(SDL_RWops *src) +SDL_Surface *IMG_LoadXCF_IO(SDL_IOStream *src) { return NULL; } diff --git a/src/IMG_xpm.c b/src/IMG_xpm.c index 52dbcdff..6c7715bb 100644 --- a/src/IMG_xpm.c +++ b/src/IMG_xpm.c @@ -51,7 +51,7 @@ #ifdef LOAD_XPM /* See if an image is contained in a data source */ -int IMG_isXPM(SDL_RWops *src) +int IMG_isXPM(SDL_IOStream *src) { Sint64 start; int is_XPM; @@ -59,14 +59,14 @@ int IMG_isXPM(SDL_RWops *src) if ( !src ) return 0; - start = SDL_RWtell(src); + start = SDL_TellIO(src); is_XPM = 0; - if ( SDL_RWread(src, magic, sizeof(magic)) == sizeof(magic) ) { + if (SDL_ReadIO(src, magic, sizeof(magic)) == sizeof(magic) ) { if ( SDL_memcmp(magic, "/* XPM */", sizeof(magic)) == 0 ) { is_XPM = 1; } } - SDL_RWseek(src, start, SDL_RW_SEEK_SET); + SDL_SeekIO(src, start, SDL_IO_SEEK_SET); return(is_XPM); } @@ -923,7 +923,7 @@ static char *error; * If len > 0, it's assumed to be at least len chars (for efficiency). * Return NULL and set error upon EOF or parse error. */ -static char *get_next_line(char ***lines, SDL_RWops *src, size_t len) +static char *get_next_line(char ***lines, SDL_IOStream *src, size_t len) { char *linebufnew; @@ -933,7 +933,7 @@ static char *get_next_line(char ***lines, SDL_RWops *src, size_t len) char c; size_t n; do { - if (SDL_RWread(src, &c, 1) != 1) { + if (SDL_ReadIO(src, &c, 1) != 1) { error = "Premature end of data"; return NULL; } @@ -950,7 +950,7 @@ static char *get_next_line(char ***lines, SDL_RWops *src, size_t len) } linebuf = linebufnew; } - if (SDL_RWread(src, linebuf, len) != len) { + if (SDL_ReadIO(src, linebuf, len) != len) { error = "Premature end of data"; return NULL; } @@ -970,7 +970,7 @@ static char *get_next_line(char ***lines, SDL_RWops *src, size_t len) } linebuf = linebufnew; } - if (SDL_RWread(src, linebuf + n, 1) != 1) { + if (SDL_ReadIO(src, linebuf + n, 1) != 1) { error = "Premature end of data"; return NULL; } @@ -994,8 +994,8 @@ do { \ ++(p); \ } while (0) -/* read XPM from either array or RWops */ -static SDL_Surface *load_xpm(char **xpm, SDL_RWops *src, SDL_bool force_32bit) +/* read XPM from either array or IOStream */ +static SDL_Surface *load_xpm(char **xpm, SDL_IOStream *src, SDL_bool force_32bit) { Sint64 start = 0; SDL_Surface *image = NULL; @@ -1016,7 +1016,7 @@ static SDL_Surface *load_xpm(char **xpm, SDL_RWops *src, SDL_bool force_32bit) buflen = 0; if (src) - start = SDL_RWtell(src); + start = SDL_TellIO(src); if (xpm) xpmlines = &xpm; @@ -1153,7 +1153,7 @@ static SDL_Surface *load_xpm(char **xpm, SDL_RWops *src, SDL_bool force_32bit) done: if (error) { if ( src ) - SDL_RWseek(src, start, SDL_RW_SEEK_SET); + SDL_SeekIO(src, start, SDL_IO_SEEK_SET); if ( image ) { SDL_DestroySurface(image); image = NULL; @@ -1168,11 +1168,11 @@ static SDL_Surface *load_xpm(char **xpm, SDL_RWops *src, SDL_bool force_32bit) return(image); } -/* Load a XPM type image from an RWops datasource */ -SDL_Surface *IMG_LoadXPM_RW(SDL_RWops *src) +/* Load a XPM type image from an IOStream datasource */ +SDL_Surface *IMG_LoadXPM_IO(SDL_IOStream *src) { if ( !src ) { - /* The error message has been set in SDL_RWFromFile */ + /* The error message has been set in SDL_IOFromFile */ return NULL; } return load_xpm(NULL, src, 0); @@ -1202,14 +1202,14 @@ SDL_Surface *IMG_ReadXPMFromArrayToRGB888(char **xpm) #endif /* See if an image is contained in a data source */ -int IMG_isXPM(SDL_RWops *src) +int IMG_isXPM(SDL_IOStream *src) { return(0); } /* Load a XPM type image from an SDL datasource */ -SDL_Surface *IMG_LoadXPM_RW(SDL_RWops *src) +SDL_Surface *IMG_LoadXPM_IO(SDL_IOStream *src) { return(NULL); } diff --git a/src/IMG_xv.c b/src/IMG_xv.c index 9200379a..31e742c8 100644 --- a/src/IMG_xv.c +++ b/src/IMG_xv.c @@ -26,10 +26,10 @@ #ifdef LOAD_XV -static int get_line(SDL_RWops *src, char *line, int size) +static int get_line(SDL_IOStream *src, char *line, int size) { while ( size > 0 ) { - if ( SDL_RWread(src, line, 1) != 1 ) { + if (SDL_ReadIO(src, line, 1) != 1 ) { return -1; } if ( *line == '\r' ) { @@ -46,7 +46,7 @@ static int get_line(SDL_RWops *src, char *line, int size) return -1; } -static int get_header(SDL_RWops *src, int *w, int *h) +static int get_header(SDL_IOStream *src, int *w, int *h) { char line[1024]; @@ -80,7 +80,7 @@ static int get_header(SDL_RWops *src, int *w, int *h) } /* See if an image is contained in a data source */ -int IMG_isXV(SDL_RWops *src) +int IMG_isXV(SDL_IOStream *src) { Sint64 start; int is_XV; @@ -88,17 +88,17 @@ int IMG_isXV(SDL_RWops *src) if ( !src ) return 0; - start = SDL_RWtell(src); + start = SDL_TellIO(src); is_XV = 0; if ( get_header(src, &w, &h) == 0 ) { is_XV = 1; } - SDL_RWseek(src, start, SDL_RW_SEEK_SET); + SDL_SeekIO(src, start, SDL_IO_SEEK_SET); return(is_XV); } /* Load a XV thumbnail image from an SDL datasource */ -SDL_Surface *IMG_LoadXV_RW(SDL_RWops *src) +SDL_Surface *IMG_LoadXV_IO(SDL_IOStream *src) { Sint64 start; const char *error = NULL; @@ -107,10 +107,10 @@ SDL_Surface *IMG_LoadXV_RW(SDL_RWops *src) Uint8 *pixels; if ( !src ) { - /* The error message has been set in SDL_RWFromFile */ + /* The error message has been set in SDL_IOFromFile */ return NULL; } - start = SDL_RWtell(src); + start = SDL_TellIO(src); /* Read the header */ if ( get_header(src, &w, &h) < 0 ) { @@ -127,7 +127,7 @@ SDL_Surface *IMG_LoadXV_RW(SDL_RWops *src) /* Load the image data */ for ( pixels = (Uint8 *)surface->pixels; h > 0; --h ) { - if ( SDL_RWread(src, pixels, w) != (size_t)w ) { + if (SDL_ReadIO(src, pixels, w) != (size_t)w ) { error = "Couldn't read image data"; goto done; } @@ -136,7 +136,7 @@ SDL_Surface *IMG_LoadXV_RW(SDL_RWops *src) done: if ( error ) { - SDL_RWseek(src, start, SDL_RW_SEEK_SET); + SDL_SeekIO(src, start, SDL_IO_SEEK_SET); if ( surface ) { SDL_DestroySurface(surface); surface = NULL; @@ -152,13 +152,13 @@ SDL_Surface *IMG_LoadXV_RW(SDL_RWops *src) #endif /* See if an image is contained in a data source */ -int IMG_isXV(SDL_RWops *src) +int IMG_isXV(SDL_IOStream *src) { return(0); } /* Load a XXX type image from an SDL datasource */ -SDL_Surface *IMG_LoadXV_RW(SDL_RWops *src) +SDL_Surface *IMG_LoadXV_IO(SDL_IOStream *src) { return(NULL); } diff --git a/src/IMG_xxx.c b/src/IMG_xxx.c index c0fc741f..b3c1d4c4 100644 --- a/src/IMG_xxx.c +++ b/src/IMG_xxx.c @@ -28,7 +28,7 @@ /* See if an image is contained in a data source */ /* Remember to declare this procedure in IMG.h . */ -int IMG_isXXX(SDL_RWops *src) +int IMG_isXXX(SDL_IOStream *src) { int start; int is_XXX; @@ -37,34 +37,34 @@ int IMG_isXXX(SDL_RWops *src) return 0; } - start = SDL_RWtell(src); + start = SDL_TellIO(src); is_XXX = 0; /* Detect the image here */ - SDL_RWseek(src, start, SDL_RW_SEEK_SET); + SDL_SeekIO(src, start, SDL_IO_SEEK_SET); return is_XXX; } /* Load an XXX type image from an SDL datasource */ /* Remember to declare this procedure in IMG.h . */ -SDL_Surface *IMG_LoadXXX_RW(SDL_RWops *src) +SDL_Surface *IMG_LoadXXX_IO(SDL_IOStream *src) { int start; const char *error = NULL; SDL_Surface *surface = NULL; if (!src) { - /* The error message has been set in SDL_RWFromFile */ + /* The error message has been set in SDL_IOFromFile */ return NULL; } - start = SDL_RWtell(src); + start = SDL_TellIO(src); /* Load the image here */ if (error) { - SDL_RWseek(src, start, SDL_RW_SEEK_SET); + SDL_SeekIO(src, start, SDL_IO_SEEK_SET); if (surface) { SDL_DestroySurface(surface); surface = NULL; @@ -81,13 +81,13 @@ SDL_Surface *IMG_LoadXXX_RW(SDL_RWops *src) #pragma warning(disable : 4100) /* warning C4100: 'op' : unreferenced formal parameter */ #endif -int IMG_isXXX(SDL_RWops *src) +int IMG_isXXX(SDL_IOStream *src) { (void) src; return 0; } -SDL_Surface *IMG_LoadXXX_RW(SDL_RWops *src) +SDL_Surface *IMG_LoadXXX_IO(SDL_IOStream *src) { (void) src; return NULL; diff --git a/src/SDL_image.sym b/src/SDL_image.sym index 422fad76..e8f62d0b 100644 --- a/src/SDL_image.sym +++ b/src/SDL_image.sym @@ -4,45 +4,45 @@ SDL3_image_0.0.0 { IMG_Init; IMG_Linked_Version; IMG_Load; - IMG_LoadAVIF_RW; + IMG_LoadAVIF_IO; IMG_LoadAnimation; - IMG_LoadAnimationTyped_RW; - IMG_LoadAnimation_RW; - IMG_LoadBMP_RW; - IMG_LoadCUR_RW; - IMG_LoadGIFAnimation_RW; - IMG_LoadGIF_RW; - IMG_LoadICO_RW; - IMG_LoadJPG_RW; - IMG_LoadJXL_RW; - IMG_LoadLBM_RW; - IMG_LoadPCX_RW; - IMG_LoadPNG_RW; - IMG_LoadPNM_RW; - IMG_LoadQOI_RW; - IMG_LoadSVG_RW; - IMG_LoadSizedSVG_RW; - IMG_LoadTGA_RW; - IMG_LoadTIF_RW; + IMG_LoadAnimationTyped_IO; + IMG_LoadAnimation_IO; + IMG_LoadBMP_IO; + IMG_LoadCUR_IO; + IMG_LoadGIFAnimation_IO; + IMG_LoadGIF_IO; + IMG_LoadICO_IO; + IMG_LoadJPG_IO; + IMG_LoadJXL_IO; + IMG_LoadLBM_IO; + IMG_LoadPCX_IO; + IMG_LoadPNG_IO; + IMG_LoadPNM_IO; + IMG_LoadQOI_IO; + IMG_LoadSVG_IO; + IMG_LoadSizedSVG_IO; + IMG_LoadTGA_IO; + IMG_LoadTIF_IO; IMG_LoadTexture; - IMG_LoadTextureTyped_RW; - IMG_LoadTexture_RW; - IMG_LoadTyped_RW; - IMG_LoadWEBPAnimation_RW; - IMG_LoadWEBP_RW; - IMG_LoadXCF_RW; - IMG_LoadXPM_RW; - IMG_LoadXV_RW; - IMG_Load_RW; + IMG_LoadTextureTyped_IO; + IMG_LoadTexture_IO; + IMG_LoadTyped_IO; + IMG_LoadWEBPAnimation_IO; + IMG_LoadWEBP_IO; + IMG_LoadXCF_IO; + IMG_LoadXPM_IO; + IMG_LoadXV_IO; + IMG_Load_IO; IMG_Quit; IMG_ReadXPMFromArray; IMG_ReadXPMFromArrayToRGB888; IMG_SaveJPG; - IMG_SaveJPG_RW; + IMG_SaveJPG_IO; IMG_SavePNG; - IMG_SavePNG_RW; + IMG_SavePNG_IO; IMG_SaveAVIF; - IMG_SaveAVIF_RW; + IMG_SaveAVIF_IO; IMG_isAVIF; IMG_isBMP; IMG_isCUR; diff --git a/test/main.c b/test/main.c index 36a53383..7330738b 100644 --- a/test/main.c +++ b/test/main.c @@ -131,8 +131,8 @@ typedef struct int initFlag; SDL_bool canLoad; SDL_bool canSave; - int (SDLCALL * checkFunction)(SDL_RWops *src); - SDL_Surface *(SDLCALL * loadFunction)(SDL_RWops *src); + int (SDLCALL * checkFunction)(SDL_IOStream *src); + SDL_Surface *(SDLCALL * loadFunction)(SDL_IOStream *src); } Format; static const Format formats[] = @@ -152,7 +152,7 @@ static const Format formats[] = #endif SDL_IMAGE_SAVE_AVIF, IMG_isAVIF, - IMG_LoadAVIF_RW, + IMG_LoadAVIF_IO, }, { "BMP", @@ -169,7 +169,7 @@ static const Format formats[] = #endif SDL_FALSE, /* can save */ IMG_isBMP, - IMG_LoadBMP_RW, + IMG_LoadBMP_IO, }, { "CUR", @@ -186,7 +186,7 @@ static const Format formats[] = #endif SDL_FALSE, /* can save */ IMG_isCUR, - IMG_LoadCUR_RW, + IMG_LoadCUR_IO, }, { "GIF", @@ -203,7 +203,7 @@ static const Format formats[] = #endif SDL_FALSE, /* can save */ IMG_isGIF, - IMG_LoadGIF_RW, + IMG_LoadGIF_IO, }, { "ICO", @@ -220,7 +220,7 @@ static const Format formats[] = #endif SDL_FALSE, /* can save */ IMG_isICO, - IMG_LoadICO_RW, + IMG_LoadICO_IO, }, { "JPG", @@ -237,7 +237,7 @@ static const Format formats[] = #endif SDL_IMAGE_SAVE_JPG, IMG_isJPG, - IMG_LoadJPG_RW, + IMG_LoadJPG_IO, }, { "JXL", @@ -254,7 +254,7 @@ static const Format formats[] = #endif SDL_FALSE, /* can save */ IMG_isJXL, - IMG_LoadJXL_RW, + IMG_LoadJXL_IO, }, #if 0 { @@ -272,7 +272,7 @@ static const Format formats[] = #endif SDL_FALSE, /* can save */ IMG_isLBM, - IMG_LoadLBM_RW, + IMG_LoadLBM_IO, }, #endif { @@ -290,7 +290,7 @@ static const Format formats[] = #endif SDL_FALSE, /* can save */ IMG_isPCX, - IMG_LoadPCX_RW, + IMG_LoadPCX_IO, }, { "PNG", @@ -307,7 +307,7 @@ static const Format formats[] = #endif SDL_IMAGE_SAVE_PNG, IMG_isPNG, - IMG_LoadPNG_RW, + IMG_LoadPNG_IO, }, { "PNM", @@ -324,7 +324,7 @@ static const Format formats[] = #endif SDL_FALSE, /* can save */ IMG_isPNM, - IMG_LoadPNM_RW, + IMG_LoadPNM_IO, }, { "QOI", @@ -341,7 +341,7 @@ static const Format formats[] = #endif SDL_FALSE, /* can save */ IMG_isQOI, - IMG_LoadQOI_RW, + IMG_LoadQOI_IO, }, { "SVG", @@ -358,7 +358,7 @@ static const Format formats[] = #endif SDL_FALSE, /* can save */ IMG_isSVG, - IMG_LoadSVG_RW, + IMG_LoadSVG_IO, }, { "SVG-sized", @@ -375,7 +375,7 @@ static const Format formats[] = #endif SDL_FALSE, /* can save */ IMG_isSVG, - IMG_LoadSVG_RW, + IMG_LoadSVG_IO, }, { "SVG-class", @@ -392,7 +392,7 @@ static const Format formats[] = #endif SDL_FALSE, /* can save */ IMG_isSVG, - IMG_LoadSVG_RW, + IMG_LoadSVG_IO, }, { "TGA", @@ -409,7 +409,7 @@ static const Format formats[] = #endif SDL_FALSE, /* can save */ NULL, - IMG_LoadTGA_RW, + IMG_LoadTGA_IO, }, { "TIF", @@ -426,7 +426,7 @@ static const Format formats[] = #endif SDL_FALSE, /* can save */ IMG_isTIF, - IMG_LoadTIF_RW, + IMG_LoadTIF_IO, }, { "WEBP", @@ -443,7 +443,7 @@ static const Format formats[] = #endif SDL_FALSE, /* can save */ IMG_isWEBP, - IMG_LoadWEBP_RW, + IMG_LoadWEBP_IO, }, { "XCF", @@ -460,7 +460,7 @@ static const Format formats[] = #endif SDL_FALSE, /* can save */ IMG_isXCF, - IMG_LoadXCF_RW, + IMG_LoadXCF_IO, }, { "XPM", @@ -477,7 +477,7 @@ static const Format formats[] = #endif SDL_FALSE, /* can save */ IMG_isXPM, - IMG_LoadXPM_RW, + IMG_LoadXPM_IO, }, #if 0 { @@ -495,7 +495,7 @@ static const Format formats[] = #endif SDL_FALSE, /* can save */ IMG_isXV, - IMG_LoadXV_RW, + IMG_LoadXV_IO, }, #endif }; @@ -513,8 +513,8 @@ StrHasSuffix(const char *str, const char *suffix) typedef enum { LOAD_CONVENIENCE = 0, - LOAD_RW, - LOAD_TYPED_RW, + LOAD_IO, + LOAD_TYPED_IO, LOAD_FORMAT_SPECIFIC, LOAD_SIZED } LoadMode; @@ -633,7 +633,7 @@ FormatLoadTest(const Format *format, { SDL_Surface *reference = NULL; SDL_Surface *surface = NULL; - SDL_RWops *src = NULL; + SDL_IOStream *src = NULL; char *filename = GetTestFilename(TEST_FILE_DIST, format->sample); char *refFilename = GetTestFilename(TEST_FILE_DIST, format->reference); int initResult = 0; @@ -682,7 +682,7 @@ FormatLoadTest(const Format *format, } if (mode != LOAD_CONVENIENCE) { - src = SDL_RWFromFile(filename, "rb"); + src = SDL_IOFromFile(filename, "rb"); SDLTest_AssertCheck(src != NULL, "Opening %s should succeed (%s)", filename, SDL_GetError()); @@ -695,12 +695,12 @@ FormatLoadTest(const Format *format, surface = IMG_Load(filename); break; - case LOAD_RW: + case LOAD_IO: if (format->checkFunction != NULL) { - SDL_RWops *ref_src; + SDL_IOStream *ref_src; int check; - ref_src = SDL_RWFromFile(refFilename, "rb"); + ref_src = SDL_IOFromFile(refFilename, "rb"); SDLTest_AssertCheck(ref_src != NULL, "Opening %s should succeed (%s)", refFilename, SDL_GetError()); @@ -709,7 +709,7 @@ FormatLoadTest(const Format *format, SDLTest_AssertCheck(!check, "Should not detect %s as %s -> %d", refFilename, format->name, check); - SDL_RWclose(ref_src); + SDL_CloseIO(ref_src); } } @@ -721,12 +721,12 @@ FormatLoadTest(const Format *format, filename, format->name, check); } - surface = IMG_Load_RW(src, SDL_TRUE); + surface = IMG_Load_IO(src, SDL_TRUE); src = NULL; /* ownership taken */ break; - case LOAD_TYPED_RW: - surface = IMG_LoadTyped_RW(src, SDL_TRUE, format->name); + case LOAD_TYPED_IO: + surface = IMG_LoadTyped_IO(src, SDL_TRUE, format->name); src = NULL; /* ownership taken */ break; @@ -736,7 +736,7 @@ FormatLoadTest(const Format *format, case LOAD_SIZED: if (SDL_strcmp(format->name, "SVG-sized") == 0) { - surface = IMG_LoadSizedSVG_RW(src, 64, 64); + surface = IMG_LoadSizedSVG_IO(src, 64, 64); } break; } @@ -778,7 +778,7 @@ FormatLoadTest(const Format *format, SDL_DestroySurface(reference); } if (src != NULL) { - SDL_RWclose(src); + SDL_CloseIO(src); } if (refFilename != NULL) { SDL_free(refFilename); @@ -799,7 +799,7 @@ FormatSaveTest(const Format *format, char filename[64] = { 0 }; SDL_Surface *reference = NULL; SDL_Surface *surface = NULL; - SDL_RWops *dest = NULL; + SDL_IOStream *dest = NULL; int initResult = 0; int diff; int result; @@ -836,25 +836,25 @@ FormatSaveTest(const Format *format, if (SDL_strcmp (format->name, "AVIF") == 0) { if (rw) { - dest = SDL_RWFromFile(filename, "wb"); - result = IMG_SaveAVIF_RW(reference, dest, SDL_FALSE, 90); - SDL_RWclose(dest); + dest = SDL_IOFromFile(filename, "wb"); + result = IMG_SaveAVIF_IO(reference, dest, SDL_FALSE, 90); + SDL_CloseIO(dest); } else { result = IMG_SaveAVIF(reference, filename, 90); } } else if (SDL_strcmp(format->name, "JPG") == 0) { if (rw) { - dest = SDL_RWFromFile(filename, "wb"); - result = IMG_SaveJPG_RW(reference, dest, SDL_FALSE, 90); - SDL_RWclose(dest); + dest = SDL_IOFromFile(filename, "wb"); + result = IMG_SaveJPG_IO(reference, dest, SDL_FALSE, 90); + SDL_CloseIO(dest); } else { result = IMG_SaveJPG(reference, filename, 90); } } else if (SDL_strcmp (format->name, "PNG") == 0) { if (rw) { - dest = SDL_RWFromFile(filename, "wb"); - result = IMG_SavePNG_RW(reference, dest, SDL_FALSE); - SDL_RWclose(dest); + dest = SDL_IOFromFile(filename, "wb"); + result = IMG_SavePNG_IO(reference, dest, SDL_FALSE); + SDL_CloseIO(dest); } else { result = IMG_SavePNG(reference, filename); } @@ -934,10 +934,10 @@ FormatTest(const Format *format) if (SDL_strcmp(format->name, "TGA") == 0) { SDLTest_Log("SKIP: Recognising %s by magic number is not supported", format->name); } else { - FormatLoadTest(format, LOAD_RW); + FormatLoadTest(format, LOAD_IO); } - FormatLoadTest(format, LOAD_TYPED_RW); + FormatLoadTest(format, LOAD_TYPED_IO); if (format->loadFunction != NULL) { FormatLoadTest(format, LOAD_FORMAT_SPECIFIC);