fix max size of graph bitmap calculation in svg_embedded_graph() and ps_embedded_graph()

This commit is contained in:
stefan schippers 2025-02-10 01:21:22 +01:00
parent 5e3c27d7ee
commit 724869638e
3 changed files with 8 additions and 7 deletions

View File

@ -4777,7 +4777,7 @@ void svg_embedded_graph(FILE *fd, xRect *r, double rx1, double ry1, double rx2,
cairo_surface_t *png_sfc;
int save, save_draw_window, save_draw_grid, rwi, rhi;
size_t olength;
const double max_size = 3000.0;
const double max_size = 2500.0;
if(!has_x) return;
@ -4792,9 +4792,9 @@ void svg_embedded_graph(FILE *fd, xRect *r, double rx1, double ry1, double rx2,
rw = fabs(rx2 -rx1);
rh = fabs(ry2 - ry1);
scale = 3.0;
if(rw > rh && rw > max_size) {
if(rw > rh && rw * scale > max_size) {
scale = max_size / rw;
} else if(rh > max_size) {
} else if(rh * scale > max_size) {
scale = max_size / rh;
}
rwi = (int) (rw * scale + 1.0);
@ -4882,7 +4882,6 @@ void draw(void)
#endif
dbg(1, "draw()\n");
if(!xctx || xctx->no_draw) return;
cs = tclgetdoublevar("cadsnap");

View File

@ -257,7 +257,7 @@ static int ps_embedded_graph(xRect* r, double rx1, double ry1, double rx2, doubl
double rw, rh, scale;
cairo_surface_t* png_sfc;
int save, save_draw_window, save_draw_grid, rwi, rhi;
const double max_size = 3000.0;
const double max_size = 2500.0;
int d_c;
unsigned char* jpgData = NULL;
size_t fileSize = 0;
@ -292,10 +292,10 @@ static int ps_embedded_graph(xRect* r, double rx1, double ry1, double rx2, doubl
rw = fabs(rx2 - rx1);
rh = fabs(ry2 - ry1);
scale = 3.0;
if (rw > rh && rw > max_size) {
if (rw > rh && rw * scale > max_size) {
scale = max_size / rw;
}
else if (rh > max_size) {
else if (rh * scale > max_size) {
scale = max_size / rh;
}
rwi = (int)(rw * scale + 1.0);

View File

@ -2185,6 +2185,8 @@ void resetwin(int create_pixmap, int clear_pixmap, int force, int w, int h)
#else
XWindowAttributes wattr;
#endif
dbg(1, "resetwin(): create=%d, clear=%d, force=%d, w=%d, h=%d\n",
create_pixmap, clear_pixmap, force, w, h);
if(w && h) {
width = w;
height = h;