small tweaks

isolation_bkp/dynres
Dominik Madarász 2021-05-16 16:58:08 +02:00
parent 44066273ea
commit 88f77b709f
7 changed files with 852 additions and 826 deletions

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.0 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

@ -68,6 +68,8 @@ typedef enum {
TOP_DRAW_TEXT,
TOP_RESIZE_IMAGE,
TOP_COLOR_TWEAKS,
TOP_FLIP_IMAGE,
TOP_ROTATE_IMAGE,
TOP_FORCE_UINT8 = UINT8_MAX
} td_op_kind;

View File

@ -43,11 +43,25 @@ void texed_process_ops(void) {
int y = op->params[2].i32;
int w = op->params[3].i32;
int h = op->params[4].i32;
int flip = op->params[5].i32;
int rotate = op->params[6].i32;
if (w != -1 || h != -1) {
ImageResize(&img, w != -1 ? w : img.width, h != -1 ? h : img.height);
}
if (flip == 1) {
ImageFlipVertical(&img);
} else if (flip == 2) {
ImageFlipHorizontal(&img);
}
if (rotate == 1) {
ImageRotateCW(&img);
} else if (rotate == 2) {
ImageRotateCCW(&img);
}
ImageDraw(&ctx.img, img,
(Rectangle){0.0f, 0.0f, img.width, img.height},
(Rectangle){x, y, img.width, img.height},
@ -81,6 +95,13 @@ void texed_process_ops(void) {
ImageColorContrast(&ctx.img, texed_map_value(op->params[0].flt, -100.0f, 100.0f));
ImageColorBrightness(&ctx.img, (int)texed_map_value(op->params[1].flt, -255.0f, 255.0f));
ImageColorTint(&ctx.img, op->params[2].color);
if (op->params[3].i32) {
ImageColorInvert(&ctx.img);
}
if (op->params[4].i32) {
ImageColorGrayscale(&ctx.img);
}
}break;
default: {
zpl_printf("%s\n", "unsupported op!");
@ -101,9 +122,7 @@ void texed_process_params(void) {
case TPARAM_FLOAT: {
p->flt = (float)zpl_str_to_f64(p->str, NULL);
}break;
case TPARAM_INT: {
p->u32 = (uint32_t)zpl_str_to_i64(p->str, NULL, 10);
}break;
case TPARAM_INT:
case TPARAM_COORD: {
p->i32 = (int32_t)zpl_str_to_i64(p->str, NULL, 10);
}break;

View File

@ -32,13 +32,15 @@ static td_op default_ops[] = {
}
},{
OP(TOP_DRAW_IMAGE),
PARAMS(6) {
PARAMS(8) {
PARAM(TPARAM_STRING, "src", "samples/test.png"),
PARAM(TPARAM_COORD, "x", "0"),
PARAM(TPARAM_COORD, "y", "0"),
PARAM(TPARAM_COORD, "w", "-1"),
PARAM(TPARAM_COORD, "h", "-1"),
PARAM(TPARAM_COLOR, "tint", "ffffffff"),
PARAM(TPARAM_INT, "flip?", "0"),
PARAM(TPARAM_INT, "rotate?", "0"),
}
},{
OP(TOP_DRAW_TEXT),
@ -66,10 +68,12 @@ static td_op default_ops[] = {
}
},{
OP(TOP_COLOR_TWEAKS),
PARAMS(3) {
PARAMS(5) {
PARAM(TPARAM_SLIDER, "contrast", "0.5"),
PARAM(TPARAM_SLIDER, "brightness", "0.5"),
PARAM(TPARAM_COLOR, "tint", "FFFFFFFF"),
PARAM(TPARAM_INT, "invert?", "0"),
PARAM(TPARAM_INT, "grayscale?", "0"),
}
}
};

View File

@ -291,6 +291,7 @@ void texed_draw_props_pane(zpl_aabb2 r) {
texed_repaint_preview();
}
}break;
case TPARAM_INT:
case TPARAM_COORD: {
if (GuiValueBox(aabb2_ray(tbox_r), NULL, &p->i32, INT32_MIN, INT32_MAX, p->edit_mode)) {
p->edit_mode = !p->edit_mode;