Je me suis dit que la meilleure solution pour les formats classiques tels que PNG, JPEG et GIF serait d'utiliser MagickWand, l'API C d'ImageMagick, et m'occuper moi-même du SVG et du FIG. Je pensais m'en servir également pour calculer les dimensions des textes. En gros, tout ce que je veux faire, c'est dessiner des rectangles, du texte (centré, aligné à droite, en haut, en bas, ... ), mais avec le même rendu dans tous les formats.
Manque de chance, la doc est franchement pas terrible, voire carrément mauvaise :/
Du coup, je n'arrive pas à faire un simple rectangle en PNG

J'ai essayé pas mal de trucs, dans ce genre :
file->magick_wand = NewMagickWand(); file->drawing_wand = NewDrawingWand(); MagickNewImage(file->magick_wand, 640, 480, color->pixel_wand); MagickSetImageBackgroundColor(file->magick_wand, color->pixel_wand); DrawSetViewbox(file->drawing_wand, 0, 0, 640, 480); DrawSetFillColor(file->drawing_wand, color->pixel_wand); DrawSetFillOpacity(file->drawing_wand, 1.0); DrawSetStrokeColor(file->drawing_wand, color->pixel_wand); DrawSetStrokeWidth(file->drawing_wand, 1.0); DrawSetFillColor(file->drawing_wand, color->pixel_wand); DrawRectangle(file->drawing_wand, 10., 20., 50., 80.); MagickDrawImage(file->magick_wand, file->drawing_wand); MagickSetImageFormat(file->magick_wand, "PNG"); MagickWriteImageFile(file->magick_wand, file->png); fclose(file->png);
Mais j'ai toujours une image complètement noire
