I'd like to post one more patch. In this patch, --only-visible is
working for photo-mode.
Here is a (1.5MB!) 300 dpi render prepared with the following snippet
of my ever-expanding pcb Makefile:
http://live.midwesttelecine.com/pcb-render.png
DPI=300
OVERSAMPLE=2
PCB=/home/markrages/src/pcb/src/pcb
PCBOPTS= -x png --photo-mode --dpi $(shell echo $$((
$(OVERSAMPLE)*$(DPI) ))) --use-alpha --only-visible
$(BOARD_NAME)-front.png: $(BOARD_NAME).pcb
$(PCB) $(PCBOPTS) $(BOARD_NAME).pcb
$(BOARD_NAME)-back.png: $(BOARD_NAME).pcb
$(PCB) $(PCBOPTS) --outfile $(BOARD_NAME)-back.png --photo-flip-x
--photo-flip-y $(BOARD_NAME).pcb
$(BOARD_NAME)-render.png: $(BOARD_NAME)-front.png $(BOARD_NAME)-back.png
montage $(BOARD_NAME)-front.png $(BOARD_NAME)-back.png -tile x1
-shadow -geometry "+50+50" -resize $(shell echo $$(( 100 /
$(OVERSAMPLE))))% -background lightblue $(BOARD_NAME)-render.png
Regards,
Mark
markra...@gmail
--
Mark Rages, Engineer
Midwest Telecine LLC
[email protected]
Index: png.c
===================================================================
RCS file: /cvsroot/pcb/pcb/src/hid/png/png.c,v
retrieving revision 1.30
diff -u -r1.30 png.c
--- png.c 27 Dec 2008 16:30:04 -0000 1.30
+++ png.c 10 Jan 2009 21:46:48 -0000
@@ -112,6 +112,7 @@
static int photo_mode, photo_flip;
static gdImagePtr photo_copper[MAX_LAYER+2];
static gdImagePtr photo_silk, photo_mask, photo_drill, *photo_im;
+static gdImagePtr photo_outline;
static int photo_groups[MAX_LAYER+2], photo_ngroups;
#define FMT_gif "GIF"
@@ -288,7 +289,7 @@
region.Y2 = PCB->MaxHeight;
if (options[HA_only_visible].int_value)
- bounds = GetDataBoundingBox (PCB->Data);
+ bounds = GetDataBoundingBox (PCB->Data);
else
bounds = ®ion;
@@ -474,9 +475,9 @@
photo_mode = 1;
options[HA_mono].int_value = 1;
options[HA_as_shown].int_value = 0;
- options[HA_only_visible].int_value = 0;
memset (photo_copper, 0, sizeof(photo_copper));
photo_silk = photo_mask = photo_drill = 0;
+ photo_outline = 0;
if (options[HA_photo_flip_x].int_value
|| options[HA_ben_flip_x].int_value)
photo_flip = PHOTO_FLIP_X;
@@ -639,87 +640,126 @@
ts_bs (photo_silk);
ts_bs_sm (photo_mask);
- for (x=0; x<gdImageSX (im); x++)
- for (y=0; y<gdImageSY (im); y++)
- {
- color_struct p, cop;
- int cc, mask, silk;
+ if (photo_outline) {
+ int black=gdImageColorResolve(photo_outline, 0x00, 0x00, 0x00);
- mask = photo_mask ? gdImageGetPixel (photo_mask, x, y) : 0;
- silk = photo_silk ? gdImageGetPixel (photo_silk, x, y) : 0;
+ // go all the way around the image, trying to fill the outline
+ for (x=0; x<gdImageSX(im); x++) {
+ gdImageFillToBorder(photo_outline, x, 0, black, black);
+ gdImageFillToBorder(photo_outline, x, gdImageSY(im)-1, black, black);
+ }
+ for (y=1; y<gdImageSY(im)-1; y++) {
+ gdImageFillToBorder(photo_outline, 0, y, black, black);
+ gdImageFillToBorder(photo_outline, gdImageSX(im)-1, y, black, black);
- if (gdImageGetPixel (photo_copper[photo_groups[1]], x, y))
- rgb (&cop, 40, 40, 40);
- else
- rgb (&cop, 100, 100, 110);
-
- if (photo_ngroups == 2)
- blend (&cop, 0.3, &cop, &fr4);
-
- cc = gdImageGetPixel (photo_copper[photo_groups[0]], x, y);
- if (cc)
- {
- int r;
-
- if (mask)
- rgb (&cop, 220, 145, 230);
- else
- {
- rgb (&cop, 140, 150, 160);
-#if 1
- r = (random() % 5 - 2) * 2;
- cop.r += r;
- cop.g += r;
- cop.b += r;
-#endif
- }
+ }
+ }
- if (cc == TOP_SHADOW)
- {
- cop.r = 255 - (255 - cop.r) * 0.7;
- cop.g = 255 - (255 - cop.g) * 0.7;
- cop.b = 255 - (255 - cop.b) * 0.7;
- }
- if (cc == BOTTOM_SHADOW)
- {
- cop.r *= 0.7;
- cop.g *= 0.7;
- cop.b *= 0.7;
- }
- }
- if (photo_drill && !gdImageGetPixel (photo_drill, x, y))
- rgb (&p, 0, 0, 0);
- else if (silk)
- {
- if (silk == TOP_SHADOW)
- rgb (&p, 255, 255, 255);
- else if (silk == BOTTOM_SHADOW)
- rgb (&p, 192, 192, 192);
- else
- rgb (&p, 224, 224, 224);
+ for (x=0; x<gdImageSX (im); x++)
+ {
+ for (y=0; y<gdImageSY (im); y++)
+ {
+ color_struct p, cop;
+ int cc, mask, silk;
+ int transparent;
+
+ if (photo_outline) {
+ transparent=gdImageGetPixel(photo_outline, x, y);
+ } else {
+ transparent=0;
}
- else if (mask)
- {
+
+ mask = photo_mask ? gdImageGetPixel (photo_mask, x, y) : 0;
+ silk = photo_silk ? gdImageGetPixel (photo_silk, x, y) : 0;
+
+ if (gdImageGetPixel (photo_copper[photo_groups[1]], x, y))
+ rgb (&cop, 40, 40, 40);
+ else
+ rgb (&cop, 100, 100, 110);
+
+ if (photo_ngroups == 2)
+ blend (&cop, 0.3, &cop, &fr4);
+
+ cc = gdImageGetPixel (photo_copper[photo_groups[0]], x, y);
+ if (cc)
+ {
+ int r;
+
+ if (mask)
+ rgb (&cop, 220, 145, 230);
+ else
+ {
+ rgb (&cop, 140, 150, 160);
+#if 1
+ r = (random() % 5 - 2) * 2;
+ cop.r += r;
+ cop.g += r;
+ cop.b += r;
+#endif
+ }
+
+ if (cc == TOP_SHADOW)
+ {
+ cop.r = 255 - (255 - cop.r) * 0.7;
+ cop.g = 255 - (255 - cop.g) * 0.7;
+ cop.b = 255 - (255 - cop.b) * 0.7;
+ }
+ if (cc == BOTTOM_SHADOW)
+ {
+ cop.r *= 0.7;
+ cop.g *= 0.7;
+ cop.b *= 0.7;
+ }
+ }
+
+ if (photo_drill && !gdImageGetPixel (photo_drill, x, y))
+ {
+ rgb (&p, 0, 0, 0);
+ transparent=1;
+ }
+ else if (silk)
+ {
+ if (silk == TOP_SHADOW)
+ rgb (&p, 255, 255, 255);
+ else if (silk == BOTTOM_SHADOW)
+ rgb (&p, 192, 192, 192);
+ else
+ rgb (&p, 224, 224, 224);
+ }
+ else if (mask)
+ {
+ p = cop;
+ p.r /= 2;
+ p.b /= 2;
+ if (mask == TOP_SHADOW)
+ blend (&p, 0.7, &p, &white);
+ if (mask == BOTTOM_SHADOW)
+ blend (&p, 0.7, &p, &black);
+ }
+ else
p = cop;
- p.r /= 2;
- p.b /= 2;
- if (mask == TOP_SHADOW)
- blend (&p, 0.7, &p, &white);
- if (mask == BOTTOM_SHADOW)
- blend (&p, 0.7, &p, &black);
- }
- else
- p = cop;
+
+ if (options[HA_use_alpha].int_value) {
- cc = gdImageColorResolve (im, p.r, p.g, p.b);
- if (photo_flip == PHOTO_FLIP_X)
- gdImageSetPixel (im, gdImageSX (im) - x - 1, y, cc);
- else if (photo_flip == PHOTO_FLIP_Y)
- gdImageSetPixel (im, x, gdImageSY (im) - y - 1, cc);
- else
- gdImageSetPixel (im, x, y, cc);
- }
+ cc = (transparent)?\
+ gdImageColorResolveAlpha(im, 0, 0, 0, 127):\
+ gdImageColorResolveAlpha(im, p.r, p.g, p.b, 0);
+
+ } else {
+ cc = (transparent)?\
+ gdImageColorResolve(im, 0, 0, 0):\
+ gdImageColorResolve(im, p.r, p.g, p.b);
+ }
+
+ if (photo_flip == PHOTO_FLIP_X)
+ gdImageSetPixel (im, gdImageSX (im) - x - 1, y, cc);
+ else if (photo_flip == PHOTO_FLIP_Y)
+ gdImageSetPixel (im, x, gdImageSY (im) - y - 1, cc);
+ else
+ gdImageSetPixel (im, x, y, cc);
+ }
+ }
}
/* actually write out the image */
@@ -833,7 +873,12 @@
default:
if (idx < 0)
return 0;
- photo_im = photo_copper + group;
+
+ if (strcasecmp (name, "outline") == 0)
+ photo_im = &photo_outline;
+ else
+ photo_im = photo_copper + group;
+
break;
}
@@ -1052,7 +1097,7 @@
bg = gdImageColorAllocate (gc->brush, 255, 255, 255);
fg =
gdImageColorAllocateAlpha (gc->brush, gc->color->r, gc->color->g,
- gc->color->b, gc->color->a);
+ gc->color->b, 0);
gdImageColorTransparent (gc->brush, bg);
/*
_______________________________________________
geda-dev mailing list
[email protected]
http://www.seul.org/cgi-bin/mailman/listinfo/geda-dev