www.delorie.com/archives/browse.cgi   search  
Mail Archives: geda-user/2025/05/21/21:57:20

DMARC-Filter: OpenDMARC Filter v1.4.2 delorie.com 54M1ssU63962074
Authentication-Results: delorie.com; dmarc=none (p=none dis=none) header.from=delorie.com
Authentication-Results: delorie.com; spf=pass smtp.mailfrom=delorie.com
X-Authentication-Warning: delorie.com: mail set sender to geda-user-bounces using -f
DMARC-Filter: OpenDMARC Filter v1.4.2 delorie.com 54M1ssj33962042
Authentication-Results: delorie.com; dmarc=pass (p=reject dis=none) header.from=a1.net
Authentication-Results: delorie.com; spf=pass smtp.mailfrom=a1.net
DKIM-Filter: OpenDKIM Filter v2.11.0 delorie.com 54M1ssj33962042
Authentication-Results: delorie.com;
dkim=pass (4096-bit key, unprotected) header.d=a1.net header.i=@a1.net header.a=rsa-sha256 header.s=resmail1 header.b=lJ76yGhO
X-Recipient: geda-user AT delorie DOT com
X-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=a1.net; s=resmail1;
t=1747878891;
h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
to:to:cc:mime-version:mime-version:content-type:content-type:
content-transfer-encoding:content-transfer-encoding;
bh=y37Iu+UiHmfER4mcKCAx/ceyodyDPLDe6zDmigewf1U=;
b=lJ76yGhO/GGs2y4DfycsP8z32kiHL8QoAH6RIA/1WtEuuM+KOzIZK2xEsIhSlMQgDO9C9F
I40qlBrcdKtu6+omaEbLkVoFzQ68LiwGf4yx7reu9CYtqM+b7Zrd0mxIU8/UkpDIggAAIc
Ycf47qwWF8Akn35HmiSTfzpAE2J3D/D47oFZpaJQhrkCMLwMXWb5PWIyOza+BhiwsV+B7G
lw3s5rKnyxb2scYrhYm9CCo97GHZaAL4LB2JS3JaUWpwvzV1NpMNDzj3qEbvAe/TSHS20I
Y2tG96UAda8UTSn+FqQUXAvnuwmEqMxLiZyIXo9NurCy9kMZmxIZfmosCNu3UbAwpsW2DY
9ufh7RJ81pRgFNH8KVWL9SkgBRX/YQullQpvSwqKmqR0ilmkcRFR26bwwvKUgjgSnKR//P
0KSO6RHSmp+h+zi1GFtQFiT6DLUhfK+98orpAIbFxAHVb2QePndxs6t/sZ6o4Dua9YqjCf
KZlcSnmM8NGekvomRMg/jl544Vpwb61Xx55D1Maff3nH9bRBAEEK6ndkohrLPsNQiDXRVR
HNNHjPKrlyAHeVveGU8W3tLFGfA45ojrtKkWbCrLLNjGTIYDF6h6Ib9YQSnfbXYMxLzOwR
pSEO+w6eI5ySRa7yJfYad+dHEFxi8cNSHOezu+esqu0Bc1CSE8bN4=
Message-ID: <a4df2934-41ed-4eb2-8d1d-394e21520a1c@a1.net>
Date: Thu, 22 May 2025 03:54:33 +0200
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
From: "Johann Klammer (klammerj AT a1 DOT net) [via geda-user AT delorie DOT com]" <geda-user AT delorie DOT com>
Subject: [geda-user] --bg-image crashes pcb (lesstif gui)
To: geda-user AT delorie DOT com
X-Spam-Level: **
Reply-To: geda-user AT delorie DOT com

I tried loading a P6 pixmap as indicated in the documentation but got:

Program received signal SIGSEGV, Segmentation fault.
0x0000555555641742 in DrawBackgroundImage () at hid/lesstif/main.c:1155
1155              XPutPixel (bgi, x, y, bg[ir][ic]);

ir=-190
ic=0

very first iteration
x=0
(gdb) p pr
$9 = -6946757

increasing the board height makes it load. but scaling seems off..
zooming causes crash.

scaling down the image does not help.

This seems to fix things:

static unsigned long PickBgPixel(Pixel **bg,int rows,int cols,int r,int c)
{
        if((r<rows)&&(r>=0)&&(c<cols)&&(c>=0))return bg[r][c];
        else return bgcolor;
}

static void
DrawBackgroundImage ()
{
  int x, y, w, h;
  double xscale, yscale;

  if (!window || !bg)
    return;

  if (!bgi || view_width != bgi_w || view_height != bgi_h)
    {
      if (bgi)
        XDestroyImage (bgi);
      /* Cheat - get the image, which sets up the format too.  */
      bgi = XGetImage (XtDisplay(work_area),
                       window,
                       0, 0, view_width, view_height,
                       -1, ZPixmap);
      bgi_w = view_width;
      bgi_h = view_height;
    }

  w = view_width;
  h = view_height;

  xscale = (double)bg_w / PCB->MaxWidth;
  yscale = (double)bg_h / PCB->MaxHeight;

  for (y=0; y<h; y++)
    {
      int pr = Py(y);
      int ir = pr * yscale;
      for (x=0; x<w; x++)
        {
          int pc = Px(x);
          int ic = pc * xscale;
          XPutPixel (bgi, x, y, PickBgPixel(bg,bg_h,bg_w,ir,ic));
        }
    }
  XPutImage(display, main_pixmap, bg_gc,
            bgi,
            0, 0, 0, 0, w, h);
}

(my source tree is too hosed to be able to format a proper diff...)

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019