bitmap.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. //NONPORTABLE
  2. #ifndef _BITMAP_H
  3. #define _BITMAP_H
  4. //#include <wasabicfg.h>
  5. //#include <bfc/common.h>
  6. #include <bfc/string/string.h>
  7. #include <bfc/string/StringW.h>
  8. class ifc_canvas; // see canvas.h
  9. //#define NO_MMX
  10. class api_region;
  11. // a skinnable bitmap
  12. class SkinBitmap
  13. {
  14. public:
  15. #ifndef _NOSTUDIO
  16. #ifdef WASABI_COMPILE_IMGLDR
  17. #ifdef _WIN32
  18. SkinBitmap(HINSTANCE hInst, int _id, const wchar_t *colorgroup = NULL); //NONPORTABLE
  19. #endif
  20. SkinBitmap(const wchar_t *elementname, int cached = 1);
  21. #endif
  22. #endif
  23. // SkinBitmap(SkinBitmap *source, int w, int h);
  24. SkinBitmap(int w, int h, ARGB32 bgcolor = RGBA(255,255,255,255)); //untested --BU
  25. #ifdef _WIN32
  26. SkinBitmap(HBITMAP bitmap);
  27. SkinBitmap(HBITMAP bitmap, HDC dc, int has_alpha = 0, void *bits = NULL);
  28. #endif
  29. SkinBitmap(ARGB32 *bits, int w, int h); // added by benski, use if you have raw image bits
  30. ~SkinBitmap();
  31. int getWidth() const { return subimage_w == -1 ? fullimage_w : subimage_w; };
  32. int getHeight() const { return subimage_h == -1 ? fullimage_h : subimage_h; };
  33. int getFullWidth() const { return fullimage_w; };
  34. int getFullHeight() const { return fullimage_h; };
  35. int getX() const { return x_offset == -1 ? 0 : x_offset; };
  36. int getY() const { return y_offset == -1 ? 0 : y_offset; };
  37. int getBpp() const { return 32; };
  38. int getAlpha() const { return has_alpha; };
  39. void setHasAlpha(int ha);
  40. virtual void *getBits();
  41. int isInvalid();
  42. const wchar_t *getBitmapName();
  43. void blit(ifc_canvas *canvas, int x, int y);
  44. void blitAlpha(ifc_canvas *canvas, int x, int y, int alpha = 255);
  45. // blits a chunk of source into dest rect
  46. void blitToRect(ifc_canvas *canvas, RECT *src, RECT *dst, int alpha = 255);
  47. void blitTile(ifc_canvas *canvas, RECT *dest, int xoffs = 0, int yoffs = 0, int alpha = 255);
  48. void blitRectToTile(ifc_canvas *canvas, RECT *dest, RECT *src, int xoffs = 0, int yoffs = 0, int alpha = 255);
  49. void stretch(ifc_canvas *canvas, int x, int y, int w, int h);
  50. void stretchToRect(ifc_canvas *canvas, RECT *r);
  51. void stretchRectToRect(ifc_canvas *canvas, RECT *src, RECT *dst);
  52. void stretchToRectAlpha(ifc_canvas *canvas, RECT *r, int alpha = 255);
  53. void stretchToRectAlpha(ifc_canvas *canvas, RECT *src, RECT *dst, int alpha = 255);
  54. ARGB32 getPixel(int x, int y);
  55. private:
  56. #ifdef _WIN32
  57. void bmpToBits(HBITMAP hbmp, HDC defaultDC = NULL);
  58. #endif
  59. int has_alpha;
  60. int x_offset, y_offset, subimage_w, subimage_h, fullimage_w, fullimage_h;
  61. ARGB32 *bits;
  62. int ownbits;
  63. int last_failed;
  64. StringW bitmapname;
  65. int fromskin;
  66. };
  67. #endif