-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgui.cpccImageBase.h
63 lines (51 loc) · 2.66 KB
/
gui.cpccImageBase.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/* *****************************************
* File: gui.cpccImageBase.h
* Version:
* Purpose: Portable (cross-platform), light-weight library
* image class
* *****************************************
* Library: Cross Platform C++ Classes (cpcc)
* Copyright: 2014 StarMessage software.
* License: Free for opensource projects.
* Commercial license for closed source projects.
* Web: http://www.StarMessageSoftware.com/cpcclibrary
* Download: https://code.google.com/p/cpcc/
* https://github.com/starmessage/cpcc
* email: sales -at- starmessage.info
* *****************************************
*/
#pragma once
#include "cpccColor.h"
#include "gui.cpccWindowBase.h"
#include "gui.cpccText.h"
// This class is the abstract image class against which you must do your programming
// Only the class factory should know what is the exact implementation that will be instatiated.
class cpccImageBase
{
protected: // data
bool m_hasTrasparentColor;
cpccColor m_transparentColor;
public: // constructor
cpccImageBase(): m_hasTrasparentColor(false) { }
virtual ~cpccImageBase() { }
public: // concrete functions
const cpccColor* getTransparentColor(void) const { return m_hasTrasparentColor? &m_transparentColor: NULL; }
virtual void setTransparentColor(const cpccColor &aColor) { m_transparentColor=aColor; m_hasTrasparentColor=true; }
void removeTransparency(void) { m_hasTrasparentColor=false; }
public: // abstract functions
virtual void initWithSizeAndColor(const int aWidth, const int aHeight, const cpccColor &aColor)=0;
virtual bool initWithFile(const cpcc_char* afullpathfilename, const bool hasTransparentCorner=false)=0;
#ifdef _WIN32
virtual bool initWithResource(const int resourceID, const bool transparentCorner) = 0;
#endif
virtual cpccColor getPixel(const int x, const int y) const =0;
virtual void setPixel(const int x, const int y, const cpccColor &aColor)=0;
virtual void amplifyPixel(const int x, const int y, const float xR, const float xG, const float xB )=0;
virtual int getWidth(void) const =0;
virtual int getHeight(void) const =0;
virtual void drawText(int x, int y, const cpcc_char *text, const cpccTextParams& params)=0;
virtual void drawInWindow(cpccWindowBase *destWindow, const int x, const int y) const =0;
virtual void resizeBy(const float aFactor) { resizeTo((int) (getWidth()*aFactor), (int) (getHeight()*aFactor)); }
virtual void resizeTo(const int newWidth, const int newHeight) =0;
virtual void cropTo(const int newTop, int newLeft, int newWidth, int newHeight)=0;
};