protect with #if HAS_CAIRO==1 the edit_image() calls

This commit is contained in:
stefan schippers 2024-03-17 01:56:59 +01:00
parent d5f7c5c88c
commit 294529f885
2 changed files with 10 additions and 8 deletions

View File

@ -4008,6 +4008,7 @@ int edit_image(int what, xRect *r)
}
#endif
#if HAS_CAIRO==1
static cairo_surface_t *get_surface_from_b64data(const char *attr)
{
int jpg = -1;
@ -4041,6 +4042,7 @@ static cairo_surface_t *get_surface_from_b64data(const char *attr)
my_free(_ALLOC_ID_, &closure.buffer);
return surface;
}
#endif
/* rot and flip for rotated / flipped symbols
* dr: 1 draw image
@ -4075,10 +4077,6 @@ int draw_image(int dr, xRect *r, double *x1, double *y1, double *x2, double *y2,
xctx->areax1,xctx->areay1,xctx->areax2,xctx->areay2)) return 0;
set_rect_extraptr(1, r); /* create r->extraptr pointing to a xEmb_image struct */
emb_ptr = r->extraptr;
if(dr) {
cairo_save(xctx->cairo_ctx);
cairo_save(xctx->cairo_save_ctx);
}
my_strncpy(filename, get_tok_value(r->prop_ptr, "image", 0), S(filename));
/******* read image from in-memory buffer ... *******/
if(emb_ptr && emb_ptr->image) {
@ -4087,8 +4085,6 @@ int draw_image(int dr, xRect *r, double *x1, double *y1, double *x2, double *y2,
} else if( (attr = get_tok_value(r->prop_ptr, "image_data", 0))[0] && strlen(attr) > 5) {
emb_ptr->image = get_surface_from_b64data(attr);
if(!emb_ptr->image) {
if(jpg != 1)
dbg(0, "draw_image(): failure creating image surface from \"image_data\" attribute\n");
return 0;
}
/******* ... or read PNG from file (image attribute) *******/
@ -4189,6 +4185,10 @@ int draw_image(int dr, xRect *r, double *x1, double *y1, double *x2, double *y2,
scaley = rh/h * xctx->mooz;
}
}
if(dr) {
cairo_save(xctx->cairo_ctx);
cairo_save(xctx->cairo_save_ctx);
}
if(dr && xctx->draw_pixmap) {
cairo_translate(xctx->cairo_save_ctx, x, y);
cairo_rotate(xctx->cairo_save_ctx, rot * XSCH_PI * 0.5);

View File

@ -2032,6 +2032,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
else { cmd_found = 0;}
break;
case 'i': /*----------------------------------------------*/
#if HAS_CAIRO==1
/* image [invert|white_transp|black_transp|transp_white|transp_black|write_back]
* Apply required changes to selected images
* invert: invert colors
@ -2078,7 +2079,8 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
draw();
Tcl_ResetResult(interp);
}
else
#endif
/* instance sym_name x y rot flip [prop] [n]
* Place a new instance of symbol 'sym_name' at position x,y,
* rotation and flip set to 'rot', 'flip'
@ -2087,7 +2089,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
* if 'n' is given it must be 0 on first call
* and non zero on following calls
* It is used only for efficiency reasons if placing multiple instances */
else if(!strcmp(argv[1], "instance"))
if(!strcmp(argv[1], "instance"))
{
if(!xctx) {Tcl_SetResult(interp, not_avail, TCL_STATIC); return TCL_ERROR;}
if(argc==7) {