1
0

svc_imgload.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. #ifndef _SVC_IMGLOAD_H
  2. #define _SVC_IMGLOAD_H
  3. #include <api/service/services.h>
  4. #include <bfc/platform/platform.h>
  5. #include <bfc/dispatch.h>
  6. class ifc_xmlreaderparams;
  7. class NOVTABLE svc_imageLoader : public Dispatchable
  8. {
  9. public:
  10. static FOURCC getServiceType() { return WaSvc::IMAGELOADER; }
  11. // assuming there is an extension of this type, is it yours?
  12. int isMine(const wchar_t *filename);
  13. // returns the mime type for this type of image
  14. const wchar_t *mimeType();
  15. // returns how many bytes needed to get image info
  16. int getHeaderSize();
  17. // test image data, return TRUE if you can load it
  18. int testData(const void *data, int datalen);
  19. // just gets the width and height from the data, if possible
  20. int getDimensions(const void *data, int datalen, int *w, int *h);
  21. // converts the data into pixels + premultiply, use api->sysFree to deallocate
  22. ARGB32 *loadImage(const void *data, int datalen, int *w, int *h, ifc_xmlreaderparams *params=NULL);\
  23. // converts the data into pixels, use api->sysFree to deallocate
  24. ARGB32 *loadImageData(const void *data, int datalen, int *w, int *h, ifc_xmlreaderparams *params=NULL);
  25. enum {
  26. ISMINE=50,
  27. MIMETYPE=75,
  28. GETHEADERSIZE=100,
  29. TESTDATA=200,
  30. GETDIMENSIONS=300,
  31. LOADIMAGE=400,
  32. LOADIMAGEDATA=500,
  33. };
  34. };
  35. inline int svc_imageLoader::isMine(const wchar_t *filename) {
  36. return _call(ISMINE, 0, filename);
  37. }
  38. inline const wchar_t *svc_imageLoader::mimeType() {
  39. return _call(MIMETYPE, L"");
  40. }
  41. inline int svc_imageLoader::getHeaderSize() {
  42. return _call(GETHEADERSIZE, -1);
  43. }
  44. inline int svc_imageLoader::testData(const void *data, int datalen) {
  45. return _call(TESTDATA, 0, data, datalen);
  46. }
  47. inline int svc_imageLoader::getDimensions(const void *data, int datalen, int *w, int *h) {
  48. return _call(GETDIMENSIONS, 0, data, datalen, w, h);
  49. }
  50. inline ARGB32 *svc_imageLoader::loadImage(const void *data, int datalen, int *w, int *h, ifc_xmlreaderparams *params) {
  51. return _call(LOADIMAGE, (ARGB32*)0, data, datalen, w, h, params);
  52. }
  53. inline ARGB32 *svc_imageLoader::loadImageData(const void *data, int datalen, int *w, int *h, ifc_xmlreaderparams *params) {
  54. return _call(LOADIMAGEDATA, (ARGB32*)0, data, datalen, w, h, params);
  55. }
  56. // derive from this one
  57. class NOVTABLE svc_imageLoaderI : public svc_imageLoader
  58. {
  59. public:
  60. virtual int isMine(const wchar_t *filename)=0;
  61. virtual const wchar_t *mimeType(void)=0;
  62. // return the header size needed to get w/h and determine if it can be loaded
  63. virtual int getHeaderSize() { return -1; }//don't know
  64. // test image data, return TRUE if you can load it
  65. virtual int testData(const void *data, int datalen)=0;
  66. // just gets the width and height from the data, if possible
  67. virtual int getDimensions(const void *data, int datalen, int *w, int *h) { return 0; }
  68. // converts the data into pixels + premultiply, use api->sysFree to deallocate
  69. virtual ARGB32 *loadImage(const void *data, int datalen, int *w, int *h, ifc_xmlreaderparams *params=NULL)=0;
  70. #if 0
  71. // converts the data into pixels, use api->sysFree to deallocate
  72. virtual ARGB32 *loadImageData(const void *data, int datalen, int *w, int *h, ifc_xmlreaderparams *params=NULL)=0;
  73. #endif
  74. protected:
  75. RECVS_DISPATCH;
  76. };
  77. #endif