public inbox for xconq7@sourceware.org
 help / color / mirror / Atom feed
From: mskala@ansuz.sooke.bc.ca
To: xconq7@sources.redhat.com, xconq-hackers@lists.sourceforge.net
Subject: Fix for "auto-generated images appear as black" bug
Date: Thu, 25 Nov 2004 07:07:00 -0000	[thread overview]
Message-ID: <Pine.LNX.4.21.0411242136590.4915-200000@diamond.ansuz.sooke.bc.ca> (raw)

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1418 bytes --]

Attached is a patch for imf.c to fix the bug I was talking about.  This
definitely fixes it in the TCL/TK interface; I haven't tested it with the
SDL interface yet.  The issue is that many parts of the image data
structure are initialized to zeros and then filled in with actual data on
demand.  In particular, there's a structure called a TkImage which has to
be filled in for the image to be used in TK, but doing so depends on the
image's palette, and that's supposed to be copied from the image's parent,
but the code that does the copying copies it *before* checking whether the
palette has been calculated at all.  So if the parent's palette hasn't
been calculated yet, then the zeros are copied to the child, and even
though the parent's palette is calculated later, that doesn't help the
child, which is stuck with a zero palette, causing the TkImage code to
abort later.

Anyway, there are a few lines that have to be re-arranged to fix it, and
this patch does that.  Other bugs are made more visible by this patch (in
particular, the "choose one subimage at random" code doesn't work with
shrunken or magnified images), and *really* shrunken images (like, down to
a single pixel as used at very low magnificatons) don't happen because of
hardcoded limits elsewhere, but at least it's an improvement.
-- 
Matthew Skala
mskala@ansuz.sooke.bc.ca                    Embrace and defend.
http://ansuz.sooke.bc.ca/

[-- Attachment #2: Type: TEXT/PLAIN, Size: 992 bytes --]

diff -r1.1.1.1 imf.c
784,789d783
<     img2->pixelsize = img->pixelsize;
<     img2->palette = img->palette;
<     img2->rawpalette = img->rawpalette;
<     img2->numcolors = img->numcolors;
<     /* Mark the image as having been computed rather than read in. */
<     img2->synthetic = TRUE;
799a794,799
>     img2->pixelsize = img->pixelsize;
>     img2->palette = img->palette;
>     img2->rawpalette = img->rawpalette;
>     img2->numcolors = img->numcolors;
>     /* Mark the image as having been computed rather than read in. */
>     img2->synthetic = TRUE;
891,895d890
<     img2->pixelsize = img->pixelsize;
<     img2->palette = img->palette;
<     img2->rawpalette = img->rawpalette;
<     img2->numcolors = img->numcolors;
<     img2->synthetic = TRUE;
905a901,905
>     img2->pixelsize = img->pixelsize;
>     img2->palette = img->palette;
>     img2->rawpalette = img->rawpalette;
>     img2->numcolors = img->numcolors;
>     img2->synthetic = TRUE;

             reply	other threads:[~2004-11-25  2:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-11-25  7:07 mskala [this message]
2004-11-27  0:33 ` Eric McDonald

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.21.0411242136590.4915-200000@diamond.ansuz.sooke.bc.ca \
    --to=mskala@ansuz.sooke.bc.ca \
    --cc=xconq-hackers@lists.sourceforge.net \
    --cc=xconq7@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).