61ddf77277
* BUG: Link with libgettextlib only with OpenBSD. Otherwise, on Linux, there is a symbol comflict with the libxml used by fontconfig, and you get spurious fontconfig warnings, and weird fonts or no font at all! [DEVELOPMENT ENVIRONMENT] * NEW: Use the new image methods for the hall of fame animation. * BUG: Text editor does not flash anymore when being resized. * BUG: The virtual control are now drawn bigger in Dekstop.Scale is too small. [EXAMPLES] * BUG: Fix many examples according to the new way of calculating Desktop.Scale. [INTERPRETER] * BUG: Symbol polymorphism is now correctly handled when the inheritance depth is greater than two! [GB.GTK] * NEW: Image.MakeGray() is a new method that makes an image use gray colors only. * NEW: Image.MakeTransparent() is a new method that intelligently replace a color by transparency. [GB.FORM] * NEW: Add a slider for setting the alpha color component. * BUG: Correctly cancel an impossible rename operation in the DirView control. [GB.QT] * NEW: Image.MakeGray() is a new method that makes an image use gray colors only. * NEW: Image.MakeTransparent() is a new method that intelligently replace a color by transparency. [GB.QT.EXT] * BUG: In Editor, always draw function expanders with the foreground color. git-svn-id: svn://localhost/gambas/trunk@1308 867c0c6c-44f3-4631-809d-bfa615b0a4ec
143 lines
2.9 KiB
C++
143 lines
2.9 KiB
C++
#ifndef __GPICTURE_H
|
|
#define __GPICTURE_H
|
|
|
|
#include "widgets.h"
|
|
#include "gshare.h"
|
|
#include "gcolor.h"
|
|
#include "gtag.h"
|
|
|
|
class alphaCache;
|
|
|
|
class gPicture : public gShare
|
|
{
|
|
public:
|
|
|
|
enum gPictureType
|
|
{
|
|
VOID,
|
|
MEMORY,
|
|
SERVER
|
|
};
|
|
|
|
gPicture();
|
|
gPicture(gPictureType type, int w, int h, bool trans);
|
|
~gPicture();
|
|
gPicture *copy();
|
|
|
|
bool isVoid() { return _type == VOID; }
|
|
|
|
static void assign(gPicture **dst, gPicture *src = 0) { gShare::assign((gShare **)dst, src); }
|
|
|
|
gPictureType type() const { return _type; }
|
|
int width() const { return _width; }
|
|
int height() const { return _height; }
|
|
int depth();
|
|
bool isTransparent() const { return _transparent; }
|
|
unsigned char *data();
|
|
|
|
void setTransparent(bool vl);
|
|
|
|
void clear();
|
|
void resize(int width,int height);
|
|
int save(const char *path, int quality = -1);
|
|
void fill(gColor col);
|
|
gPicture *copy(int x, int y, int w, int h);
|
|
|
|
gPicture *flip(bool mirror = false);
|
|
gPicture *mirror() { return flip(true); }
|
|
gPicture *rotate(double ang);
|
|
gPicture *stretch(int w, int h, bool smooth);
|
|
|
|
gColor getPixel(int x, int y);
|
|
void putPixel(int x, int y, gColor col);
|
|
void replace(gColor src, gColor dst, bool noteq = false);
|
|
void draw(gPicture *src, int x, int y, int w = -1, int h = -1, int sx = 0, int sy = 0, int sw = -1, int sh = -1);
|
|
void makeGray();
|
|
void makeTransparent(gColor color);
|
|
|
|
static gPicture *fromNamedIcon(const char *name, int len = -1);
|
|
static gPicture *fromMemory(char *addr, unsigned int len);
|
|
|
|
//"Private"
|
|
GdkPixmap *pic;
|
|
GdkBitmap *mask;
|
|
GdkPixbuf *img;
|
|
|
|
gPictureType _type;
|
|
bool _transparent;
|
|
int _width;
|
|
int _height;
|
|
|
|
gPicture(GdkPixbuf *image, bool trans = true);
|
|
gPicture(GdkPixmap *pixmap);
|
|
void initialize();
|
|
GdkPixbuf *getPixbuf();
|
|
GdkPixmap *getPixmap();
|
|
GdkBitmap *getMask();
|
|
|
|
static gPicture* fromPixbuf(GdkPixbuf *buf) { return new gPicture(buf); }
|
|
|
|
// "Private"
|
|
void invalidate();
|
|
void createMask(bool white);
|
|
};
|
|
|
|
class gPictureCache
|
|
{
|
|
public:
|
|
static void put(const char *key, gPicture *img);
|
|
static gPicture *get(const char *key);
|
|
static void flush();
|
|
static void init();
|
|
static void exit();
|
|
private:
|
|
static GHashTable *cache;
|
|
};
|
|
|
|
#if 0
|
|
|
|
class gPicture
|
|
{
|
|
public:
|
|
gPicture(int w,int h,bool trans);
|
|
~gPicture();
|
|
|
|
int width();
|
|
int height();
|
|
int depth();
|
|
bool transparent();
|
|
|
|
void setTransparent(bool vl);
|
|
|
|
void resize(int width,int height);
|
|
int save(char *path);
|
|
void fromMemory(char *addr,unsigned int len);
|
|
static gPicture* fromNamedIcon(char* name);
|
|
void Fill(int col);
|
|
gPicture* getImage();
|
|
gPicture* copy(int x,int y,int w,int h);
|
|
|
|
void ref();
|
|
void unref();
|
|
|
|
//"Private"
|
|
GdkDrawable *pic;
|
|
alphaCache *cache;
|
|
int _transparent;
|
|
GdkPixbuf* getPixbuf();
|
|
static gPicture* fromPixbuf(GdkPixbuf *buf);
|
|
int refcount;
|
|
};
|
|
|
|
class gPictureCache
|
|
{
|
|
public:
|
|
static void save(char *key,gPicture *img);
|
|
static gPicture* load(char *key);
|
|
static void flush();
|
|
};
|
|
|
|
#endif
|
|
|
|
#endif
|