整理代码
This commit is contained in:
commit
c7b4e178ec
364 changed files with 59691 additions and 0 deletions
52
video/core/Image.h
Normal file
52
video/core/Image.h
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
#ifndef CF80473A_40DD_43E5_B0D7_73F2205E9DF6
|
||||
#define CF80473A_40DD_43E5_B0D7_73F2205E9DF6
|
||||
/*
|
||||
*******************************************************************************
|
||||
* INCLUDE
|
||||
*******************************************************************************
|
||||
*/
|
||||
#include "Color.h"
|
||||
#include "GeometryTypes.h"
|
||||
#include <CImg.h>
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
#include <Poco/SharedPtr.h>
|
||||
#include <functional>
|
||||
|
||||
using namespace cimg_library;
|
||||
|
||||
namespace Video
|
||||
{
|
||||
namespace Core
|
||||
{
|
||||
/*
|
||||
*******************************************************************************
|
||||
* CLASS DECLARE
|
||||
*******************************************************************************
|
||||
*/
|
||||
class Image: public CImg<uint8_t>
|
||||
{
|
||||
public:
|
||||
using Ptr = Poco::SharedPtr<Image>;
|
||||
using CImg::CImg;
|
||||
|
||||
void drawText(const std::string& text, const std::string& font, int size, Color foreColor, Color bgColor);
|
||||
void drawRectangle(const Rect& rect, Color& color, int border = 0);
|
||||
void drawImage(int x, int y, Ptr pImage);
|
||||
void getPixel(int x, int y, Color& color);
|
||||
void forceAlpha(uint8_t alpha);
|
||||
|
||||
static void computeStringSize(const std::string& text, const std::string& font, int fontsz, Size& size);
|
||||
|
||||
protected:
|
||||
static int computeStringBBox(std::wstring text, FT_Face face, FT_BBox& bbox);
|
||||
static void convertText(const std::string& from, std::wstring& to);
|
||||
static void runOnFreeType(const std::string& font, int size, std::function<void(FT_Face&)> func);
|
||||
|
||||
private:
|
||||
bool _forceAlphaEnabled = false;
|
||||
uint8_t _forceAlphaValue;
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue