@@ -245,23 +245,60 @@ int QgsSymbol::pointSize() const
245
245
246
246
QImage QgsSymbol::getLineSymbolAsImage ()
247
247
{
248
- QImage img (15 , 15 , QImage::Format_ARGB32_Premultiplied);
249
- img.fill (QColor (255 ,255 ,255 ,0 ).rgba ());
250
- QPainter p (&img);
251
- p.setPen (mPen );
252
- p.drawLine (0 , 0 , 15 , 15 );
253
- return img; // this is ok because of qts sharing mechanism
248
+ // Note by Tim: dont use premultiplied - it causes
249
+ // artifacts on the output icon!
250
+ QImage img (15 , 15 ,QImage::Format_ARGB32 );// QImage::Format_ARGB32_Premultiplied);
251
+ img.fill (QColor (255 ,255 ,255 ,255 ).rgba ());
252
+ QPainter p (&img);
253
+ p.setRenderHints (QPainter::Antialiasing);
254
+ p.setPen (mPen );
255
+
256
+
257
+ QPainterPath myPath;
258
+ myPath.moveTo (0 , 0 );
259
+ myPath.cubicTo (15 , 0 , 5 , 7 , 15 , 15 );
260
+ p.drawPath (myPath);
261
+ // p.drawLine(0, 0, 15, 15);
262
+ return img; // this is ok because of qts sharing mechanism
254
263
}
255
264
256
265
QImage QgsSymbol::getPolygonSymbolAsImage ()
257
266
{
258
- QImage img (15 , 15 , QImage::Format_ARGB32_Premultiplied);
259
- img.fill (QColor (255 ,255 ,255 ,0 ).rgba ());
260
- QPainter p (&img);
261
- p.setPen (mPen );
262
- p.setBrush (mBrush );
263
- p.drawRect (0 , 0 , 15 , 15 );
264
- return img; // this is ok because of qts sharing mechanism
267
+ // Note by Tim: dont use premultiplied - it causes
268
+ // artifacts on the output icon!
269
+ QImage img (15 , 15 ,QImage::Format_ARGB32); // , QImage::Format_ARGB32_Premultiplied);
270
+ img.fill (QColor (255 ,255 ,255 ,255 ).rgba ());
271
+ QPainter p (&img);
272
+ p.setRenderHints (QPainter::Antialiasing);
273
+ p.setPen (mPen );
274
+ p.setBrush (mBrush );
275
+ QPolygon myPolygon;
276
+ // leave a little white space around so
277
+ // dont draw at 0,0,15,15
278
+ myPolygon << QPoint (2 , 2 )
279
+ << QPoint (1 , 5 )
280
+ << QPoint (1 , 10 )
281
+ << QPoint (2 , 12 )
282
+ << QPoint (5 , 13 )
283
+ << QPoint (6 , 13 )
284
+ << QPoint (8 , 12 )
285
+ << QPoint (8 , 12 )
286
+ << QPoint (10 , 12 )
287
+ << QPoint (12 , 13 )
288
+ << QPoint (13 , 11 )
289
+ << QPoint (12 , 8 )
290
+ << QPoint (11 , 6 )
291
+ << QPoint (12 , 5 )
292
+ << QPoint (13 , 2 )
293
+ << QPoint (11 , 1 )
294
+ << QPoint (10 , 1 )
295
+ << QPoint (8 , 2 )
296
+ << QPoint (6 , 4 )
297
+ << QPoint (4 , 2 )
298
+ ;
299
+ p.drawPolygon (myPolygon);
300
+ // p.drawRect(1, 1, 14, 14);
301
+ return img; // this is ok because of qts sharing mechanism
265
302
}
266
303
267
304
QImage QgsSymbol::getCachedPointSymbolAsImage ( double widthScale,
0 commit comments