| 1 | // Aseprite Document Library | 
|---|
| 2 | // Copyright (c) 2018-2021 Igara Studio S.A. | 
|---|
| 3 | // Copyright (c) 2001-2016 David Capello | 
|---|
| 4 | // | 
|---|
| 5 | // This file is released under the terms of the MIT license. | 
|---|
| 6 | // Read LICENSE.txt for more information. | 
|---|
| 7 |  | 
|---|
| 8 | #ifndef DOC_PRIMITIVES_H_INCLUDED | 
|---|
| 9 | #define DOC_PRIMITIVES_H_INCLUDED | 
|---|
| 10 | #pragma once | 
|---|
| 11 |  | 
|---|
| 12 | #include "base/ints.h" | 
|---|
| 13 | #include "doc/color.h" | 
|---|
| 14 | #include "doc/image_buffer.h" | 
|---|
| 15 | #include "gfx/fwd.h" | 
|---|
| 16 |  | 
|---|
| 17 | namespace doc { | 
|---|
| 18 | class Brush; | 
|---|
| 19 | class Image; | 
|---|
| 20 | class Palette; | 
|---|
| 21 | class Remap; | 
|---|
| 22 |  | 
|---|
| 23 | color_t get_pixel(const Image* image, int x, int y); | 
|---|
| 24 | void put_pixel(Image* image, int x, int y, color_t c); | 
|---|
| 25 |  | 
|---|
| 26 | void clear_image(Image* image, color_t bg); | 
|---|
| 27 |  | 
|---|
| 28 | void copy_image(Image* dst, const Image* src); | 
|---|
| 29 | void copy_image(Image* dst, const Image* src, int x, int y); | 
|---|
| 30 | void copy_image(Image* dst, const Image* src, const gfx::Region& rgn); | 
|---|
| 31 | Image* crop_image(const Image* image, int x, int y, int w, int h, color_t bg, const ImageBufferPtr& buffer = ImageBufferPtr()); | 
|---|
| 32 | Image* crop_image(const Image* image, const gfx::Rect& bounds, color_t bg, const ImageBufferPtr& buffer = ImageBufferPtr()); | 
|---|
| 33 | void rotate_image(const Image* src, Image* dst, int angle); | 
|---|
| 34 |  | 
|---|
| 35 | void draw_hline(Image* image, int x1, int y, int x2, color_t c); | 
|---|
| 36 | void draw_vline(Image* image, int x, int y1, int y2, color_t c); | 
|---|
| 37 | void draw_rect(Image* image, int x1, int y1, int x2, int y2, color_t c); | 
|---|
| 38 | void fill_rect(Image* image, int x1, int y1, int x2, int y2, color_t c); | 
|---|
| 39 | void fill_rect(Image* image, const gfx::Rect& rc, color_t c); | 
|---|
| 40 | void blend_rect(Image* image, int x1, int y1, int x2, int y2, color_t c, int opacity); | 
|---|
| 41 | void draw_line(Image* image, int x1, int y1, int x2, int y2, color_t c); | 
|---|
| 42 | void draw_ellipse(Image* image, int x1, int y1, int x2, int y2, int , int , color_t color); | 
|---|
| 43 | void fill_ellipse(Image* image, int x1, int y1, int x2, int y2, int , int , color_t color); | 
|---|
| 44 |  | 
|---|
| 45 | bool is_plain_image(const Image* img, color_t c); | 
|---|
| 46 | bool is_empty_image(const Image* img); | 
|---|
| 47 |  | 
|---|
| 48 | int count_diff_between_images(const Image* i1, const Image* i2); | 
|---|
| 49 | bool is_same_image(const Image* i1, const Image* i2); | 
|---|
| 50 |  | 
|---|
| 51 | void remap_image(Image* image, const Remap& remap); | 
|---|
| 52 |  | 
|---|
| 53 | uint32_t calculate_image_hash(const Image* image, | 
|---|
| 54 | const gfx::Rect& bounds); | 
|---|
| 55 |  | 
|---|
| 56 | // Sets RGB values to 0 when alpha=0 (to match images with alpha=0 | 
|---|
| 57 | // in tilesets/calculate_image_hash) | 
|---|
| 58 | void preprocess_transparent_pixels(Image* image); | 
|---|
| 59 |  | 
|---|
| 60 | } // namespace doc | 
|---|
| 61 |  | 
|---|
| 62 | #endif | 
|---|
| 63 |  | 
|---|