dl
dl_image.h
浏览该文件的文档.
1
16#pragma once
17
18#include <string>
19
20#include "base/dl_vector2.h"
21#include "dl_type.h"
22#include "base/dl_range_any.h"
23
24namespace dl
25{
26
28
35Image* createImage(const Size& size, const Color& col);
41Image* createImage(std::string_view path_name);
42
49Image* createImageSvg(std::string_view path_name, const Size& size);
50
54bool saveImage(const Image* img, std::string_view path_name);
55
56namespace Img
57{
64inline bool IsSupportFormat(std::string_view str, bool read)
65{
66 constexpr std::array<std::string_view, 8> ARRAY_READ = {
67 "jpg", "png", "tga", "bmp", "psd", "gif", "hdr", "pic"
68 };
69 constexpr std::array<std::string_view, 3> ARRAY_WRITE = {
70 "png", "tag", "bmp"
71 };
72 return read ? Any::Equal(ARRAY_READ, str) : Any::Equal(ARRAY_WRITE, str);
73}
74
75
76
81void CalcLeastRect(const Image* img, RectU& rect);
82
83
88bool IsHaveTranslucent(const Image* img, const RectU& rect);
89
98void AddImageRect(Image* img_tar, const Image* img_src, const RectU& rect, const PointU& tar_xy);
99
103void SetAlphaZero(const Image* img);
104
105}
106}
范围操作 任一满足条件
2维vector
bool Equal(const C &container, const V &v)
判断容器任意元素等于某值
Definition: dl_range_any.h:24
void CalcLeastRect(const Image *img, RectU &rect)
计算返回最小包围盒(去除边缘的全透明像素)
bool IsSupportFormat(std::string_view str, bool read)
是否支持的格式
Definition: dl_image.h:64
bool IsHaveTranslucent(const Image *img, const RectU &rect)
返回是否包含非透明颜色
void AddImageRect(Image *img_tar, const Image *img_src, const RectU &rect, const PointU &tar_xy)
添加另一个图像的部分到自己的位置上
void SetAlphaZero(const Image *img)
设置透明色颜色为0,针对于某些颜色透明,但是其他通道非0
Definition: dl_array2.h:17
PointU Size
Definition: dl_type_def.h:34
bool saveImage(const Image *img, std::string_view path_name)
保存到图像
Point4U RectU
Definition: dl_type_def.h:35
Image * createImageSvg(std::string_view path_name, const Size &size)
创建图像 从svg
Image * createImage(const Size &size, const Color &col)
创建图像
std::array< float, 4 > Color
Definition: dl_type_def.h:49
Point2U PointU
Definition: dl_type_def.h:32