use an image (PNG, JPG, BMP …) as marker symbol.
Width and height of the image can be set independently
QgsRasterMarkerSymbolLayer
类是图片标记层(Raster Image marker layer),类图如下QgsRasterMarkerSymbolLayer (const QString &path=QString(), double size=DEFAULT_SVGMARKER_SIZE, double angle=DEFAULT_SVGMARKER_ANGLE, Qgis::ScaleMethod scaleMethod=DEFAULT_SCALE_METHOD)
QgsFeatureRenderer * layerRenderer= layer->renderer();
QgsSingleSymbolRenderer *singleRenderer = QgsSingleSymbolRenderer::convertFromRenderer(layerRenderer);
//构造Rasger标记层(Raster Marker SymbolLayer)方法一
//作为示例,用到了imageFile和size两个参数,其他参数使用类似
QString imageFile = QStringLiteral("resources/cock.jpg");
auto markerSymbolLayer = new QgsRasterMarkerSymbolLayer(imageFile,8.0);
//QgsMarkerSymbol构造函数中需要传入QgsSymbolLayerList
//多个Symbol Layer构成一个Symbol
QgsSymbolLayerList layerList;
layerList << markerSymbolLayer;
auto markerSymbol = new QgsMarkerSymbol(layerList);
singleRenderer->setSymbol(markerSymbol);
layer->setRenderer(singleRenderer);
Animated marker symbol layer class.
The QgsAnimatedMarkerSymbolLayer class renders frames from an animated raster image source (e.g. an animated GIF) during temporal animations or map exports.
QgsAnimatedMarkerSymbolLayer
类是动画标记图层(Animated marker layer),类图如下QgsFeatureRenderer * layerRenderer= layer->renderer();
QgsSingleSymbolRenderer *singleRenderer = QgsSingleSymbolRenderer::convertFromRenderer(layerRenderer);
//构造Animated标记层(Animated Marker SymbolLayer)方法一
//作为示例,用到了path和size两个参数,其他参数使用类似
QString path = QStringLiteral("resources/fire.gif");
auto markerSymbolLayer = new QgsAnimatedMarkerSymbolLayer(path,8.0);
//QgsMarkerSymbol构造函数中需要传入QgsSymbolLayerList
//多个Symbol Layer构成一个Symbol
QgsSymbolLayerList layerList;
layerList << markerSymbolLayer;
auto markerSymbol = new QgsMarkerSymbol(layerList);
singleRenderer->setSymbol(markerSymbol);
layer->setRenderer(singleRenderer);