forked from old/legacy-imlib2
Cleanups in load() functions
When entering load we can assume that im != NULL and im->data == NULL.
This commit is contained in:
parent
cf2b8e7c3d
commit
868a40579a
|
@ -13,8 +13,6 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
|||
int w = 0, h = 0, alpha = 0;
|
||||
FILE *f;
|
||||
|
||||
if (im->data)
|
||||
return 0;
|
||||
f = fopen(im->real_file, "rb");
|
||||
if (!f)
|
||||
return 0;
|
||||
|
|
|
@ -128,8 +128,6 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
|||
*/
|
||||
unsigned char byte1, byte2;
|
||||
|
||||
if (im->data)
|
||||
return 0;
|
||||
f = fopen(im->real_file, "rb");
|
||||
if (!f)
|
||||
return 0;
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <assert.h>
|
||||
|
||||
#define OUTBUF_SIZE 16384
|
||||
#define INBUF_SIZE 1024
|
||||
|
@ -55,8 +54,6 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
|||
char *file, *p, *q, tmp[] = "/tmp/imlib2_loader_bz2-XXXXXX";
|
||||
char *real_ext;
|
||||
|
||||
assert(im);
|
||||
|
||||
/* make sure this file ends in ".bz2" and that there's another ext
|
||||
* (e.g. "foo.png.bz2"
|
||||
*/
|
||||
|
|
|
@ -23,35 +23,32 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
|||
}
|
||||
|
||||
/* read and check the header */
|
||||
if (!im->data)
|
||||
if (fread(hdr, sizeof(uint32_t), LEN(hdr), f) != LEN(hdr) ||
|
||||
memcmp("farbfeld", hdr, sizeof("farbfeld") - 1))
|
||||
{
|
||||
if (fread(hdr, sizeof(uint32_t), LEN(hdr), f) != LEN(hdr) ||
|
||||
memcmp("farbfeld", hdr, sizeof("farbfeld") - 1))
|
||||
{
|
||||
fclose(f);
|
||||
return 0;
|
||||
}
|
||||
im->w = ntohl(hdr[2]);
|
||||
im->h = ntohl(hdr[3]);
|
||||
if (!IMAGE_DIMENSIONS_OK(im->w, im->h))
|
||||
fclose(f);
|
||||
return 0;
|
||||
}
|
||||
im->w = ntohl(hdr[2]);
|
||||
im->h = ntohl(hdr[3]);
|
||||
if (!IMAGE_DIMENSIONS_OK(im->w, im->h))
|
||||
{
|
||||
im->w = 0;
|
||||
fclose(f);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* set format */
|
||||
if (!im->loader)
|
||||
{
|
||||
if (!(im->format = strdup("ff")))
|
||||
{
|
||||
im->w = 0;
|
||||
fclose(f);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* set format */
|
||||
if (!im->loader)
|
||||
{
|
||||
if (!(im->format = strdup("ff")))
|
||||
{
|
||||
im->w = 0;
|
||||
fclose(f);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
SET_FLAG(im->flags, F_HAS_ALPHA);
|
||||
}
|
||||
SET_FLAG(im->flags, F_HAS_ALPHA);
|
||||
|
||||
/* load the data */
|
||||
if (im->loader || immediate_load || progress)
|
||||
|
|
|
@ -26,11 +26,6 @@ load(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity,
|
|||
rows = NULL;
|
||||
transp = -1;
|
||||
|
||||
/* if immediate_load is 1, then dont delay image laoding as below, or */
|
||||
/* already data in this image - dont load it again */
|
||||
if (im->data)
|
||||
return 0;
|
||||
|
||||
fd = open(im->real_file, O_RDONLY);
|
||||
if (fd < 0)
|
||||
return 0;
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
#include <id3tag.h>
|
||||
|
@ -496,7 +495,6 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
|||
int res;
|
||||
struct stat st;
|
||||
|
||||
assert(im);
|
||||
if (stat(im->real_file, &st) < 0)
|
||||
return 0;
|
||||
if (!get_options(&opt, im))
|
||||
|
|
|
@ -51,8 +51,6 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
|||
struct ImLib_JPEG_error_mgr jerr;
|
||||
FILE *f;
|
||||
|
||||
if (im->data)
|
||||
return 0;
|
||||
f = fopen(im->real_file, "rb");
|
||||
if (!f)
|
||||
return 0;
|
||||
|
|
|
@ -457,12 +457,6 @@ load(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity,
|
|||
unsigned char *plane[40];
|
||||
ILBM ilbm;
|
||||
|
||||
/*----------
|
||||
* Do nothing if the data is already loaded.
|
||||
*----------*/
|
||||
if (im->data)
|
||||
return 0;
|
||||
|
||||
/*----------
|
||||
* Load the chunk(s) we're interested in. If full is not true, then we only
|
||||
* want the image size and format.
|
||||
|
|
|
@ -24,10 +24,6 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
|||
png_infop info_ptr = NULL;
|
||||
int bit_depth, color_type, interlace_type;
|
||||
|
||||
/* if immediate_load is 1, then don't delay image loading as below, or */
|
||||
/* already data in this image - don't load it again */
|
||||
if (im->data)
|
||||
return 0;
|
||||
f = fopen(im->real_file, "rb");
|
||||
if (!f)
|
||||
return 0;
|
||||
|
|
|
@ -36,8 +36,6 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
|||
char buf[256];
|
||||
FILE *f = NULL;
|
||||
|
||||
if (im->data)
|
||||
return 0;
|
||||
f = fopen(im->real_file, "rb");
|
||||
if (!f)
|
||||
return 0;
|
||||
|
|
|
@ -201,9 +201,6 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
|||
tga_header *header;
|
||||
tga_footer *footer;
|
||||
|
||||
if (im->data)
|
||||
return 0;
|
||||
|
||||
fd = open(im->real_file, O_RDONLY);
|
||||
if (fd < 0)
|
||||
return 0;
|
||||
|
|
|
@ -271,9 +271,6 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
|||
|
||||
ok = 0;
|
||||
|
||||
if (im->data)
|
||||
return 0;
|
||||
|
||||
file = fopen(im->real_file, "rb");
|
||||
if (!file)
|
||||
return 0;
|
||||
|
|
|
@ -111,14 +111,6 @@ load(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity,
|
|||
done = 0;
|
||||
transp = -1;
|
||||
|
||||
/* if immediate_load is 1, then dont delay image laoding as below, or */
|
||||
/* already data in this image - dont load it again */
|
||||
|
||||
if (im->data)
|
||||
{
|
||||
xpm_parse_done();
|
||||
return 0;
|
||||
}
|
||||
f = fopen(im->real_file, "rb");
|
||||
if (!f)
|
||||
{
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <assert.h>
|
||||
|
||||
#define OUTBUF_SIZE 16484
|
||||
|
||||
|
@ -48,8 +47,6 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
|||
char *real_ext;
|
||||
struct stat st;
|
||||
|
||||
assert(im);
|
||||
|
||||
/* check that this file ends in *.gz and that there's another ext
|
||||
* (e.g. "foo.png.gz"
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue