protect with #if HAS_CAIRO==1 the edit_image() calls
This commit is contained in:
parent
d5f7c5c88c
commit
294529f885
12
src/draw.c
12
src/draw.c
|
|
@ -4008,6 +4008,7 @@ int edit_image(int what, xRect *r)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if HAS_CAIRO==1
|
||||||
static cairo_surface_t *get_surface_from_b64data(const char *attr)
|
static cairo_surface_t *get_surface_from_b64data(const char *attr)
|
||||||
{
|
{
|
||||||
int jpg = -1;
|
int jpg = -1;
|
||||||
|
|
@ -4041,6 +4042,7 @@ static cairo_surface_t *get_surface_from_b64data(const char *attr)
|
||||||
my_free(_ALLOC_ID_, &closure.buffer);
|
my_free(_ALLOC_ID_, &closure.buffer);
|
||||||
return surface;
|
return surface;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* rot and flip for rotated / flipped symbols
|
/* rot and flip for rotated / flipped symbols
|
||||||
* dr: 1 draw image
|
* 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;
|
xctx->areax1,xctx->areay1,xctx->areax2,xctx->areay2)) return 0;
|
||||||
set_rect_extraptr(1, r); /* create r->extraptr pointing to a xEmb_image struct */
|
set_rect_extraptr(1, r); /* create r->extraptr pointing to a xEmb_image struct */
|
||||||
emb_ptr = r->extraptr;
|
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));
|
my_strncpy(filename, get_tok_value(r->prop_ptr, "image", 0), S(filename));
|
||||||
/******* read image from in-memory buffer ... *******/
|
/******* read image from in-memory buffer ... *******/
|
||||||
if(emb_ptr && emb_ptr->image) {
|
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) {
|
} else if( (attr = get_tok_value(r->prop_ptr, "image_data", 0))[0] && strlen(attr) > 5) {
|
||||||
emb_ptr->image = get_surface_from_b64data(attr);
|
emb_ptr->image = get_surface_from_b64data(attr);
|
||||||
if(!emb_ptr->image) {
|
if(!emb_ptr->image) {
|
||||||
if(jpg != 1)
|
|
||||||
dbg(0, "draw_image(): failure creating image surface from \"image_data\" attribute\n");
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/******* ... or read PNG from file (image attribute) *******/
|
/******* ... 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;
|
scaley = rh/h * xctx->mooz;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(dr) {
|
||||||
|
cairo_save(xctx->cairo_ctx);
|
||||||
|
cairo_save(xctx->cairo_save_ctx);
|
||||||
|
}
|
||||||
if(dr && xctx->draw_pixmap) {
|
if(dr && xctx->draw_pixmap) {
|
||||||
cairo_translate(xctx->cairo_save_ctx, x, y);
|
cairo_translate(xctx->cairo_save_ctx, x, y);
|
||||||
cairo_rotate(xctx->cairo_save_ctx, rot * XSCH_PI * 0.5);
|
cairo_rotate(xctx->cairo_save_ctx, rot * XSCH_PI * 0.5);
|
||||||
|
|
|
||||||
|
|
@ -2032,6 +2032,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
|
||||||
else { cmd_found = 0;}
|
else { cmd_found = 0;}
|
||||||
break;
|
break;
|
||||||
case 'i': /*----------------------------------------------*/
|
case 'i': /*----------------------------------------------*/
|
||||||
|
#if HAS_CAIRO==1
|
||||||
/* image [invert|white_transp|black_transp|transp_white|transp_black|write_back]
|
/* image [invert|white_transp|black_transp|transp_white|transp_black|write_back]
|
||||||
* Apply required changes to selected images
|
* Apply required changes to selected images
|
||||||
* invert: invert colors
|
* invert: invert colors
|
||||||
|
|
@ -2078,7 +2079,8 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
|
||||||
draw();
|
draw();
|
||||||
Tcl_ResetResult(interp);
|
Tcl_ResetResult(interp);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
/* instance sym_name x y rot flip [prop] [n]
|
/* instance sym_name x y rot flip [prop] [n]
|
||||||
* Place a new instance of symbol 'sym_name' at position x,y,
|
* Place a new instance of symbol 'sym_name' at position x,y,
|
||||||
* rotation and flip set to 'rot', 'flip'
|
* 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
|
* if 'n' is given it must be 0 on first call
|
||||||
* and non zero on following calls
|
* and non zero on following calls
|
||||||
* It is used only for efficiency reasons if placing multiple instances */
|
* 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(!xctx) {Tcl_SetResult(interp, not_avail, TCL_STATIC); return TCL_ERROR;}
|
||||||
if(argc==7) {
|
if(argc==7) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue