Mercurial > foo_out_sdl
comparison foosdk/sdk/foobar2000/SDK/imageLoaderLite.h @ 1:20d02a178406 default tip
*: check in everything else
yay
| author | Paper <paper@tflc.us> |
|---|---|
| date | Mon, 05 Jan 2026 02:15:46 -0500 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 0:e9bb126753e7 | 1:20d02a178406 |
|---|---|
| 1 #pragma once | |
| 2 | |
| 3 #include "commonObjects.h" | |
| 4 | |
| 5 #ifdef _WIN32 | |
| 6 namespace Gdiplus { | |
| 7 class Image; | |
| 8 } | |
| 9 #endif | |
| 10 namespace fb2k { | |
| 11 #ifdef _WIN32 | |
| 12 typedef Gdiplus::Image * nativeImage_t; | |
| 13 #else | |
| 14 typedef void * nativeImage_t; | |
| 15 #endif | |
| 16 | |
| 17 struct imageInfo_t { | |
| 18 uint32_t width, height, bitDepth; | |
| 19 bool haveAlpha; | |
| 20 const char * formatName; // MAY BE NULL IF UNKNOWN | |
| 21 const char * mime; // MAY BE NULL IF UNKNOWN | |
| 22 }; | |
| 23 | |
| 24 //! \since 1.6 | |
| 25 //! Interface to common image loader routines that turn a bytestream into a image that can be drawn in a window. \n | |
| 26 //! Windows: Using imageLoaderLite methods initializes gdiplus if necessary, leaving gdiplus initialized for the rest of app lifetime. \n | |
| 27 //! If your component supports running on foobar2000 older than 1.6, use tryGet() to gracefully fall back to your own image loader: \n | |
| 28 //! auto api = fb2k::imageLoaderLite::tryGet(); if (api.is_valid()) { do stuff with api; } else { use fallbacks; } | |
| 29 class imageLoaderLite : public service_base { | |
| 30 FB2K_MAKE_SERVICE_COREAPI(imageLoaderLite); | |
| 31 public: | |
| 32 //! Throws excpetions on failure, returns valid image otherwise.\n | |
| 33 //! Caller takes ownership of the returned object. \n | |
| 34 //! @param outInfo Optional struct to receive information about the loaded image. | |
| 35 virtual nativeImage_t load(const void * data, size_t bytes, imageInfo_t * outInfo = nullptr, abort_callback & aborter = fb2k::noAbort) = 0; | |
| 36 | |
| 37 //! Parses the image data just enough to hand over basic info about what's inside. \n | |
| 38 //! Much faster than load(). \n | |
| 39 //! Throws exceptions on failure. \n | |
| 40 //! Supports all formats recognized by load(). | |
| 41 virtual imageInfo_t getInfo(const void * data, size_t bytes, abort_callback & aborter = fb2k::noAbort) = 0; | |
| 42 | |
| 43 //! Helper - made virtual so it can be possibly specialized in the future | |
| 44 virtual nativeImage_t load(album_art_data_ptr data, imageInfo_t * outInfo = nullptr, abort_callback & aborter = fb2k::noAbort) { | |
| 45 return load(data->get_ptr(), data->get_size(), outInfo, aborter); | |
| 46 } | |
| 47 //! Helper - made virtual so it can be possibly specialized in the future | |
| 48 virtual imageInfo_t getInfo(album_art_data_ptr data, abort_callback & aborter = fb2k::noAbort) { | |
| 49 return getInfo(data->get_ptr(), data->get_size(), aborter); | |
| 50 } | |
| 51 }; | |
| 52 } | |
| 53 | |
| 54 #define FB2K_GETOPENFILENAME_PICTUREFILES "Picture files|*.jpg;*.jpeg;*.png;*.bmp;*.gif;*.webp" | |
| 55 #define FB2K_GETOPENFILENAME_PICTUREFILES_ALL FB2K_GETOPENFILENAME_PICTUREFILES "|All files|*.*" |
