imgldr.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #ifndef __IMGLDR_H
  2. #define __IMGLDR_H
  3. //CUT
  4. #define FT_UNKNOWN 0
  5. #define FT_BMP 1
  6. #define FT_JPEG 5
  7. #define FT_PNG 6
  8. #include <bfc/ptrlist.h>
  9. #include <tataki/bitmap/bitmap.h>
  10. #ifdef WASABI_COMPILE_XMLPARSER
  11. #include <api/xml/xmlreader.h>
  12. #include <api/xml/xmlparamsi.h>
  13. #else
  14. class XmlReaderParamsI;
  15. #endif
  16. #ifdef WASABI_COMPILE_SKIN
  17. #include <api/skin/skin.h>
  18. #include <api/skin/skinfilter.h>
  19. #endif
  20. #include <bfc/string/StringW.h>
  21. typedef struct {
  22. ARGB32 *bitmapbits;
  23. StringW filename;
  24. int usageCount;
  25. bool has_alpha;
  26. int width;
  27. int height;
  28. StringW includepath;
  29. // String rootpath;
  30. XmlReaderParamsI params;
  31. StringW original_element_id;
  32. StringW fullpathfilename;
  33. } skinCacheEntry;
  34. typedef unsigned long ARGB32;
  35. #ifdef WASABI_COMPILE_SKIN
  36. class skinCacheComp
  37. {
  38. public:
  39. static int compareItem(void *p1, void *p2) {
  40. return wcscmp(((skinCacheEntry *)p1)->fullpathfilename, ((skinCacheEntry *)p2)->fullpathfilename);
  41. }
  42. static int compareAttrib(const wchar_t *attrib, void *item) {
  43. return wcscmp(attrib, ((skinCacheEntry *)item)->fullpathfilename);
  44. }
  45. };
  46. #endif //WASABI_COMPILE_SKIN
  47. class imageLoader
  48. {
  49. public:
  50. static ARGB32 *makeBmp(const wchar_t *filename, const wchar_t *path, int *has_alpha, int *w, int *h, ifc_xmlreaderparams *params, bool addmem, int *force_nocache);
  51. #ifdef _WIN32
  52. static ARGB32 *makeBmp(OSMODULEHANDLE hInst, int id, int *has_alpha, int *w, int *h, const wchar_t *forcegroup=NULL);
  53. #endif
  54. static int getFileType(uint8_t *pData);
  55. static StringW getWallpaper();
  56. static void release(ARGB32 *bitmapbits);
  57. #ifdef WASABI_COMPILE_SKIN
  58. static ARGB32 *requestSkinBitmap(const wchar_t *id, int *has_alpha, int *x, int *y, int *subw, int *subh, int *w, int *h, int cached=1);
  59. static void releaseSkinBitmap(ARGB32 *bmpbits);
  60. static void applySkinFilters();
  61. static void applySkinFilters(skinCacheEntry *entry);
  62. static ARGB32 filterSkinColor(ARGB32 color, const wchar_t *elementid, const wchar_t *groupname);
  63. static int layerEqual(const wchar_t *id1, const wchar_t *id2);
  64. #endif //WASABI_COMPILE_SKIN
  65. static int getMemUsage() { return totalMemUsage; }
  66. static int getNumCached() { return skinCacheList.getNumItems(); }
  67. private:
  68. #ifdef WASABI_COMPILE_SKIN
  69. //static int paramsMatch(ifc_xmlreaderparams *a, ifc_xmlreaderparams *b);
  70. static PtrListInsertMultiSorted<skinCacheEntry,skinCacheComp> skinCacheList;
  71. #endif //WASABI_COMPILE_SKIN
  72. static void optimizeHasAlpha(ARGB32 *bits, int len, int *has_alpha);
  73. static void addMemUsage(const wchar_t *filename, int size);
  74. static void subMemUsage(int size);
  75. static int totalMemUsage;
  76. };
  77. #endif