aboutsummaryrefslogtreecommitdiffstats
path: root/image.c
diff options
context:
space:
mode:
authorN-R-K <79544946+N-R-K@users.noreply.github.com>2021-10-28 22:00:53 +0200
committerGitHub <noreply@github.com>2021-10-28 22:00:53 +0200
commit850bc788c3fd4bb96f425ceedfe4237754cabe46 (patch)
tree8007a27013fe67601640e257310161a2c254f3ba /image.c
parent03eb664e89d01cb9a28a9a2dcbad6aac208fa03b (diff)
downloadnsxiv-850bc788c3fd4bb96f425ceedfe4237754cabe46.tar.zst
code-style: general cleanups (#137)
* tns_clean_cache: remove unused function arg * remove malloc casting * improve consistency use sizeof(T) at the end * avoid comparing integers of different signedness * use Window type for embed and parent * remove unnecessary comparisons * remove cpp style comments * improve consistency: remove comma from the end of enumerator list * Removed useless _IMAGE_CONFIG defines * consistency: use the same order as snprintf * Resolve c89 warnings Co-authored-by: uidops <uidops@protonmail.com> Co-authored-by: Arthur Williams <taaparthur@gmail.com>
Diffstat (limited to 'image.c')
-rw-r--r--image.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/image.c b/image.c
index 776840d..2926a1f 100644
--- a/image.c
+++ b/image.c
@@ -135,8 +135,7 @@ bool img_load_gif(img_t *img, const fileinfo_t *file)
if (img->multi.cap == 0) {
img->multi.cap = 8;
- img->multi.frames = (img_frame_t*)
- emalloc(sizeof(img_frame_t) * img->multi.cap);
+ img->multi.frames = emalloc(img->multi.cap * sizeof(img_frame_t));
}
img->multi.cnt = img->multi.sel = 0;
img->multi.length = 0;
@@ -188,9 +187,9 @@ bool img_load_gif(img_t *img, const fileinfo_t *file)
w = gif->Image.Width;
h = gif->Image.Height;
- rows = (GifRowType*) emalloc(h * sizeof(GifRowType));
+ rows = emalloc(h * sizeof(GifRowType));
for (i = 0; i < h; i++)
- rows[i] = (GifRowType) emalloc(w * sizeof(GifPixelType));
+ rows[i] = emalloc(w * sizeof(GifPixelType));
if (gif->Image.Interlace) {
for (i = 0; i < 4; i++) {
for (j = intoffset[i]; j < h; j += intjump[i])
@@ -201,7 +200,7 @@ bool img_load_gif(img_t *img, const fileinfo_t *file)
DGifGetLine(gif, rows[i], w);
}
- ptr = data = (DATA32*) emalloc(sizeof(DATA32) * sw * sh);
+ ptr = data = emalloc(sw * sh * sizeof(DATA32));
cmap = gif->Image.ColorMap ? gif->Image.ColorMap : gif->SColorMap;
if (bg >= cmap->ColorCount) {
err = true;
@@ -258,8 +257,7 @@ bool img_load_gif(img_t *img, const fileinfo_t *file)
if (img->multi.cnt == img->multi.cap) {
img->multi.cap *= 2;
- img->multi.frames = (img_frame_t*)
- erealloc(img->multi.frames,
+ img->multi.frames = erealloc(img->multi.frames,
img->multi.cap * sizeof(img_frame_t));
}
img->multi.frames[img->multi.cnt].im = im;
@@ -322,7 +320,6 @@ bool img_load_webp(const fileinfo_t *file, Imlib_Image *fframe, img_t *img)
{
FILE *webp_file;
WebPData data;
- data.bytes = NULL;
Imlib_Image im = NULL;
struct WebPAnimDecoderOptions opts;
@@ -335,6 +332,7 @@ bool img_load_webp(const fileinfo_t *file, Imlib_Image *fframe, img_t *img)
unsigned long flags;
unsigned int delay;
bool err = false;
+ data.bytes = NULL;
if ((err = fframe == NULL && img == NULL))
goto fail;
@@ -863,7 +861,7 @@ bool img_change_gamma(img_t *img, int d)
if (img->gamma != gamma) {
imlib_reset_color_modifier();
- if (gamma != 0) {
+ if (gamma) {
range = gamma <= 0 ? 1.0 : GAMMA_MAX - 1.0;
imlib_modify_color_modifier_gamma(1.0 + gamma * (range / GAMMA_RANGE));
}