Donner 0.5.1
Embeddable browser-grade SVG2 engine
Loading...
Searching...
No Matches
donner::svg::ImageLoader Class Reference

Utility class for loading images from a URI. More...

#include "donner/svg/resources/ImageLoader.h"

Public Types

using Result = std::variant<ImageResource, SvgImageContent, UrlLoaderError>
 Result type returned by fromUri. Contains either decoded raster pixels, raw SVG content, or an error.

Public Member Functions

 ImageLoader (ResourceLoaderInterface &resourceLoader)
 Create a new image loader that uses the given resource loader to fetch external resources.
 ~ImageLoader ()=default
 Destructor.
 ImageLoader (const ImageLoader &)=delete
 ImageLoader (ImageLoader &&)=delete
ImageLoaderoperator= (const ImageLoader &)=delete
ImageLoaderoperator= (ImageLoader &&)=delete
Result fromUri (std::string_view uri)
 Read an image from a URI, which can be a file path, a URL, or a data URL (e.g.

Detailed Description

Utility class for loading images from a URI.

Supports both raster images (PNG, JPEG, GIF) and SVG images. Raster images are decoded into pixel data (ImageResource), while SVG images are returned as raw bytes (SvgImageContent) for parsing by the caller.

Constructor & Destructor Documentation

◆ ImageLoader()

donner::svg::ImageLoader::ImageLoader ( ResourceLoaderInterface & resourceLoader)
inlineexplicit

Create a new image loader that uses the given resource loader to fetch external resources.

Parameters
resourceLoaderResource loader to use for fetching external resources.

Member Function Documentation

◆ fromUri()

Result donner::svg::ImageLoader::fromUri ( std::string_view uri)

Read an image from a URI, which can be a file path, a URL, or a data URL (e.g.

"data:image/png;base64,...").

If the resource is an SVG image (image/svg+xml), returns SvgImageContent with raw bytes. Otherwise, decodes the image into RGBA pixel data and returns ImageResource.

Parameters
uriURI of the image, or data URL containing a base64 embedded image.
Returns
A variant containing the loaded ImageResource, SvgImageContent, or a UrlLoaderError.

The documentation for this class was generated from the following file: