summaryrefslogtreecommitdiff
path: root/SplashScreen/src/bitmap_funcs.h
diff options
context:
space:
mode:
authormataes2007 <mataes2007@e753b5eb-9565-29b2-b5c5-2cc6f99dfbcb>2011-11-26 15:41:10 +0000
committermataes2007 <mataes2007@e753b5eb-9565-29b2-b5c5-2cc6f99dfbcb>2011-11-26 15:41:10 +0000
commitf04d64869f3b1de54fb343f28f955584780001b8 (patch)
tree5453dc10de3d980de79ffe019fa0b5fcb692a27d /SplashScreen/src/bitmap_funcs.h
parent7aff1e4cb053394db57c2814d5fe1e6493e0cc75 (diff)
Project folders rename part 3
git-svn-id: http://miranda-plugins.googlecode.com/svn/trunk@215 e753b5eb-9565-29b2-b5c5-2cc6f99dfbcb
Diffstat (limited to 'SplashScreen/src/bitmap_funcs.h')
-rw-r--r--SplashScreen/src/bitmap_funcs.h77
1 files changed, 77 insertions, 0 deletions
diff --git a/SplashScreen/src/bitmap_funcs.h b/SplashScreen/src/bitmap_funcs.h
new file mode 100644
index 0000000..f82e909
--- /dev/null
+++ b/SplashScreen/src/bitmap_funcs.h
@@ -0,0 +1,77 @@
+#ifndef __bitmap_funcs_h__
+#define __bitmap_funcs_h__
+
+// This should make bitmap manipulations much easier...
+class MyBitmap
+{
+public:
+ typedef unsigned long COLOR32;
+ static inline COLOR32 RGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a = 0xff)
+ {
+ return (a << 24) | (r << 16) | (g << 8) | b;
+ };
+
+private:
+ HBITMAP hBmpSave, hBmp;
+ HDC dcBmp;
+ COLOR32 *bits;
+ COLOR32 *bitsSave;
+ int width, height;
+
+ void allocate(int w, int h);
+ void free();
+
+ void premultipleChannels();
+
+public:
+ MyBitmap();
+ MyBitmap(int w, int h);
+ MyBitmap(TCHAR *fn, TCHAR *fnAlpha = 0);
+ ~MyBitmap();
+
+ bool loadFromFile(TCHAR *fn, TCHAR *fnAlpha = 0);
+
+ int getWidth() { return width; }
+ int getHeight() { return height; }
+
+ HDC getDC() { return dcBmp; }
+ HBITMAP getBitmap() { return hBmp; }
+
+
+ void makeOpaque();
+
+ void saveAlpha(int x = 0, int y = 0, int w = 0, int h = 0);
+ void restoreAlpha(int x = 0, int y = 0, int w = 0, int h = 0);
+
+ void Blend(MyBitmap *bmp, int x, int y, int w, int h);
+ void DrawText(TCHAR *str, int x, int y);
+
+ inline COLOR32 *getBits() { return bits; }
+ inline COLOR32 *getRow(int row) { return bits + row * width; }
+ inline COLOR32 *operator[] (int row) { return bits + row * width; }
+
+ COLOR32 rgba(COLOR32 r, COLOR32 g, COLOR32 b, COLOR32 a)
+ {
+ return ((a & 0xff) << 24) | ((r & 0xff) << 16) | ((g & 0xff) << 8) | (b & 0xff);
+ }
+ COLOR32 getr(COLOR32 c)
+ {
+ return (c >> 16) & 0xff;
+ }
+ COLOR32 getg(COLOR32 c)
+ {
+ return (c >> 8) & 0xff;
+ }
+ COLOR32 getb(COLOR32 c)
+ {
+ return c & 0xff;
+ }
+ COLOR32 geta(COLOR32 c)
+ {
+ return (c >> 24) & 0xff;
+ }
+
+ HRGN buildOpaqueRgn();
+};
+
+#endif // __bitmap_funcs_h__