17 #ifndef _uhardima_hpp_ 18 #define _uhardima_hpp_ 1 19 #include <ubit/ubit_features.h> 20 #include <ubit/udisp.hpp> 22 # include <ubit/ugl.hpp> 28 # include <X11/Xlib.h> 29 # include <X11/Xutil.h> 30 #define SysPutPixel(I,X,Y,P) XPutPixel(I,X,Y,P) 31 #define SysGetPixel(I,X,Y) XGetPixel(I,X,Y) 33 typedef XImage* USysIma;
34 typedef Pixmap USysPixmap;
35 typedef unsigned long USysPixel;
36 typedef XColor USysColor;
37 typedef XPoint USysPoint;
41 #define SysPutPixel(I,X,Y,P) gdk_image_put_pixel(I,X,Y,P) 42 #define SysGetPixel(I,X,Y) gdk_image_get_pixel(I,X,Y) 44 typedef GdkImage* USysIma;
45 typedef GdkPixmap* USysPixmap;
46 typedef guint32 USysPixel;
47 typedef GdkColor USysColor;
48 typedef GdkPoint USysPoint;
56 static int read(
UHardIma&,
const UStr& fname,
int wmax,
int hmax);
60 static int read(
UHardIma&,
const UStr& fname,
int wmax,
int hmax);
64 static int read(
UHardIma&,
const UStr& fname,
int wmax,
int hmax);
65 static int readFromData(
UHardIma&,
const char** xpm_data,
int wmax,
int hmax);
75 virtual int read(
const UStr& filename,
const char* filetype = null,
76 int max_w = 0,
int max_h = 0);
82 virtual int readFromData(
const char **xpm_data,
int max_w = 0,
int max_h = 0);
85 virtual void setRaster(
int width,
int height,
int alpha_hint) = 0;
95 virtual void setRasterAndAdopt(USysIma image, USysIma shapemask) = 0;
106 virtual UHardIma* createScaledClone(
float xscale,
float yscale,
UDisp* = 0) = 0;
109 virtual int getWidth()
const {
return width;}
110 virtual int getHeight()
const {
return height;}
111 virtual int getBpp()
const {
return bpp;}
116 UDisp* getDisp()
const {
return disp;}
117 virtual float getScale()
const = 0;
118 virtual bool isRealized()
const = 0;
122 friend class UGraphCtxX11;
123 friend class UGraphCtxGDK;
127 unsigned char transparency;
136 class UHardImaGL :
public UHardIma {
138 UHardImaGL(
UDisp*,
int width = 0,
int height = 0,
int transparency_hint = 24);
143 virtual ~UHardImaGL();
145 virtual bool isRealized()
const;
147 virtual void setRaster(
int width,
int height,
int transparency_hint);
149 virtual void setRasterAndAdopt(
unsigned char* pixels,
int width,
int height);
159 virtual void setRasterAndAdopt(USysIma ima, USysIma imashape);
162 virtual UHardIma* createScaledClone(
float xscale,
float yscale,
UDisp* = 0);
164 unsigned char* getPixels() {
return pixels;}
168 virtual float getScale()
const {
return 1.;}
170 GLuint getTexID()
const {
return texid;}
173 friend class UGlcontext;
176 unsigned char* pixels;
177 mutable GLuint texid;
178 void createTexFromPixels()
const;
181 #endif // UBIT_WITH_GL 190 class UHardIma2D :
public UHardIma {
192 UHardIma2D(
UDisp*,
int width = 0,
int height = 0,
int transparency_hint = 0);
197 virtual ~UHardIma2D();
199 virtual void setRaster(
int width,
int height,
int transparency_hint);
200 virtual void setRasterAndAdopt(USysIma ima, USysIma shape);
202 virtual UHardIma* createScaledClone(
float xscale,
float yscale,
UDisp* = 0);
205 unsigned long getPixel(
int x,
int y) {
return gdk_image_get_pixel(sys_ima, x, y);}
206 void setPixel(
unsigned long p,
int x,
int y) {gdk_image_put_pixel(sys_ima, p, x, y);}
208 unsigned long getPixel(
int x,
int y) {
return XGetPixel(sys_ima, x, y);}
209 void setPixel(
unsigned long p,
int x,
int y) {XPutPixel(sys_ima, p, x, y);}
212 virtual float getScale()
const {
return scale;}
214 USysIma getIma() {
return sys_ima;}
215 USysIma getImaShape() {
return sys_imashape;}
216 virtual bool isRealized()
const {
return sys_ima != null;}
220 static USysIma createEmptySysIma(
UDisp*,
int width,
int height,
int depth);
228 static USysIma createScaledSysIma(
UDisp* to_nd,
UDisp* from_nd,
229 USysIma from_ima,
float xscale,
float yscale);
238 static bool blendSysIma(
UDisp*, USysIma i1, USysIma i2,
float alpha);
243 static bool blendSysIma(
UDisp*, USysIma i1, USysPixel p2,
float alpha);
248 static USysPixel* allocSysColors(
UDisp*, USysColor* colors,
int col_count);
253 friend class UX11context;
254 USysIma sys_ima, sys_imashape;
264 UHardPix(
UDisp*, UHardIma2D* image = null);
271 virtual void setRasterFrom(
const USysIma image,
const USysIma shapemask = 0);
280 virtual int getWidth()
const {
return width;}
281 virtual int getHeight()
const {
return height;}
282 virtual int getBpp()
const {
return bpp;}
283 virtual int getTransparency()
const {
return transparency;}
284 UDisp* getDisp()
const {
return disp;}
285 virtual float getScale()
const {
return scale;}
286 virtual bool isRealized()
const {
return sys_pix != USysNull;}
288 USysPixmap getPixmap() {
return sys_pix;}
289 USysPixmap getPixmapShape() {
return sys_pixshape;}
293 friend class UX11context;
297 unsigned char transparency;
298 USysPixmap sys_pix, sys_pixshape;
Image.
Definition: uima.hpp:50
Display Context.
Definition: udisp.hpp:44
[Impl] image implementation (encapsulates system resources).
Definition: uhardima.hpp:71
virtual int getTransparency() const
0 (opaque), 1(bitmask) or >1(alpha channel).
Definition: uhardima.hpp:113
Definition: uhardima.hpp:63
Definition: uhardfont.hpp:31
Definition: uhardima.hpp:59
Definition: uhardima.hpp:55
Pixmap Image.
Definition: upix.hpp:31
Ubit String.
Definition: ustr.hpp:72