mirror of https://github.com/GNOME/gimp.git
patches from Martin Weber and Peter Kirchgessner
This commit is contained in:
parent
83ddc3fa06
commit
2481607268
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
Sat Mar 25 21:09:40 CET 2000 Stanislav Brabec <utx@penguin.cz>
|
||||
* plug-ins/common/ps.c: Applied changes from Peter
|
||||
Kirchgessner (V 1.10).
|
||||
|
||||
Sat Mar 25 20:57:24 CET 2000 Stanislav Brabec <utx@penguin.cz>
|
||||
|
||||
On request of Martin Weber <martweb@gmx.net>:
|
||||
* app/convert.c: Speedups.
|
||||
* app/paths_dialog.c: Include string.h.
|
||||
|
||||
2000-03-25 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* README.i18n: added new sections explaining what catalogs
|
||||
|
|
113
app/convert.c
113
app/convert.c
|
@ -25,6 +25,7 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* 2000/03/24 - Some speedups [Martin]
|
||||
* 2000/01/30 - Use palette_selector instead of option_menu for custom
|
||||
* palette. Use libgimp callback functions. [Sven]
|
||||
*
|
||||
|
@ -128,9 +129,13 @@
|
|||
#define B_SHIFT (BITS_IN_SAMPLE-PRECISION_B)
|
||||
|
||||
/* this has to match the INTENSITY definition in libgimp/gimpcolorspace.h */
|
||||
#define R_SCALE 30 /* scale R distances by this much */
|
||||
#define G_SCALE 59 /* scale G distances by this much */
|
||||
#define B_SCALE 11 /* and B by this much */
|
||||
/* #define R_SCALE 30 */ /* scale R distances by this much */
|
||||
/* #define G_SCALE 59 */ /* scale G distances by this much */
|
||||
/* #define B_SCALE 11 */ /* and B by this much */
|
||||
/* not as precise as the above devlaration but much faster */
|
||||
#define R_SCALE << 2 /* *4 = 36% */
|
||||
#define G_SCALE * 6 /* *6 = 55% */
|
||||
#define B_SCALE /* *1 = 9 % */
|
||||
|
||||
static const unsigned char webpal[] =
|
||||
{
|
||||
|
@ -1811,20 +1816,20 @@ find_split_candidate (boxptr boxlist,
|
|||
{
|
||||
if (boxp->volume > 0)
|
||||
{
|
||||
if (boxp->gerror*G_SCALE > maxc)
|
||||
if (boxp->gerror G_SCALE > maxc)
|
||||
{
|
||||
which = boxp;
|
||||
maxc = boxp->gerror*G_SCALE;
|
||||
maxc = boxp->gerror G_SCALE;
|
||||
}
|
||||
if (boxp->rerror*R_SCALE > maxc)
|
||||
if (boxp->rerror R_SCALE > maxc)
|
||||
{
|
||||
which = boxp;
|
||||
maxc = boxp->rerror*R_SCALE;
|
||||
maxc = boxp->rerror R_SCALE;
|
||||
}
|
||||
if (boxp->berror*B_SCALE > maxc)
|
||||
if (boxp->berror B_SCALE > maxc)
|
||||
{
|
||||
which = boxp;
|
||||
maxc = boxp->berror*B_SCALE;
|
||||
maxc = boxp->berror B_SCALE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2028,9 +2033,9 @@ update_box_rgb (Histogram histogram,
|
|||
* we have to shift back to JSAMPLE units to get consistent distances;
|
||||
* after which, we scale according to the selected distance scale factors.
|
||||
*/
|
||||
dist0 = (( + Rmax - Rmin) << R_SHIFT) * R_SCALE;
|
||||
dist1 = (( + Gmax - Gmin) << G_SHIFT) * G_SCALE;
|
||||
dist2 = (( + Bmax - Bmin) << B_SHIFT) * B_SCALE;
|
||||
dist0 = (( + Rmax - Rmin) << R_SHIFT) R_SCALE;
|
||||
dist1 = (( + Gmax - Gmin) << G_SHIFT) G_SCALE;
|
||||
dist2 = (( + Bmax - Bmin) << B_SHIFT) B_SCALE;
|
||||
boxp->volume = dist0*dist0 + dist1*dist1 + dist2*dist2;
|
||||
|
||||
compute_color_rgb(&dummyqo, histogram, boxp, 0);
|
||||
|
@ -2068,7 +2073,7 @@ update_box_rgb (Histogram histogram,
|
|||
|
||||
boxp->error += (*histp) *
|
||||
(
|
||||
re*re*R_SCALE + ge*ge*G_SCALE + be*be*B_SCALE
|
||||
(re*re R_SCALE) + (ge*ge G_SCALE) + (be*be B_SCALE)
|
||||
);
|
||||
|
||||
ccount += *histp;
|
||||
|
@ -2096,7 +2101,7 @@ update_box_rgb (Histogram histogram,
|
|||
|
||||
tempRerror += (*histp)*re*re;
|
||||
|
||||
if (tempRerror*2 > boxp->rerror)
|
||||
if ((tempRerror<<1) > boxp->rerror)
|
||||
goto green_axisscan;
|
||||
else
|
||||
boxp->Rhalferror = R;
|
||||
|
@ -2126,7 +2131,7 @@ update_box_rgb (Histogram histogram,
|
|||
|
||||
tempGerror += (*histp)*ge*ge;
|
||||
|
||||
if (tempGerror*2 > boxp->gerror)
|
||||
if ((tempGerror<<1) > boxp->gerror)
|
||||
goto blue_axisscan;
|
||||
else
|
||||
boxp->Ghalferror = G;
|
||||
|
@ -2157,7 +2162,7 @@ update_box_rgb (Histogram histogram,
|
|||
|
||||
tempBerror += (*histp)*be*be;
|
||||
|
||||
if (tempBerror*2 > boxp->berror)
|
||||
if ((tempBerror<<1) > boxp->berror)
|
||||
goto finished_axesscan;
|
||||
else
|
||||
boxp->Bhalferror = B;
|
||||
|
@ -2205,7 +2210,7 @@ median_cut_gray (Histogram histogram,
|
|||
* Current algorithm: by population for first half, then by volume.
|
||||
*/
|
||||
#if 0
|
||||
if (numboxes*2 <= desired_colors)
|
||||
if ((numboxes<<1) <= desired_colors)
|
||||
{
|
||||
b1 = find_biggest_color_pop (boxlist, numboxes);
|
||||
}
|
||||
|
@ -2257,7 +2262,7 @@ median_cut_rgb (Histogram histogram,
|
|||
/* Select box to split.
|
||||
* Current algorithm: by population for first half, then by volume.
|
||||
*/
|
||||
if (1 || numboxes*2 <= desired_colors)
|
||||
if (1 || (numboxes<<1) <= desired_colors)
|
||||
{
|
||||
g_print ("O ");
|
||||
b1 = find_biggest_color_pop (boxlist, numboxes);
|
||||
|
@ -2284,9 +2289,9 @@ median_cut_rgb (Histogram histogram,
|
|||
// G = ((b1->Gmax - b1->Gmin) << G_SHIFT) * G_SCALE;
|
||||
//B = ((b1->Bmax - b1->Bmin) << B_SHIFT) * B_SCALE;
|
||||
*/
|
||||
R = R_SCALE*b1->rerror;/* * (((b1->Rmax - b1->Rmin) << R_SHIFT)) * R_SCALE; */
|
||||
G = G_SCALE*b1->gerror;/* * (((b1->Gmax - b1->Gmin) << G_SHIFT)) * G_SCALE; */
|
||||
B = B_SCALE*b1->berror;/* * (((b1->Bmax - b1->Bmin) << B_SHIFT)) * B_SCALE; */
|
||||
R = b1->rerror R_SCALE;/* * (((b1->Rmax - b1->Rmin) << R_SHIFT)) * R_SCALE; */
|
||||
G = b1->gerror G_SCALE;/* * (((b1->Gmax - b1->Gmin) << G_SHIFT)) * G_SCALE; */
|
||||
B = b1->berror B_SCALE;/* * (((b1->Bmax - b1->Bmin) << B_SHIFT)) * B_SCALE; */
|
||||
/* We want to break any ties in favor of green, then red, blue last.
|
||||
*/
|
||||
cmax = G; n = 1;
|
||||
|
@ -2619,67 +2624,67 @@ find_nearby_colors (QuantizeObj *quantobj,
|
|||
/* We compute the squared-R-distance term, then add in the other two. */
|
||||
x = quantobj->cmap[i].red;
|
||||
if (x < minR) {
|
||||
tdist = (x - minR) * R_SCALE;
|
||||
tdist = (x - minR) R_SCALE;
|
||||
min_dist = tdist*tdist;
|
||||
tdist = (x - maxR) * R_SCALE;
|
||||
tdist = (x - maxR) R_SCALE;
|
||||
max_dist = tdist*tdist;
|
||||
} else if (x > maxR) {
|
||||
tdist = (x - maxR) * R_SCALE;
|
||||
tdist = (x - maxR) R_SCALE;
|
||||
min_dist = tdist*tdist;
|
||||
tdist = (x - minR) * R_SCALE;
|
||||
tdist = (x - minR) R_SCALE;
|
||||
max_dist = tdist*tdist;
|
||||
} else {
|
||||
/* within cell range so no contribution to min_dist */
|
||||
min_dist = 0;
|
||||
if (x <= centerR) {
|
||||
tdist = (x - maxR) * R_SCALE;
|
||||
tdist = (x - maxR) R_SCALE;
|
||||
max_dist = tdist*tdist;
|
||||
} else {
|
||||
tdist = (x - minR) * R_SCALE;
|
||||
tdist = (x - minR) R_SCALE;
|
||||
max_dist = tdist*tdist;
|
||||
}
|
||||
}
|
||||
|
||||
x = quantobj->cmap[i].green;
|
||||
if (x < minG) {
|
||||
tdist = (x - minG) * G_SCALE;
|
||||
tdist = (x - minG) G_SCALE;
|
||||
min_dist += tdist*tdist;
|
||||
tdist = (x - maxG) * G_SCALE;
|
||||
tdist = (x - maxG) G_SCALE;
|
||||
max_dist += tdist*tdist;
|
||||
} else if (x > maxG) {
|
||||
tdist = (x - maxG) * G_SCALE;
|
||||
tdist = (x - maxG) G_SCALE;
|
||||
min_dist += tdist*tdist;
|
||||
tdist = (x - minG) * G_SCALE;
|
||||
tdist = (x - minG) G_SCALE;
|
||||
max_dist += tdist*tdist;
|
||||
} else {
|
||||
/* within cell range so no contribution to min_dist */
|
||||
if (x <= centerG) {
|
||||
tdist = (x - maxG) * G_SCALE;
|
||||
tdist = (x - maxG) G_SCALE;
|
||||
max_dist += tdist*tdist;
|
||||
} else {
|
||||
tdist = (x - minG) * G_SCALE;
|
||||
tdist = (x - minG) G_SCALE;
|
||||
max_dist += tdist*tdist;
|
||||
}
|
||||
}
|
||||
|
||||
x = quantobj->cmap[i].blue;
|
||||
if (x < minB) {
|
||||
tdist = (x - minB) * B_SCALE;
|
||||
tdist = (x - minB) B_SCALE;
|
||||
min_dist += tdist*tdist;
|
||||
tdist = (x - maxB) * B_SCALE;
|
||||
tdist = (x - maxB) B_SCALE;
|
||||
max_dist += tdist*tdist;
|
||||
} else if (x > maxB) {
|
||||
tdist = (x - maxB) * B_SCALE;
|
||||
tdist = (x - maxB) B_SCALE;
|
||||
min_dist += tdist*tdist;
|
||||
tdist = (x - minB) * B_SCALE;
|
||||
tdist = (x - minB) B_SCALE;
|
||||
max_dist += tdist*tdist;
|
||||
} else {
|
||||
/* within cell range so no contribution to min_dist */
|
||||
if (x <= centerB) {
|
||||
tdist = (x - maxB) * B_SCALE;
|
||||
tdist = (x - maxB) B_SCALE;
|
||||
max_dist += tdist*tdist;
|
||||
} else {
|
||||
tdist = (x - minB) * B_SCALE;
|
||||
tdist = (x - minB) B_SCALE;
|
||||
max_dist += tdist*tdist;
|
||||
}
|
||||
}
|
||||
|
@ -2741,23 +2746,23 @@ find_best_colors (QuantizeObj *quantobj,
|
|||
*/
|
||||
|
||||
/* Nominal steps between cell centers ("x" in Thomas article) */
|
||||
#define STEP_R ((1 << R_SHIFT) * R_SCALE)
|
||||
#define STEP_G ((1 << G_SHIFT) * G_SCALE)
|
||||
#define STEP_B ((1 << B_SHIFT) * B_SCALE)
|
||||
#define STEP_R ((1 << R_SHIFT) R_SCALE)
|
||||
#define STEP_G ((1 << G_SHIFT) G_SCALE)
|
||||
#define STEP_B ((1 << B_SHIFT) B_SCALE)
|
||||
|
||||
for (i = 0; i < numcolors; i++) {
|
||||
icolor = colorlist[i];
|
||||
/* Compute (square of) distance from minR/G/B to this color */
|
||||
inR = (minR - quantobj->cmap[icolor].red) * R_SCALE;
|
||||
inR = (minR - quantobj->cmap[icolor].red) R_SCALE;
|
||||
dist0 = inR*inR;
|
||||
inG = (minG - quantobj->cmap[icolor].green) * G_SCALE;
|
||||
inG = (minG - quantobj->cmap[icolor].green) G_SCALE;
|
||||
dist0 += inG*inG;
|
||||
inB = (minB - quantobj->cmap[icolor].blue) * B_SCALE;
|
||||
inB = (minB - quantobj->cmap[icolor].blue) B_SCALE;
|
||||
dist0 += inB*inB;
|
||||
/* Form the initial difference increments */
|
||||
inR = inR * (2 * STEP_R) + STEP_R * STEP_R;
|
||||
inG = inG * (2 * STEP_G) + STEP_G * STEP_G;
|
||||
inB = inB * (2 * STEP_B) + STEP_B * STEP_B;
|
||||
inR = inR * (STEP_R<<1) + STEP_R * STEP_R;
|
||||
inG = inG * (STEP_G<<1) + STEP_G * STEP_G;
|
||||
inB = inB * (STEP_B<<1) + STEP_B * STEP_B;
|
||||
/* Now loop over all cells in box, updating distance per Thomas method */
|
||||
bptr = bestdist;
|
||||
cptr = bestcolor;
|
||||
|
@ -2774,15 +2779,15 @@ find_best_colors (QuantizeObj *quantobj,
|
|||
*cptr = icolor;
|
||||
}
|
||||
dist2 += xx2;
|
||||
xx2 += 2 * STEP_B * STEP_B;
|
||||
xx2 += (STEP_B<<1) * STEP_B;
|
||||
bptr++;
|
||||
cptr++;
|
||||
}
|
||||
dist1 += xx1;
|
||||
xx1 += 2 * STEP_G * STEP_G;
|
||||
xx1 += (STEP_G<<1) * STEP_G;
|
||||
}
|
||||
dist0 += xx0;
|
||||
xx0 += 2 * STEP_R * STEP_R;
|
||||
xx0 += (STEP_R<<1) * STEP_R;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3240,9 +3245,9 @@ median_cut_pass2_fixed_dither_rgb (QuantizeObj *quantobj,
|
|||
ge = src[green_pix] - color->green;
|
||||
be = src[blue_pix] - color->blue;
|
||||
|
||||
re = (re * dmval * 2) / 63;
|
||||
ge = (ge * dmval * 2) / 63;
|
||||
be = (be * dmval * 2) / 63;
|
||||
re = (re * (dmval<<1)) / 63;
|
||||
ge = (ge * (dmval<<1)) / 63;
|
||||
be = (be * (dmval<<1)) / 63;
|
||||
|
||||
R = (CLAMP0255(color->red + re)) >> R_SHIFT;
|
||||
G = (CLAMP0255(color->green + ge)) >> G_SHIFT;
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* 2000/03/24 - Some speedups [Martin]
|
||||
* 2000/01/30 - Use palette_selector instead of option_menu for custom
|
||||
* palette. Use libgimp callback functions. [Sven]
|
||||
*
|
||||
|
@ -128,9 +129,13 @@
|
|||
#define B_SHIFT (BITS_IN_SAMPLE-PRECISION_B)
|
||||
|
||||
/* this has to match the INTENSITY definition in libgimp/gimpcolorspace.h */
|
||||
#define R_SCALE 30 /* scale R distances by this much */
|
||||
#define G_SCALE 59 /* scale G distances by this much */
|
||||
#define B_SCALE 11 /* and B by this much */
|
||||
/* #define R_SCALE 30 */ /* scale R distances by this much */
|
||||
/* #define G_SCALE 59 */ /* scale G distances by this much */
|
||||
/* #define B_SCALE 11 */ /* and B by this much */
|
||||
/* not as precise as the above devlaration but much faster */
|
||||
#define R_SCALE << 2 /* *4 = 36% */
|
||||
#define G_SCALE * 6 /* *6 = 55% */
|
||||
#define B_SCALE /* *1 = 9 % */
|
||||
|
||||
static const unsigned char webpal[] =
|
||||
{
|
||||
|
@ -1811,20 +1816,20 @@ find_split_candidate (boxptr boxlist,
|
|||
{
|
||||
if (boxp->volume > 0)
|
||||
{
|
||||
if (boxp->gerror*G_SCALE > maxc)
|
||||
if (boxp->gerror G_SCALE > maxc)
|
||||
{
|
||||
which = boxp;
|
||||
maxc = boxp->gerror*G_SCALE;
|
||||
maxc = boxp->gerror G_SCALE;
|
||||
}
|
||||
if (boxp->rerror*R_SCALE > maxc)
|
||||
if (boxp->rerror R_SCALE > maxc)
|
||||
{
|
||||
which = boxp;
|
||||
maxc = boxp->rerror*R_SCALE;
|
||||
maxc = boxp->rerror R_SCALE;
|
||||
}
|
||||
if (boxp->berror*B_SCALE > maxc)
|
||||
if (boxp->berror B_SCALE > maxc)
|
||||
{
|
||||
which = boxp;
|
||||
maxc = boxp->berror*B_SCALE;
|
||||
maxc = boxp->berror B_SCALE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2028,9 +2033,9 @@ update_box_rgb (Histogram histogram,
|
|||
* we have to shift back to JSAMPLE units to get consistent distances;
|
||||
* after which, we scale according to the selected distance scale factors.
|
||||
*/
|
||||
dist0 = (( + Rmax - Rmin) << R_SHIFT) * R_SCALE;
|
||||
dist1 = (( + Gmax - Gmin) << G_SHIFT) * G_SCALE;
|
||||
dist2 = (( + Bmax - Bmin) << B_SHIFT) * B_SCALE;
|
||||
dist0 = (( + Rmax - Rmin) << R_SHIFT) R_SCALE;
|
||||
dist1 = (( + Gmax - Gmin) << G_SHIFT) G_SCALE;
|
||||
dist2 = (( + Bmax - Bmin) << B_SHIFT) B_SCALE;
|
||||
boxp->volume = dist0*dist0 + dist1*dist1 + dist2*dist2;
|
||||
|
||||
compute_color_rgb(&dummyqo, histogram, boxp, 0);
|
||||
|
@ -2068,7 +2073,7 @@ update_box_rgb (Histogram histogram,
|
|||
|
||||
boxp->error += (*histp) *
|
||||
(
|
||||
re*re*R_SCALE + ge*ge*G_SCALE + be*be*B_SCALE
|
||||
(re*re R_SCALE) + (ge*ge G_SCALE) + (be*be B_SCALE)
|
||||
);
|
||||
|
||||
ccount += *histp;
|
||||
|
@ -2096,7 +2101,7 @@ update_box_rgb (Histogram histogram,
|
|||
|
||||
tempRerror += (*histp)*re*re;
|
||||
|
||||
if (tempRerror*2 > boxp->rerror)
|
||||
if ((tempRerror<<1) > boxp->rerror)
|
||||
goto green_axisscan;
|
||||
else
|
||||
boxp->Rhalferror = R;
|
||||
|
@ -2126,7 +2131,7 @@ update_box_rgb (Histogram histogram,
|
|||
|
||||
tempGerror += (*histp)*ge*ge;
|
||||
|
||||
if (tempGerror*2 > boxp->gerror)
|
||||
if ((tempGerror<<1) > boxp->gerror)
|
||||
goto blue_axisscan;
|
||||
else
|
||||
boxp->Ghalferror = G;
|
||||
|
@ -2157,7 +2162,7 @@ update_box_rgb (Histogram histogram,
|
|||
|
||||
tempBerror += (*histp)*be*be;
|
||||
|
||||
if (tempBerror*2 > boxp->berror)
|
||||
if ((tempBerror<<1) > boxp->berror)
|
||||
goto finished_axesscan;
|
||||
else
|
||||
boxp->Bhalferror = B;
|
||||
|
@ -2205,7 +2210,7 @@ median_cut_gray (Histogram histogram,
|
|||
* Current algorithm: by population for first half, then by volume.
|
||||
*/
|
||||
#if 0
|
||||
if (numboxes*2 <= desired_colors)
|
||||
if ((numboxes<<1) <= desired_colors)
|
||||
{
|
||||
b1 = find_biggest_color_pop (boxlist, numboxes);
|
||||
}
|
||||
|
@ -2257,7 +2262,7 @@ median_cut_rgb (Histogram histogram,
|
|||
/* Select box to split.
|
||||
* Current algorithm: by population for first half, then by volume.
|
||||
*/
|
||||
if (1 || numboxes*2 <= desired_colors)
|
||||
if (1 || (numboxes<<1) <= desired_colors)
|
||||
{
|
||||
g_print ("O ");
|
||||
b1 = find_biggest_color_pop (boxlist, numboxes);
|
||||
|
@ -2284,9 +2289,9 @@ median_cut_rgb (Histogram histogram,
|
|||
// G = ((b1->Gmax - b1->Gmin) << G_SHIFT) * G_SCALE;
|
||||
//B = ((b1->Bmax - b1->Bmin) << B_SHIFT) * B_SCALE;
|
||||
*/
|
||||
R = R_SCALE*b1->rerror;/* * (((b1->Rmax - b1->Rmin) << R_SHIFT)) * R_SCALE; */
|
||||
G = G_SCALE*b1->gerror;/* * (((b1->Gmax - b1->Gmin) << G_SHIFT)) * G_SCALE; */
|
||||
B = B_SCALE*b1->berror;/* * (((b1->Bmax - b1->Bmin) << B_SHIFT)) * B_SCALE; */
|
||||
R = b1->rerror R_SCALE;/* * (((b1->Rmax - b1->Rmin) << R_SHIFT)) * R_SCALE; */
|
||||
G = b1->gerror G_SCALE;/* * (((b1->Gmax - b1->Gmin) << G_SHIFT)) * G_SCALE; */
|
||||
B = b1->berror B_SCALE;/* * (((b1->Bmax - b1->Bmin) << B_SHIFT)) * B_SCALE; */
|
||||
/* We want to break any ties in favor of green, then red, blue last.
|
||||
*/
|
||||
cmax = G; n = 1;
|
||||
|
@ -2619,67 +2624,67 @@ find_nearby_colors (QuantizeObj *quantobj,
|
|||
/* We compute the squared-R-distance term, then add in the other two. */
|
||||
x = quantobj->cmap[i].red;
|
||||
if (x < minR) {
|
||||
tdist = (x - minR) * R_SCALE;
|
||||
tdist = (x - minR) R_SCALE;
|
||||
min_dist = tdist*tdist;
|
||||
tdist = (x - maxR) * R_SCALE;
|
||||
tdist = (x - maxR) R_SCALE;
|
||||
max_dist = tdist*tdist;
|
||||
} else if (x > maxR) {
|
||||
tdist = (x - maxR) * R_SCALE;
|
||||
tdist = (x - maxR) R_SCALE;
|
||||
min_dist = tdist*tdist;
|
||||
tdist = (x - minR) * R_SCALE;
|
||||
tdist = (x - minR) R_SCALE;
|
||||
max_dist = tdist*tdist;
|
||||
} else {
|
||||
/* within cell range so no contribution to min_dist */
|
||||
min_dist = 0;
|
||||
if (x <= centerR) {
|
||||
tdist = (x - maxR) * R_SCALE;
|
||||
tdist = (x - maxR) R_SCALE;
|
||||
max_dist = tdist*tdist;
|
||||
} else {
|
||||
tdist = (x - minR) * R_SCALE;
|
||||
tdist = (x - minR) R_SCALE;
|
||||
max_dist = tdist*tdist;
|
||||
}
|
||||
}
|
||||
|
||||
x = quantobj->cmap[i].green;
|
||||
if (x < minG) {
|
||||
tdist = (x - minG) * G_SCALE;
|
||||
tdist = (x - minG) G_SCALE;
|
||||
min_dist += tdist*tdist;
|
||||
tdist = (x - maxG) * G_SCALE;
|
||||
tdist = (x - maxG) G_SCALE;
|
||||
max_dist += tdist*tdist;
|
||||
} else if (x > maxG) {
|
||||
tdist = (x - maxG) * G_SCALE;
|
||||
tdist = (x - maxG) G_SCALE;
|
||||
min_dist += tdist*tdist;
|
||||
tdist = (x - minG) * G_SCALE;
|
||||
tdist = (x - minG) G_SCALE;
|
||||
max_dist += tdist*tdist;
|
||||
} else {
|
||||
/* within cell range so no contribution to min_dist */
|
||||
if (x <= centerG) {
|
||||
tdist = (x - maxG) * G_SCALE;
|
||||
tdist = (x - maxG) G_SCALE;
|
||||
max_dist += tdist*tdist;
|
||||
} else {
|
||||
tdist = (x - minG) * G_SCALE;
|
||||
tdist = (x - minG) G_SCALE;
|
||||
max_dist += tdist*tdist;
|
||||
}
|
||||
}
|
||||
|
||||
x = quantobj->cmap[i].blue;
|
||||
if (x < minB) {
|
||||
tdist = (x - minB) * B_SCALE;
|
||||
tdist = (x - minB) B_SCALE;
|
||||
min_dist += tdist*tdist;
|
||||
tdist = (x - maxB) * B_SCALE;
|
||||
tdist = (x - maxB) B_SCALE;
|
||||
max_dist += tdist*tdist;
|
||||
} else if (x > maxB) {
|
||||
tdist = (x - maxB) * B_SCALE;
|
||||
tdist = (x - maxB) B_SCALE;
|
||||
min_dist += tdist*tdist;
|
||||
tdist = (x - minB) * B_SCALE;
|
||||
tdist = (x - minB) B_SCALE;
|
||||
max_dist += tdist*tdist;
|
||||
} else {
|
||||
/* within cell range so no contribution to min_dist */
|
||||
if (x <= centerB) {
|
||||
tdist = (x - maxB) * B_SCALE;
|
||||
tdist = (x - maxB) B_SCALE;
|
||||
max_dist += tdist*tdist;
|
||||
} else {
|
||||
tdist = (x - minB) * B_SCALE;
|
||||
tdist = (x - minB) B_SCALE;
|
||||
max_dist += tdist*tdist;
|
||||
}
|
||||
}
|
||||
|
@ -2741,23 +2746,23 @@ find_best_colors (QuantizeObj *quantobj,
|
|||
*/
|
||||
|
||||
/* Nominal steps between cell centers ("x" in Thomas article) */
|
||||
#define STEP_R ((1 << R_SHIFT) * R_SCALE)
|
||||
#define STEP_G ((1 << G_SHIFT) * G_SCALE)
|
||||
#define STEP_B ((1 << B_SHIFT) * B_SCALE)
|
||||
#define STEP_R ((1 << R_SHIFT) R_SCALE)
|
||||
#define STEP_G ((1 << G_SHIFT) G_SCALE)
|
||||
#define STEP_B ((1 << B_SHIFT) B_SCALE)
|
||||
|
||||
for (i = 0; i < numcolors; i++) {
|
||||
icolor = colorlist[i];
|
||||
/* Compute (square of) distance from minR/G/B to this color */
|
||||
inR = (minR - quantobj->cmap[icolor].red) * R_SCALE;
|
||||
inR = (minR - quantobj->cmap[icolor].red) R_SCALE;
|
||||
dist0 = inR*inR;
|
||||
inG = (minG - quantobj->cmap[icolor].green) * G_SCALE;
|
||||
inG = (minG - quantobj->cmap[icolor].green) G_SCALE;
|
||||
dist0 += inG*inG;
|
||||
inB = (minB - quantobj->cmap[icolor].blue) * B_SCALE;
|
||||
inB = (minB - quantobj->cmap[icolor].blue) B_SCALE;
|
||||
dist0 += inB*inB;
|
||||
/* Form the initial difference increments */
|
||||
inR = inR * (2 * STEP_R) + STEP_R * STEP_R;
|
||||
inG = inG * (2 * STEP_G) + STEP_G * STEP_G;
|
||||
inB = inB * (2 * STEP_B) + STEP_B * STEP_B;
|
||||
inR = inR * (STEP_R<<1) + STEP_R * STEP_R;
|
||||
inG = inG * (STEP_G<<1) + STEP_G * STEP_G;
|
||||
inB = inB * (STEP_B<<1) + STEP_B * STEP_B;
|
||||
/* Now loop over all cells in box, updating distance per Thomas method */
|
||||
bptr = bestdist;
|
||||
cptr = bestcolor;
|
||||
|
@ -2774,15 +2779,15 @@ find_best_colors (QuantizeObj *quantobj,
|
|||
*cptr = icolor;
|
||||
}
|
||||
dist2 += xx2;
|
||||
xx2 += 2 * STEP_B * STEP_B;
|
||||
xx2 += (STEP_B<<1) * STEP_B;
|
||||
bptr++;
|
||||
cptr++;
|
||||
}
|
||||
dist1 += xx1;
|
||||
xx1 += 2 * STEP_G * STEP_G;
|
||||
xx1 += (STEP_G<<1) * STEP_G;
|
||||
}
|
||||
dist0 += xx0;
|
||||
xx0 += 2 * STEP_R * STEP_R;
|
||||
xx0 += (STEP_R<<1) * STEP_R;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3240,9 +3245,9 @@ median_cut_pass2_fixed_dither_rgb (QuantizeObj *quantobj,
|
|||
ge = src[green_pix] - color->green;
|
||||
be = src[blue_pix] - color->blue;
|
||||
|
||||
re = (re * dmval * 2) / 63;
|
||||
ge = (ge * dmval * 2) / 63;
|
||||
be = (be * dmval * 2) / 63;
|
||||
re = (re * (dmval<<1)) / 63;
|
||||
ge = (ge * (dmval<<1)) / 63;
|
||||
be = (be * (dmval<<1)) / 63;
|
||||
|
||||
R = (CLAMP0255(color->red + re)) >> R_SHIFT;
|
||||
G = (CLAMP0255(color->green + ge)) >> G_SHIFT;
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* 2000/03/24 - Some speedups [Martin]
|
||||
* 2000/01/30 - Use palette_selector instead of option_menu for custom
|
||||
* palette. Use libgimp callback functions. [Sven]
|
||||
*
|
||||
|
@ -128,9 +129,13 @@
|
|||
#define B_SHIFT (BITS_IN_SAMPLE-PRECISION_B)
|
||||
|
||||
/* this has to match the INTENSITY definition in libgimp/gimpcolorspace.h */
|
||||
#define R_SCALE 30 /* scale R distances by this much */
|
||||
#define G_SCALE 59 /* scale G distances by this much */
|
||||
#define B_SCALE 11 /* and B by this much */
|
||||
/* #define R_SCALE 30 */ /* scale R distances by this much */
|
||||
/* #define G_SCALE 59 */ /* scale G distances by this much */
|
||||
/* #define B_SCALE 11 */ /* and B by this much */
|
||||
/* not as precise as the above devlaration but much faster */
|
||||
#define R_SCALE << 2 /* *4 = 36% */
|
||||
#define G_SCALE * 6 /* *6 = 55% */
|
||||
#define B_SCALE /* *1 = 9 % */
|
||||
|
||||
static const unsigned char webpal[] =
|
||||
{
|
||||
|
@ -1811,20 +1816,20 @@ find_split_candidate (boxptr boxlist,
|
|||
{
|
||||
if (boxp->volume > 0)
|
||||
{
|
||||
if (boxp->gerror*G_SCALE > maxc)
|
||||
if (boxp->gerror G_SCALE > maxc)
|
||||
{
|
||||
which = boxp;
|
||||
maxc = boxp->gerror*G_SCALE;
|
||||
maxc = boxp->gerror G_SCALE;
|
||||
}
|
||||
if (boxp->rerror*R_SCALE > maxc)
|
||||
if (boxp->rerror R_SCALE > maxc)
|
||||
{
|
||||
which = boxp;
|
||||
maxc = boxp->rerror*R_SCALE;
|
||||
maxc = boxp->rerror R_SCALE;
|
||||
}
|
||||
if (boxp->berror*B_SCALE > maxc)
|
||||
if (boxp->berror B_SCALE > maxc)
|
||||
{
|
||||
which = boxp;
|
||||
maxc = boxp->berror*B_SCALE;
|
||||
maxc = boxp->berror B_SCALE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2028,9 +2033,9 @@ update_box_rgb (Histogram histogram,
|
|||
* we have to shift back to JSAMPLE units to get consistent distances;
|
||||
* after which, we scale according to the selected distance scale factors.
|
||||
*/
|
||||
dist0 = (( + Rmax - Rmin) << R_SHIFT) * R_SCALE;
|
||||
dist1 = (( + Gmax - Gmin) << G_SHIFT) * G_SCALE;
|
||||
dist2 = (( + Bmax - Bmin) << B_SHIFT) * B_SCALE;
|
||||
dist0 = (( + Rmax - Rmin) << R_SHIFT) R_SCALE;
|
||||
dist1 = (( + Gmax - Gmin) << G_SHIFT) G_SCALE;
|
||||
dist2 = (( + Bmax - Bmin) << B_SHIFT) B_SCALE;
|
||||
boxp->volume = dist0*dist0 + dist1*dist1 + dist2*dist2;
|
||||
|
||||
compute_color_rgb(&dummyqo, histogram, boxp, 0);
|
||||
|
@ -2068,7 +2073,7 @@ update_box_rgb (Histogram histogram,
|
|||
|
||||
boxp->error += (*histp) *
|
||||
(
|
||||
re*re*R_SCALE + ge*ge*G_SCALE + be*be*B_SCALE
|
||||
(re*re R_SCALE) + (ge*ge G_SCALE) + (be*be B_SCALE)
|
||||
);
|
||||
|
||||
ccount += *histp;
|
||||
|
@ -2096,7 +2101,7 @@ update_box_rgb (Histogram histogram,
|
|||
|
||||
tempRerror += (*histp)*re*re;
|
||||
|
||||
if (tempRerror*2 > boxp->rerror)
|
||||
if ((tempRerror<<1) > boxp->rerror)
|
||||
goto green_axisscan;
|
||||
else
|
||||
boxp->Rhalferror = R;
|
||||
|
@ -2126,7 +2131,7 @@ update_box_rgb (Histogram histogram,
|
|||
|
||||
tempGerror += (*histp)*ge*ge;
|
||||
|
||||
if (tempGerror*2 > boxp->gerror)
|
||||
if ((tempGerror<<1) > boxp->gerror)
|
||||
goto blue_axisscan;
|
||||
else
|
||||
boxp->Ghalferror = G;
|
||||
|
@ -2157,7 +2162,7 @@ update_box_rgb (Histogram histogram,
|
|||
|
||||
tempBerror += (*histp)*be*be;
|
||||
|
||||
if (tempBerror*2 > boxp->berror)
|
||||
if ((tempBerror<<1) > boxp->berror)
|
||||
goto finished_axesscan;
|
||||
else
|
||||
boxp->Bhalferror = B;
|
||||
|
@ -2205,7 +2210,7 @@ median_cut_gray (Histogram histogram,
|
|||
* Current algorithm: by population for first half, then by volume.
|
||||
*/
|
||||
#if 0
|
||||
if (numboxes*2 <= desired_colors)
|
||||
if ((numboxes<<1) <= desired_colors)
|
||||
{
|
||||
b1 = find_biggest_color_pop (boxlist, numboxes);
|
||||
}
|
||||
|
@ -2257,7 +2262,7 @@ median_cut_rgb (Histogram histogram,
|
|||
/* Select box to split.
|
||||
* Current algorithm: by population for first half, then by volume.
|
||||
*/
|
||||
if (1 || numboxes*2 <= desired_colors)
|
||||
if (1 || (numboxes<<1) <= desired_colors)
|
||||
{
|
||||
g_print ("O ");
|
||||
b1 = find_biggest_color_pop (boxlist, numboxes);
|
||||
|
@ -2284,9 +2289,9 @@ median_cut_rgb (Histogram histogram,
|
|||
// G = ((b1->Gmax - b1->Gmin) << G_SHIFT) * G_SCALE;
|
||||
//B = ((b1->Bmax - b1->Bmin) << B_SHIFT) * B_SCALE;
|
||||
*/
|
||||
R = R_SCALE*b1->rerror;/* * (((b1->Rmax - b1->Rmin) << R_SHIFT)) * R_SCALE; */
|
||||
G = G_SCALE*b1->gerror;/* * (((b1->Gmax - b1->Gmin) << G_SHIFT)) * G_SCALE; */
|
||||
B = B_SCALE*b1->berror;/* * (((b1->Bmax - b1->Bmin) << B_SHIFT)) * B_SCALE; */
|
||||
R = b1->rerror R_SCALE;/* * (((b1->Rmax - b1->Rmin) << R_SHIFT)) * R_SCALE; */
|
||||
G = b1->gerror G_SCALE;/* * (((b1->Gmax - b1->Gmin) << G_SHIFT)) * G_SCALE; */
|
||||
B = b1->berror B_SCALE;/* * (((b1->Bmax - b1->Bmin) << B_SHIFT)) * B_SCALE; */
|
||||
/* We want to break any ties in favor of green, then red, blue last.
|
||||
*/
|
||||
cmax = G; n = 1;
|
||||
|
@ -2619,67 +2624,67 @@ find_nearby_colors (QuantizeObj *quantobj,
|
|||
/* We compute the squared-R-distance term, then add in the other two. */
|
||||
x = quantobj->cmap[i].red;
|
||||
if (x < minR) {
|
||||
tdist = (x - minR) * R_SCALE;
|
||||
tdist = (x - minR) R_SCALE;
|
||||
min_dist = tdist*tdist;
|
||||
tdist = (x - maxR) * R_SCALE;
|
||||
tdist = (x - maxR) R_SCALE;
|
||||
max_dist = tdist*tdist;
|
||||
} else if (x > maxR) {
|
||||
tdist = (x - maxR) * R_SCALE;
|
||||
tdist = (x - maxR) R_SCALE;
|
||||
min_dist = tdist*tdist;
|
||||
tdist = (x - minR) * R_SCALE;
|
||||
tdist = (x - minR) R_SCALE;
|
||||
max_dist = tdist*tdist;
|
||||
} else {
|
||||
/* within cell range so no contribution to min_dist */
|
||||
min_dist = 0;
|
||||
if (x <= centerR) {
|
||||
tdist = (x - maxR) * R_SCALE;
|
||||
tdist = (x - maxR) R_SCALE;
|
||||
max_dist = tdist*tdist;
|
||||
} else {
|
||||
tdist = (x - minR) * R_SCALE;
|
||||
tdist = (x - minR) R_SCALE;
|
||||
max_dist = tdist*tdist;
|
||||
}
|
||||
}
|
||||
|
||||
x = quantobj->cmap[i].green;
|
||||
if (x < minG) {
|
||||
tdist = (x - minG) * G_SCALE;
|
||||
tdist = (x - minG) G_SCALE;
|
||||
min_dist += tdist*tdist;
|
||||
tdist = (x - maxG) * G_SCALE;
|
||||
tdist = (x - maxG) G_SCALE;
|
||||
max_dist += tdist*tdist;
|
||||
} else if (x > maxG) {
|
||||
tdist = (x - maxG) * G_SCALE;
|
||||
tdist = (x - maxG) G_SCALE;
|
||||
min_dist += tdist*tdist;
|
||||
tdist = (x - minG) * G_SCALE;
|
||||
tdist = (x - minG) G_SCALE;
|
||||
max_dist += tdist*tdist;
|
||||
} else {
|
||||
/* within cell range so no contribution to min_dist */
|
||||
if (x <= centerG) {
|
||||
tdist = (x - maxG) * G_SCALE;
|
||||
tdist = (x - maxG) G_SCALE;
|
||||
max_dist += tdist*tdist;
|
||||
} else {
|
||||
tdist = (x - minG) * G_SCALE;
|
||||
tdist = (x - minG) G_SCALE;
|
||||
max_dist += tdist*tdist;
|
||||
}
|
||||
}
|
||||
|
||||
x = quantobj->cmap[i].blue;
|
||||
if (x < minB) {
|
||||
tdist = (x - minB) * B_SCALE;
|
||||
tdist = (x - minB) B_SCALE;
|
||||
min_dist += tdist*tdist;
|
||||
tdist = (x - maxB) * B_SCALE;
|
||||
tdist = (x - maxB) B_SCALE;
|
||||
max_dist += tdist*tdist;
|
||||
} else if (x > maxB) {
|
||||
tdist = (x - maxB) * B_SCALE;
|
||||
tdist = (x - maxB) B_SCALE;
|
||||
min_dist += tdist*tdist;
|
||||
tdist = (x - minB) * B_SCALE;
|
||||
tdist = (x - minB) B_SCALE;
|
||||
max_dist += tdist*tdist;
|
||||
} else {
|
||||
/* within cell range so no contribution to min_dist */
|
||||
if (x <= centerB) {
|
||||
tdist = (x - maxB) * B_SCALE;
|
||||
tdist = (x - maxB) B_SCALE;
|
||||
max_dist += tdist*tdist;
|
||||
} else {
|
||||
tdist = (x - minB) * B_SCALE;
|
||||
tdist = (x - minB) B_SCALE;
|
||||
max_dist += tdist*tdist;
|
||||
}
|
||||
}
|
||||
|
@ -2741,23 +2746,23 @@ find_best_colors (QuantizeObj *quantobj,
|
|||
*/
|
||||
|
||||
/* Nominal steps between cell centers ("x" in Thomas article) */
|
||||
#define STEP_R ((1 << R_SHIFT) * R_SCALE)
|
||||
#define STEP_G ((1 << G_SHIFT) * G_SCALE)
|
||||
#define STEP_B ((1 << B_SHIFT) * B_SCALE)
|
||||
#define STEP_R ((1 << R_SHIFT) R_SCALE)
|
||||
#define STEP_G ((1 << G_SHIFT) G_SCALE)
|
||||
#define STEP_B ((1 << B_SHIFT) B_SCALE)
|
||||
|
||||
for (i = 0; i < numcolors; i++) {
|
||||
icolor = colorlist[i];
|
||||
/* Compute (square of) distance from minR/G/B to this color */
|
||||
inR = (minR - quantobj->cmap[icolor].red) * R_SCALE;
|
||||
inR = (minR - quantobj->cmap[icolor].red) R_SCALE;
|
||||
dist0 = inR*inR;
|
||||
inG = (minG - quantobj->cmap[icolor].green) * G_SCALE;
|
||||
inG = (minG - quantobj->cmap[icolor].green) G_SCALE;
|
||||
dist0 += inG*inG;
|
||||
inB = (minB - quantobj->cmap[icolor].blue) * B_SCALE;
|
||||
inB = (minB - quantobj->cmap[icolor].blue) B_SCALE;
|
||||
dist0 += inB*inB;
|
||||
/* Form the initial difference increments */
|
||||
inR = inR * (2 * STEP_R) + STEP_R * STEP_R;
|
||||
inG = inG * (2 * STEP_G) + STEP_G * STEP_G;
|
||||
inB = inB * (2 * STEP_B) + STEP_B * STEP_B;
|
||||
inR = inR * (STEP_R<<1) + STEP_R * STEP_R;
|
||||
inG = inG * (STEP_G<<1) + STEP_G * STEP_G;
|
||||
inB = inB * (STEP_B<<1) + STEP_B * STEP_B;
|
||||
/* Now loop over all cells in box, updating distance per Thomas method */
|
||||
bptr = bestdist;
|
||||
cptr = bestcolor;
|
||||
|
@ -2774,15 +2779,15 @@ find_best_colors (QuantizeObj *quantobj,
|
|||
*cptr = icolor;
|
||||
}
|
||||
dist2 += xx2;
|
||||
xx2 += 2 * STEP_B * STEP_B;
|
||||
xx2 += (STEP_B<<1) * STEP_B;
|
||||
bptr++;
|
||||
cptr++;
|
||||
}
|
||||
dist1 += xx1;
|
||||
xx1 += 2 * STEP_G * STEP_G;
|
||||
xx1 += (STEP_G<<1) * STEP_G;
|
||||
}
|
||||
dist0 += xx0;
|
||||
xx0 += 2 * STEP_R * STEP_R;
|
||||
xx0 += (STEP_R<<1) * STEP_R;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3240,9 +3245,9 @@ median_cut_pass2_fixed_dither_rgb (QuantizeObj *quantobj,
|
|||
ge = src[green_pix] - color->green;
|
||||
be = src[blue_pix] - color->blue;
|
||||
|
||||
re = (re * dmval * 2) / 63;
|
||||
ge = (ge * dmval * 2) / 63;
|
||||
be = (be * dmval * 2) / 63;
|
||||
re = (re * (dmval<<1)) / 63;
|
||||
ge = (ge * (dmval<<1)) / 63;
|
||||
be = (be * (dmval<<1)) / 63;
|
||||
|
||||
R = (CLAMP0255(color->red + re)) >> R_SHIFT;
|
||||
G = (CLAMP0255(color->green + ge)) >> G_SHIFT;
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "gdk/gdkkeysyms.h"
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "gdk/gdkkeysyms.h"
|
||||
|
||||
|
|
|
@ -48,10 +48,14 @@
|
|||
* V 1.09, PK, 15-Feb-2000: Force showpage on EPS-files
|
||||
* Add "RunLength" compression
|
||||
* Fix problem with "Level 2" toggle
|
||||
* V 1.10, PK, 13-Mar-2000: For load EPSF, allow negative Bounding Box Values
|
||||
* Save PS: dont start lines of image data with %%
|
||||
* to prevent problems with stupid PostScript
|
||||
* analyzer programs (Stanislav Brabec)
|
||||
*/
|
||||
#define VERSIO 1.09
|
||||
static char dversio[] = "v1.09 15-Feb-2000";
|
||||
static char ident[] = "@(#) GIMP PostScript/PDF file-plugin v1.09 15-Feb-2000";
|
||||
static char dversio[] = "v1.10 13-Mar-2000";
|
||||
static char ident[] = "@(#) GIMP PostScript/PDF file-plugin v1.10 13-Mar-2000";
|
||||
|
||||
#include "config.h"
|
||||
|
||||
|
@ -134,7 +138,7 @@ static PSSaveVals psvals =
|
|||
5.0, 5.0, /* Offset */
|
||||
1, /* Unit is mm */
|
||||
1, /* Keep edge ratio */
|
||||
0, /* Rotate */
|
||||
90, /* Rotate */
|
||||
2, /* PostScript Level */
|
||||
0, /* Encapsulated PostScript flag */
|
||||
0, /* Preview flag */
|
||||
|
@ -288,6 +292,7 @@ ascii85_flush (FILE *ofp)
|
|||
char c[5];
|
||||
int i;
|
||||
gboolean zero_case = (ascii85_buf == 0);
|
||||
static int max_linewidth = 75;
|
||||
|
||||
for (i=4; i >= 0; i--)
|
||||
{
|
||||
|
@ -298,20 +303,26 @@ ascii85_flush (FILE *ofp)
|
|||
* at end of data. */
|
||||
if (zero_case && (ascii85_len == 4))
|
||||
{
|
||||
if (ascii85_linewidth >= max_linewidth)
|
||||
{
|
||||
putc ('\n', ofp);
|
||||
ascii85_linewidth = 0;
|
||||
}
|
||||
putc ('z', ofp);
|
||||
ascii85_linewidth++;
|
||||
}
|
||||
else
|
||||
{
|
||||
ascii85_linewidth += ascii85_len+1;
|
||||
for (i=0; i < ascii85_len+1; i++)
|
||||
{
|
||||
if ((ascii85_linewidth >= max_linewidth) && (c[i] != '%'))
|
||||
{
|
||||
putc ('\n', ofp);
|
||||
ascii85_linewidth = 0;
|
||||
}
|
||||
putc (c[i], ofp);
|
||||
}
|
||||
|
||||
if (ascii85_linewidth >= 75)
|
||||
{
|
||||
putc ('\n', ofp);
|
||||
ascii85_linewidth = 0;
|
||||
ascii85_linewidth++;
|
||||
}
|
||||
}
|
||||
|
||||
ascii85_len = 0;
|
||||
|
@ -550,7 +561,7 @@ ps_set_save_size (PSSaveVals *vals,
|
|||
GimpUnit unit;
|
||||
|
||||
gimp_image_get_resolution (image_ID, &xres, &yres);
|
||||
if ((xres < GIMP_MIN_RESOLUTION) || (yres < GIMP_MIN_RESOLUTION))
|
||||
if ((xres < 1e-5) || (yres < 1e-5))
|
||||
{
|
||||
xres = yres = 72.0;
|
||||
}
|
||||
|
@ -1168,8 +1179,10 @@ ps_open (gchar *filename,
|
|||
FILE *fd_popen;
|
||||
int width, height, resolution;
|
||||
int x0, y0, x1, y1;
|
||||
int offx = 0, offy = 0;
|
||||
int is_pdf;
|
||||
char TextAlphaBits[64], GraphicsAlphaBits[64], geometry[32];
|
||||
char offset[32];
|
||||
|
||||
resolution = loadopt->resolution;
|
||||
*llx = *lly = 0;
|
||||
|
@ -1210,16 +1223,23 @@ ps_open (gchar *filename,
|
|||
|
||||
if ((!is_pdf) && (loadopt->use_bbox)) /* Try the BoundingBox ? */
|
||||
{
|
||||
if ( (get_bbox (filename, &x0, &y0, &x1, &y1) == 0)
|
||||
&& (x0 >= 0) && (y0 >= 0) && (x1 > x0) && (y1 > y0))
|
||||
{
|
||||
*llx = (int)((x0/72.0) * resolution + 0.01);
|
||||
*lly = (int)((y0/72.0) * resolution + 0.01);
|
||||
*urx = (int)((x1/72.0) * resolution + 0.01);
|
||||
*ury = (int)((y1/72.0) * resolution + 0.01);
|
||||
width = *urx + 1;
|
||||
height = *ury + 1;
|
||||
}
|
||||
if (get_bbox (filename, &x0, &y0, &x1, &y1) == 0)
|
||||
{
|
||||
if (*is_epsf) /* Handle negative BoundingBox for EPSF */
|
||||
{
|
||||
offx = -x0; x1 += offx; x0 += offx;
|
||||
offy = -y0; y1 += offy; y0 += offy;
|
||||
}
|
||||
if ((x0 >= 0) && (y0 >= 0) && (x1 > x0) && (y1 > y0))
|
||||
{
|
||||
*llx = (int)((x0/72.0) * resolution + 0.01);
|
||||
*lly = (int)((y0/72.0) * resolution + 0.01);
|
||||
*urx = (int)((x1/72.0) * resolution + 0.01);
|
||||
*ury = (int)((y1/72.0) * resolution + 0.01);
|
||||
width = *urx + 1;
|
||||
height = *ury + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (loadopt->pnm_type == 4) driver = "pbmraw";
|
||||
else if (loadopt->pnm_type == 5) driver = "pgmraw";
|
||||
|
@ -1257,6 +1277,11 @@ ps_open (gchar *filename,
|
|||
gs_opts = ""; /* Ghostscript will add these options */
|
||||
|
||||
TextAlphaBits[0] = GraphicsAlphaBits[0] = geometry[0] = '\0';
|
||||
offset[0] = '\0';
|
||||
|
||||
/* Offset command for gs to get image part with negative x/y-coord. */
|
||||
if ((offx != 0) || (offy != 0))
|
||||
sprintf (offset, "-c %d %d translate -- ", offx, offy);
|
||||
|
||||
/* Antialiasing not available for PBM-device */
|
||||
if ((loadopt->pnm_type != 4) && (loadopt->textalpha != 1))
|
||||
|
@ -1270,10 +1295,10 @@ ps_open (gchar *filename,
|
|||
sprintf (geometry,"-g%dx%d ", width, height);
|
||||
|
||||
cmd = g_strdup_printf ("%s -sDEVICE=%s -r%d %s%s%s-q -dNOPAUSE %s \
|
||||
-sOutputFile=%s %s %s-c quit",
|
||||
-sOutputFile=%s %s%s %s-c quit",
|
||||
gs, driver, resolution, geometry,
|
||||
TextAlphaBits, GraphicsAlphaBits,
|
||||
gs_opts, pnmfile, filename,
|
||||
gs_opts, pnmfile, offset, filename,
|
||||
*is_epsf ? "-c showpage " : "");
|
||||
#ifdef PS_DEBUG
|
||||
g_print ("Going to start ghostscript with:\n%s\n", cmd);
|
||||
|
@ -2675,7 +2700,7 @@ save_dialog (void)
|
|||
/* Image Size */
|
||||
frame = gtk_frame_new (_("Image Size"));
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_IN);
|
||||
gtk_box_pack_start (GTK_BOX (main_vbox[0]), frame, TRUE, TRUE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (main_vbox[0]), frame, FALSE, FALSE, 0);
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 4);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (vbox), 4);
|
||||
|
@ -2741,7 +2766,7 @@ save_dialog (void)
|
|||
_("Millimeter"), (gpointer) TRUE, NULL,
|
||||
|
||||
NULL);
|
||||
gtk_box_pack_end (GTK_BOX (vbox), uframe, FALSE, FALSE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), uframe, FALSE, FALSE, 0);
|
||||
gtk_widget_show (uframe);
|
||||
|
||||
gtk_widget_show (vbox);
|
||||
|
|
|
@ -48,10 +48,14 @@
|
|||
* V 1.09, PK, 15-Feb-2000: Force showpage on EPS-files
|
||||
* Add "RunLength" compression
|
||||
* Fix problem with "Level 2" toggle
|
||||
* V 1.10, PK, 13-Mar-2000: For load EPSF, allow negative Bounding Box Values
|
||||
* Save PS: dont start lines of image data with %%
|
||||
* to prevent problems with stupid PostScript
|
||||
* analyzer programs (Stanislav Brabec)
|
||||
*/
|
||||
#define VERSIO 1.09
|
||||
static char dversio[] = "v1.09 15-Feb-2000";
|
||||
static char ident[] = "@(#) GIMP PostScript/PDF file-plugin v1.09 15-Feb-2000";
|
||||
static char dversio[] = "v1.10 13-Mar-2000";
|
||||
static char ident[] = "@(#) GIMP PostScript/PDF file-plugin v1.10 13-Mar-2000";
|
||||
|
||||
#include "config.h"
|
||||
|
||||
|
@ -134,7 +138,7 @@ static PSSaveVals psvals =
|
|||
5.0, 5.0, /* Offset */
|
||||
1, /* Unit is mm */
|
||||
1, /* Keep edge ratio */
|
||||
0, /* Rotate */
|
||||
90, /* Rotate */
|
||||
2, /* PostScript Level */
|
||||
0, /* Encapsulated PostScript flag */
|
||||
0, /* Preview flag */
|
||||
|
@ -288,6 +292,7 @@ ascii85_flush (FILE *ofp)
|
|||
char c[5];
|
||||
int i;
|
||||
gboolean zero_case = (ascii85_buf == 0);
|
||||
static int max_linewidth = 75;
|
||||
|
||||
for (i=4; i >= 0; i--)
|
||||
{
|
||||
|
@ -298,20 +303,26 @@ ascii85_flush (FILE *ofp)
|
|||
* at end of data. */
|
||||
if (zero_case && (ascii85_len == 4))
|
||||
{
|
||||
if (ascii85_linewidth >= max_linewidth)
|
||||
{
|
||||
putc ('\n', ofp);
|
||||
ascii85_linewidth = 0;
|
||||
}
|
||||
putc ('z', ofp);
|
||||
ascii85_linewidth++;
|
||||
}
|
||||
else
|
||||
{
|
||||
ascii85_linewidth += ascii85_len+1;
|
||||
for (i=0; i < ascii85_len+1; i++)
|
||||
{
|
||||
if ((ascii85_linewidth >= max_linewidth) && (c[i] != '%'))
|
||||
{
|
||||
putc ('\n', ofp);
|
||||
ascii85_linewidth = 0;
|
||||
}
|
||||
putc (c[i], ofp);
|
||||
}
|
||||
|
||||
if (ascii85_linewidth >= 75)
|
||||
{
|
||||
putc ('\n', ofp);
|
||||
ascii85_linewidth = 0;
|
||||
ascii85_linewidth++;
|
||||
}
|
||||
}
|
||||
|
||||
ascii85_len = 0;
|
||||
|
@ -550,7 +561,7 @@ ps_set_save_size (PSSaveVals *vals,
|
|||
GimpUnit unit;
|
||||
|
||||
gimp_image_get_resolution (image_ID, &xres, &yres);
|
||||
if ((xres < GIMP_MIN_RESOLUTION) || (yres < GIMP_MIN_RESOLUTION))
|
||||
if ((xres < 1e-5) || (yres < 1e-5))
|
||||
{
|
||||
xres = yres = 72.0;
|
||||
}
|
||||
|
@ -1168,8 +1179,10 @@ ps_open (gchar *filename,
|
|||
FILE *fd_popen;
|
||||
int width, height, resolution;
|
||||
int x0, y0, x1, y1;
|
||||
int offx = 0, offy = 0;
|
||||
int is_pdf;
|
||||
char TextAlphaBits[64], GraphicsAlphaBits[64], geometry[32];
|
||||
char offset[32];
|
||||
|
||||
resolution = loadopt->resolution;
|
||||
*llx = *lly = 0;
|
||||
|
@ -1210,16 +1223,23 @@ ps_open (gchar *filename,
|
|||
|
||||
if ((!is_pdf) && (loadopt->use_bbox)) /* Try the BoundingBox ? */
|
||||
{
|
||||
if ( (get_bbox (filename, &x0, &y0, &x1, &y1) == 0)
|
||||
&& (x0 >= 0) && (y0 >= 0) && (x1 > x0) && (y1 > y0))
|
||||
{
|
||||
*llx = (int)((x0/72.0) * resolution + 0.01);
|
||||
*lly = (int)((y0/72.0) * resolution + 0.01);
|
||||
*urx = (int)((x1/72.0) * resolution + 0.01);
|
||||
*ury = (int)((y1/72.0) * resolution + 0.01);
|
||||
width = *urx + 1;
|
||||
height = *ury + 1;
|
||||
}
|
||||
if (get_bbox (filename, &x0, &y0, &x1, &y1) == 0)
|
||||
{
|
||||
if (*is_epsf) /* Handle negative BoundingBox for EPSF */
|
||||
{
|
||||
offx = -x0; x1 += offx; x0 += offx;
|
||||
offy = -y0; y1 += offy; y0 += offy;
|
||||
}
|
||||
if ((x0 >= 0) && (y0 >= 0) && (x1 > x0) && (y1 > y0))
|
||||
{
|
||||
*llx = (int)((x0/72.0) * resolution + 0.01);
|
||||
*lly = (int)((y0/72.0) * resolution + 0.01);
|
||||
*urx = (int)((x1/72.0) * resolution + 0.01);
|
||||
*ury = (int)((y1/72.0) * resolution + 0.01);
|
||||
width = *urx + 1;
|
||||
height = *ury + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (loadopt->pnm_type == 4) driver = "pbmraw";
|
||||
else if (loadopt->pnm_type == 5) driver = "pgmraw";
|
||||
|
@ -1257,6 +1277,11 @@ ps_open (gchar *filename,
|
|||
gs_opts = ""; /* Ghostscript will add these options */
|
||||
|
||||
TextAlphaBits[0] = GraphicsAlphaBits[0] = geometry[0] = '\0';
|
||||
offset[0] = '\0';
|
||||
|
||||
/* Offset command for gs to get image part with negative x/y-coord. */
|
||||
if ((offx != 0) || (offy != 0))
|
||||
sprintf (offset, "-c %d %d translate -- ", offx, offy);
|
||||
|
||||
/* Antialiasing not available for PBM-device */
|
||||
if ((loadopt->pnm_type != 4) && (loadopt->textalpha != 1))
|
||||
|
@ -1270,10 +1295,10 @@ ps_open (gchar *filename,
|
|||
sprintf (geometry,"-g%dx%d ", width, height);
|
||||
|
||||
cmd = g_strdup_printf ("%s -sDEVICE=%s -r%d %s%s%s-q -dNOPAUSE %s \
|
||||
-sOutputFile=%s %s %s-c quit",
|
||||
-sOutputFile=%s %s%s %s-c quit",
|
||||
gs, driver, resolution, geometry,
|
||||
TextAlphaBits, GraphicsAlphaBits,
|
||||
gs_opts, pnmfile, filename,
|
||||
gs_opts, pnmfile, offset, filename,
|
||||
*is_epsf ? "-c showpage " : "");
|
||||
#ifdef PS_DEBUG
|
||||
g_print ("Going to start ghostscript with:\n%s\n", cmd);
|
||||
|
@ -2675,7 +2700,7 @@ save_dialog (void)
|
|||
/* Image Size */
|
||||
frame = gtk_frame_new (_("Image Size"));
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_IN);
|
||||
gtk_box_pack_start (GTK_BOX (main_vbox[0]), frame, TRUE, TRUE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (main_vbox[0]), frame, FALSE, FALSE, 0);
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 4);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (vbox), 4);
|
||||
|
@ -2741,7 +2766,7 @@ save_dialog (void)
|
|||
_("Millimeter"), (gpointer) TRUE, NULL,
|
||||
|
||||
NULL);
|
||||
gtk_box_pack_end (GTK_BOX (vbox), uframe, FALSE, FALSE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), uframe, FALSE, FALSE, 0);
|
||||
gtk_widget_show (uframe);
|
||||
|
||||
gtk_widget_show (vbox);
|
||||
|
|
Loading…
Reference in New Issue