[gimp] plug-ins: fix #1351 Raw Data Import Creates Blank/White Image...
- From: Jacob Boerema <jboerema src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] plug-ins: fix #1351 Raw Data Import Creates Blank/White Image...
- Date: Mon, 16 May 2022 18:00:29 +0000 (UTC)
commit 3644b9010aff6ed25270d323c46588d500911711
Author: Jacob Boerema <jgboerema gmail com>
Date: Mon May 16 14:00:10 2022 -0400
plug-ins: fix #1351 Raw Data Import Creates Blank/White Image...
when Offset and Dimensions Bigger than File Size.
If we didn't read the exact amount of bytes, the whole image would be
filled with white.
Let's change this, so we read as much bytes as we can, and fill the rest
with white.
plug-ins/common/file-raw-data.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
---
diff --git a/plug-ins/common/file-raw-data.c b/plug-ins/common/file-raw-data.c
index 82dc65a970..1b3643b355 100644
--- a/plug-ins/common/file-raw-data.c
+++ b/plug-ins/common/file-raw-data.c
@@ -661,12 +661,15 @@ raw_read_row (FILE *fp,
gint32 offset,
gint32 size)
{
+ size_t bread;
+
fseek (fp, offset, SEEK_SET);
- if (! fread (buf, size, 1, fp))
+ memset (buf, 0xFF, size);
+ bread = fread (buf, 1, size, fp);
+ if (bread < size)
{
- g_printerr ("fread failed\n");
- memset (buf, 0xFF, size);
+ g_printerr ("fread failed: read %u instead of %u bytes\n", (guint) bread, (guint) size);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]