store zoom in ecotex files
parent
b26ac74cbf
commit
5863d6c746
BIN
art/demo.ecotex
BIN
art/demo.ecotex
Binary file not shown.
|
@ -57,6 +57,7 @@ typedef enum {
|
|||
TOP_DITHER,
|
||||
TOP_LOAD_IMAGE,
|
||||
TOP_DRAW_TEXT,
|
||||
TOP_RESIZE_IMAGE,
|
||||
|
||||
TOP_FORCE_UINT8 = UINT8_MAX
|
||||
} td_op_kind;
|
||||
|
|
|
@ -63,6 +63,16 @@ void texed_process_ops(void) {
|
|||
Color color = op->params[4].color;
|
||||
ImageDrawText(&ctx.img, str, x, y, size, color);
|
||||
}break;
|
||||
case TOP_RESIZE_IMAGE: {
|
||||
int w = op->params[0].i32;
|
||||
int h = op->params[1].i32;
|
||||
int mode = op->params[2].i32;
|
||||
if (mode) {
|
||||
ImageResize(&ctx.img, w, h);
|
||||
} else {
|
||||
ImageResizeNN(&ctx.img, w, h);
|
||||
}
|
||||
}break;
|
||||
default: {
|
||||
zpl_printf("%s\n", "unsupported op!");
|
||||
}break;
|
||||
|
|
|
@ -66,10 +66,19 @@ static td_op default_ops[] = {
|
|||
PARAM(TPARAM_INT, "size", "16"),
|
||||
PARAM(TPARAM_COLOR, "color", "ffffffff"),
|
||||
}
|
||||
},
|
||||
{
|
||||
OP(TOP_RESIZE_IMAGE),
|
||||
.num_params = 3,
|
||||
.params = (td_param[]) {
|
||||
PARAM(TPARAM_COORD, "w", "64"),
|
||||
PARAM(TPARAM_COORD, "h", "64"),
|
||||
PARAM(TPARAM_COORD, "mode (0=nearest,1=bicubic)", "0"),
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// NOTE(zaklaus): IMPORTANT !! keep these in sync
|
||||
static char const *add_op_list = "CLEAR SOLID;DRAW RECTANGLE;PLOT LINE;DITHER;LOAD IMAGE;DRAW TEXT";
|
||||
static char const *add_op_list = "NEW IMAGE;DRAW RECTANGLE;PLOT LINE;DITHER;LOAD IMAGE;DRAW TEXT;RESIZE IMAGE";
|
||||
|
||||
#define DEF_OPS_LEN (int)(sizeof(default_ops) / (sizeof(default_ops[0])))
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
//~ NOTE(zaklaus): DATA SERIALISATION
|
||||
|
||||
#define ECOTEX_VERSION 1
|
||||
#define ECOTEX_VERSION 2
|
||||
|
||||
#define UNPACK(kind) cw_unpack_next(&uc); assert(uc.item.type == kind);
|
||||
|
||||
|
@ -22,6 +22,9 @@ void texed_load(void) {
|
|||
UNPACK(CWP_ITEM_POSITIVE_INTEGER);
|
||||
int selected_op = (int)uc.item.as.u64;
|
||||
|
||||
UNPACK(CWP_ITEM_FLOAT);
|
||||
zoom = uc.item.as.real;
|
||||
|
||||
UNPACK(CWP_ITEM_ARRAY);
|
||||
int arrsize = (int)uc.item.as.array.size;
|
||||
for (int i = 0; i < arrsize; i += 1) {
|
||||
|
@ -75,6 +78,7 @@ void texed_save(void) {
|
|||
|
||||
cw_pack_unsigned(&pc, ECOTEX_VERSION);
|
||||
cw_pack_unsigned(&pc, ctx.selected_op);
|
||||
cw_pack_float(&pc, zoom);
|
||||
|
||||
cw_pack_array_size(&pc, zpl_array_count(ctx.ops));
|
||||
for (int i = 0; i < zpl_array_count(ctx.ops); i += 1) {
|
||||
|
|
Loading…
Reference in New Issue