terom@1: #include terom@1: #include terom@1: terom@1: #include "render.h" terom@1: terom@1: int render_init (render_t *ctx, int mode) { terom@1: memset(ctx, 0, sizeof(*ctx)); terom@1: terom@1: return render_set_mode(ctx, mode); terom@1: } terom@1: terom@1: int render_set_mode (render_t *ctx, int mode) { terom@1: if (mode != RENDER_RAW && mode != RENDER_PNG) terom@1: return RENDER_ERR; terom@1: terom@1: ctx->mode = mode; terom@1: terom@1: return RENDER_OK; terom@1: } terom@1: terom@1: int render_set_size (render_t *ctx, u_int32_t img_w, u_int32_t img_h) { terom@1: if (img_w == 0 || img_h == 0) terom@1: return RENDER_ERR; terom@1: terom@1: ctx->img_w = img_w; terom@1: ctx->img_h = img_h; terom@1: terom@1: return RENDER_OK; terom@1: } terom@1: terom@1: int render_region_full (render_t *ctx) { terom@1: return render_region_raw(ctx, REGION_X1, REGION_Y1, REGION_X2, REGION_Y2); terom@1: } terom@1: terom@1: int render_region_raw (render_t *ctx, double x1, double y1, double x2, double y2) { terom@1: if ((x1 >= x2) || (y1 >= y2)) terom@1: return RENDER_ERR; terom@1: terom@1: ctx->x1 = x1; terom@1: ctx->y1 = y1; terom@1: ctx->x2 = x2; terom@1: ctx->y2 = y2; terom@1: terom@1: return RENDER_OK; terom@1: } terom@1: terom@1: int render_io_custom (render_t *ctx, render_ctx_write_cb write_fn, render_ctx_flush_cb flush_fn, void *arg) { terom@1: if (!write_fn) terom@1: return RENDER_ERR; terom@1: terom@1: ctx->io_write_fn = write_fn; terom@1: ctx->io_flush_fn = flush_fn; terom@1: ctx->io_cb_arg = arg; terom@1: terom@1: return RENDER_OK; terom@1: } terom@1: terom@1: int render_io_stream (render_t *ctx, FILE *fh) { terom@1: if (!fh) terom@1: return RENDER_ERR; terom@1: terom@1: ctx->io_stream = fh; terom@1: terom@1: return RENDER_OK; terom@1: } terom@1: