public inbox for xconq7@sourceware.org
 help / color / mirror / Atom feed
* Fix for "auto-generated images appear as black" bug
@ 2004-11-25  7:07 mskala
  2004-11-27  0:33 ` Eric McDonald
  0 siblings, 1 reply; 2+ messages in thread
From: mskala @ 2004-11-25  7:07 UTC (permalink / raw)
  To: xconq7, xconq-hackers

[-- 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;

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Fix for "auto-generated images appear as black" bug
  2004-11-25  7:07 Fix for "auto-generated images appear as black" bug mskala
@ 2004-11-27  0:33 ` Eric McDonald
  0 siblings, 0 replies; 2+ messages in thread
From: Eric McDonald @ 2004-11-27  0:33 UTC (permalink / raw)
  To: mskala; +Cc: xconq7, xconq-hackers

Hi Matthew,

mskala@ansuz.sooke.bc.ca wrote:

> 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.

Yes, it is definitely an improvement.

Patch read, understood, applied, tested, and committed.

   Thanks,
      Eric

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-11-25  7:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-11-25  7:07 Fix for "auto-generated images appear as black" bug mskala
2004-11-27  0:33 ` Eric McDonald

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).