This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch master
in repository legacy-imlib2.
View the commit online.
commit f8a45104387184c7ec7e29f9e3164018443d6160
Author: Kim Woelders <k...@woelders.dk>
AuthorDate: Thu Mar 21 06:43:27 2024 +0100
imlib2_load: Add crc32 printout
For comparing results before/after loader changes.
---
src/bin/Makefile.am | 2 +-
src/bin/imlib2_load.c | 27 ++++++++++++++++++++++++++-
2 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am
index 4e0bbc7..effc09a 100644
--- a/src/bin/Makefile.am
+++ b/src/bin/Makefile.am
@@ -23,7 +23,7 @@ imlib2_conv_SOURCES = imlib2_conv.c $(SRCS_UTIL)
imlib2_conv_LDADD = $(top_builddir)/src/lib/libImlib2.la
imlib2_load_SOURCES = imlib2_load.c $(SRCS_UTIL)
-imlib2_load_LDADD = $(top_builddir)/src/lib/libImlib2.la $(CLOCK_LIBS)
+imlib2_load_LDADD = $(top_builddir)/src/lib/libImlib2.la -lz $(CLOCK_LIBS)
imlib2_show_SOURCES = imlib2_show.c $(SRCS_X11)
imlib2_show_LDADD = $(top_builddir)/src/lib/libImlib2.la -lX11 -lm
diff --git a/src/bin/imlib2_load.c b/src/bin/imlib2_load.c
index 3edfb96..81658d9 100644
--- a/src/bin/imlib2_load.c
+++ b/src/bin/imlib2_load.c
@@ -11,6 +11,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <zlib.h>
#include <sys/mman.h>
#include <sys/stat.h>
@@ -34,6 +35,7 @@ static FILE *fout;
"Usage:\n" \
" imlib2_load [OPTIONS] FILE...\n" \
"OPTIONS:\n" \
+ " -C : Print CRC32 of image data\n" \
" -c : Enable image caching\n" \
" -e : Break on error\n" \
" -f : Load with imlib_load_image_fd()\n" \
@@ -51,6 +53,21 @@ usage(void)
printf(HELP);
}
+static unsigned int
+image_get_crc32(Imlib_Image im)
+{
+ const unsigned char *data;
+ unsigned int crc, w, h;
+
+ imlib_context_set_image(im);
+ w = imlib_image_get_width();
+ h = imlib_image_get_height();
+ data = "" unsigned char *)imlib_image_get_data_for_reading_only();
+ crc = crc32(0, data, w * h * sizeof(uint32_t));
+
+ return crc;
+}
+
static Imlib_Image *
image_load_fd(const char *file, int *perr)
{
@@ -144,6 +161,7 @@ main(int argc, char **argv)
int load_cnt, cnt;
int load_mode;
bool opt_cache;
+ bool show_crc;
fout = stdout;
verbose = 0;
@@ -153,11 +171,15 @@ main(int argc, char **argv)
load_cnt = 1;
load_mode = LOAD_DEFER;
opt_cache = false;
+ show_crc = false;
- while ((opt = getopt(argc, argv, "cefijmn:pvx")) != -1)
+ while ((opt = getopt(argc, argv, "Ccefijmn:pvx")) != -1)
{
switch (opt)
{
+ case 'C':
+ show_crc = true;
+ break;
case 'c':
opt_cache = true;
break;
@@ -278,6 +300,9 @@ main(int argc, char **argv)
}
}
+ if (cnt == 0 && show_crc)
+ printf("%08x %s\n", image_get_crc32(im), argv[0]);
+
if (opt_cache)
imlib_free_image();
else
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.