Merge __imlib_FindBestLoader...() functions
And move a few loader related function protoptypes again.
This commit is contained in:
parent
05f454a89d
commit
32a1c3ae19
|
@ -553,7 +553,7 @@ __imlib_LoadImage(const char *file, ImlibLoadArgs * ila)
|
|||
loader_ret = LOAD_FAIL;
|
||||
|
||||
/* take a guess by extension on the best loader to use */
|
||||
best_loader = __imlib_FindBestLoaderForFile(im->real_file, 0);
|
||||
best_loader = __imlib_FindBestLoader(im->real_file, NULL, 0);
|
||||
errno = 0;
|
||||
if (best_loader)
|
||||
loader_ret = __imlib_LoadImageWrapper(best_loader, im, ila->immed);
|
||||
|
@ -777,7 +777,7 @@ __imlib_SaveImage(ImlibImage * im, const char *file,
|
|||
}
|
||||
|
||||
/* find the laoder for the format - if its null use the extension */
|
||||
l = __imlib_FindBestLoaderForFileFormat(file, im->format, 1);
|
||||
l = __imlib_FindBestLoader(file, im->format, 1);
|
||||
/* no loader - abort */
|
||||
if (!l)
|
||||
{
|
||||
|
|
|
@ -78,6 +78,13 @@ typedef struct {
|
|||
int frame;
|
||||
} ImlibLoadArgs;
|
||||
|
||||
ImlibLoader *__imlib_FindBestLoader(const char *file, const char *format,
|
||||
int for_save);
|
||||
|
||||
void __imlib_LoaderSetFormats(ImlibLoader * l,
|
||||
const char *const *fmt,
|
||||
unsigned int num);
|
||||
|
||||
ImlibImage *__imlib_CreateImage(int w, int h, DATA32 * data);
|
||||
ImlibImage *__imlib_LoadImage(const char *file, ImlibLoadArgs * ila);
|
||||
int __imlib_LoadEmbedded(ImlibLoader * l, ImlibImage * im,
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include "debug.h"
|
||||
#include "file.h"
|
||||
#include "image.h"
|
||||
#include "loaders.h"
|
||||
|
||||
#define DBG_PFX "LOAD"
|
||||
|
@ -316,11 +317,14 @@ __imlib_LookupLoadedLoader(const char *format, int for_save)
|
|||
}
|
||||
|
||||
__EXPORT__ ImlibLoader *
|
||||
__imlib_FindBestLoaderForFormat(const char *format, int for_save)
|
||||
__imlib_FindBestLoader(const char *file, const char *format, int for_save)
|
||||
{
|
||||
ImlibLoader *l;
|
||||
|
||||
DP("%s: fmt='%s'\n", __func__, format);
|
||||
DP("%s: file='%s' fmt='%s'\n", __func__, file, format);
|
||||
|
||||
if (!format)
|
||||
format = __imlib_FileExtension(file);
|
||||
|
||||
if (!format || format[0] == '\0')
|
||||
return NULL;
|
||||
|
@ -346,32 +350,6 @@ __imlib_FindBestLoaderForFormat(const char *format, int for_save)
|
|||
return l;
|
||||
}
|
||||
|
||||
__EXPORT__ ImlibLoader *
|
||||
__imlib_FindBestLoaderForFile(const char *file, int for_save)
|
||||
{
|
||||
ImlibLoader *l;
|
||||
|
||||
DP("%s: file='%s'\n", __func__, file);
|
||||
|
||||
l = __imlib_FindBestLoaderForFormat(__imlib_FileExtension(file), for_save);
|
||||
|
||||
return l;
|
||||
}
|
||||
|
||||
ImlibLoader *
|
||||
__imlib_FindBestLoaderForFileFormat(const char *file, const char *format,
|
||||
int for_save)
|
||||
{
|
||||
DP("%s: file='%s' ext='%s'\n", __func__, file, format);
|
||||
|
||||
/* if the format is provided ("png" "jpg" etc.) use that */
|
||||
/* otherwise us the file extension */
|
||||
if (format)
|
||||
return __imlib_FindBestLoaderForFormat(format, for_save);
|
||||
else
|
||||
return __imlib_FindBestLoaderForFile(file, for_save);
|
||||
}
|
||||
|
||||
__EXPORT__ void
|
||||
__imlib_LoaderSetFormats(ImlibLoader * l,
|
||||
const char *const *fmt, unsigned int num)
|
||||
|
|
|
@ -20,15 +20,5 @@ struct _ImlibLoader {
|
|||
|
||||
void __imlib_RemoveAllLoaders(void);
|
||||
ImlibLoader **__imlib_GetLoaderList(void);
|
||||
ImlibLoader *__imlib_FindBestLoaderForFile(const char *file,
|
||||
int for_save);
|
||||
ImlibLoader *__imlib_FindBestLoaderForFormat(const char *format,
|
||||
int for_save);
|
||||
ImlibLoader *__imlib_FindBestLoaderForFileFormat(const char *file,
|
||||
const char *format,
|
||||
int for_save);
|
||||
void __imlib_LoaderSetFormats(ImlibLoader * l,
|
||||
const char *const *fmt,
|
||||
unsigned int num);
|
||||
|
||||
#endif /* __LOADERS */
|
||||
|
|
|
@ -41,7 +41,7 @@ decompress_load(ImlibImage * im, int load_data, const char *const *pext,
|
|||
if (!(real_ext = strndup(q, p - q - 1)))
|
||||
return LOAD_OOM;
|
||||
|
||||
loader = __imlib_FindBestLoaderForFormat(real_ext, 0);
|
||||
loader = __imlib_FindBestLoader(NULL, real_ext, 0);
|
||||
free(real_ext);
|
||||
if (!loader)
|
||||
return rc;
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
|
||||
#include "debug.h"
|
||||
#include "image.h"
|
||||
#include "loaders.h"
|
||||
|
||||
__EXPORT__ char load(ImlibImage * im, ImlibProgressFunction progress,
|
||||
char progress_granularity, char load_data);
|
||||
|
|
|
@ -376,7 +376,7 @@ get_loader(lopt * opt, ImlibLoader ** loader)
|
|||
return 0;
|
||||
}
|
||||
strncpy(ext + 1, data + 6, EXT_LEN);
|
||||
if (!(*loader = __imlib_FindBestLoaderForFile(ext, 0)))
|
||||
if (!(*loader = __imlib_FindBestLoader(ext, NULL, 0)))
|
||||
{
|
||||
fprintf(stderr, "No loader found for extension %s\n", ext);
|
||||
return 0;
|
||||
|
@ -552,7 +552,7 @@ load2(ImlibImage * im, int load_data)
|
|||
strncpy(url, data, length);
|
||||
url[length] = '\0';
|
||||
file = (strncmp(url, "file://", 7) ? url : url + 7);
|
||||
if (!(loader = __imlib_FindBestLoaderForFile(file, 0)))
|
||||
if (!(loader = __imlib_FindBestLoader(file, NULL, 0)))
|
||||
{
|
||||
fprintf(stderr, "No loader found for file %s\n", file);
|
||||
free(url);
|
||||
|
|
Loading…
Reference in New Issue