diff options
Diffstat (limited to 'image/image.c')
-rw-r--r-- | image/image.c | 69 |
1 files changed, 67 insertions, 2 deletions
diff --git a/image/image.c b/image/image.c index cf5badc4d..becf221b9 100644 --- a/image/image.c +++ b/image/image.c @@ -22,8 +22,11 @@ #include <string.h> #include "utils/errors.h" +#include "utils/config.h" +#include "utils/log.h" +#include "desktop/plotters.h" +#include "image/bitmap.h" -#include "image/image.h" #include "image/bmp.h" #include "image/gif.h" #include "image/ico.h" @@ -35,7 +38,7 @@ #include "image/svg.h" #include "image/webp.h" -#include "utils/config.h" +#include "image/image.h" /** * Initialise image content handlers @@ -114,3 +117,65 @@ nserror image_init(void) return NSERROR_OK; } + +bool image_bitmap_plot(struct bitmap *bitmap, + struct content_redraw_data *data, + const struct rect *clip, + const struct redraw_context *ctx) +{ + bitmap_flags_t flags = BITMAPF_NONE; + + int width; + int height; + unsigned char *pixel; + plot_style_t fill_style; + struct rect area; + + width = bitmap_get_width(bitmap); + if (width == 1) { + height = bitmap_get_height(bitmap); + if (height == 1) { + /* optimise 1x1 bitmap plot */ + pixel = bitmap_get_buffer(bitmap); + fill_style.fill_colour = pixel_to_colour(pixel); + + if (bitmap_get_opaque(bitmap) || + ((fill_style.fill_colour & 0xff000000) == 0xff000000)) { + + area = *clip; + + if (data->repeat_x != true) { + area.x0 = data->x; + area.x1 = data->x + data->width; + } + + if (data->repeat_y != true) { + area.y0 = data->y; + area.y1 = data->y + data->height; + } + + fill_style.stroke_type = PLOT_OP_TYPE_NONE; + fill_style.fill_type = PLOT_OP_TYPE_SOLID; + + return ctx->plot->rectangle(area.x0, area.y0, + area.x1, area.y1, + &fill_style); + + } else if ((fill_style.fill_colour & 0xff000000) == 0) { + /* transparent pixel used as spacer, skip it */ + return true; + } + } + } + + /* do the plot */ + if (data->repeat_x) + flags |= BITMAPF_REPEAT_X; + if (data->repeat_y) + flags |= BITMAPF_REPEAT_Y; + + return ctx->plot->bitmap(data->x, data->y, data->width, data->height, + bitmap, data->background_colour, flags); + + +} |