File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed
Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -975,6 +975,7 @@ EXCLUDE_SYMLINKS = NO
975975
976976EXCLUDE_PATTERNS = */internal/* \
977977 */src/blocks/* \
978+ */src/imageformats/* \
978979 *_p.cpp \
979980 *_p.h
980981
Original file line number Diff line number Diff line change 1+ \page imageFormats Image formats
2+
3+ To work with costumes, libscratchcpp has to read image files from Scratch projects.
4+ No formats are currently supported, but that will change soon.
5+
6+ # Implementing a custom image format
7+ To implement a custom image format that libscratchcpp doesn't support,
8+ subclass \link libscratchcpp::IImageFormat IImageFormat \endlink
9+ and override all of the methods.
10+
11+ Then subclass \link libscratchcpp::IImageFormatFactory IImageFormatFactory \endlink
12+ and override \link libscratchcpp::IImageFormatFactory::createInstance() createInstance() \endlink.
13+
14+ It's recommended to use the libscratchcpp namespace like this in your classes:
15+ ``` cpp
16+ using namespace libscratchcpp ;
17+ ```
18+
19+ Here's an example of the ` createInstance() ` method:
20+ ``` cpp
21+ std::shared_ptr<IImageFormat> TiffImageFormatFactory::createInstance () {
22+ return std::make_shared<TiffImageFormat>();
23+ }
24+ ```
25+
26+ # Registering the image format
27+ To register the image format, you need to register the factory class.
28+ It will be used by classes such as \link libscratchcpp::Costume Costume \endlink
29+ internally to instantiate your image format.
30+
31+ ``` cpp
32+ libscratchcpp::ScratchConfiguration::registerImageFormat ("tiff", std::make_shared<TiffImageFormatFactory >());
33+ ```
You can’t perform that action at this time.
0 commit comments