Of course!!! If i comment the first "if"
Code: Select all
// Read the image. Change "logo:" to the name of your input image file
status = MagickReadImage(magick_wand,"Asterisk_logo.jpg");
if (status == MagickFalse)
//ThrowWandException(magick_wand);
the second "if" is not a problem...
This is my console information.
Code: Select all
Magick: unable to read font `C:\Program Files\ImageMagick-6.5.8-Q16\config\@ghos
tscript_font_path@n019003l.pfb' @ annotate.c/RenderFreetype/1043.
Magick: `%s': %s "gswin32c.exe" -q -dQUIET -dPARANOIDSAFER -dBATCH -dNOPAUSE -dN
OPROMPT -dMaxBitmap=500000000 -dEPSCrop -dAlignToPixels=0 -dGridFitTT=0 "-sDEVIC
E=pnmraw" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r72x72" -g504x56 "-sOutputF
ile=C:/Users/ADMINI~1/AppData/Local/Temp/magick-_U9uGK1A" "-fC:/Users/ADMINI~1/A
ppData/Local/Temp/magick-gOHS4A_y" "-fC:/Users/ADMINI~1/AppData/Local/Temp/magic
k-Ax9ZI3Db" @ utility.c/SystemCommand/1964.
Magick: `%s': %s "gswin32c.exe" -q -dQUIET -dPARANOIDSAFER -dBATCH -dNOPAUSE -dN
OPROMPT -dMaxBitmap=500000000 -dEPSCrop -dAlignToPixels=0 -dGridFitTT=0 "-sDEVIC
E=pnmraw" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r72x72" -g504x56 "-sOutputF
ile=C:/Users/ADMINI~1/AppData/Local/Temp/magick-_U9uGK1A" "-fC:/Users/ADMINI~1/A
ppData/Local/Temp/magick-gOHS4A_y" "-fC:/Users/ADMINI~1/AppData/Local/Temp/magic
k-Ax9ZI3Db" -c showpage @ utility.c/SystemCommand/1964.
Magick: Postscript delegate failed `C:/Users/ADMINI~1/AppData/Local/Temp/magick-
SOUE92Vf': No such file or directory @ ps.c/ReadPSImage/765.
Magick: unable to read font `C:\Program Files\ImageMagick-6.5.8-Q16\config\@ghos
tscript_font_path@n019003l.pfb' @ annotate.c/RenderFreetype/1043.
Magick: `%s': %s "gswin32c.exe" -q -dQUIET -dPARANOIDSAFER -dBATCH -dNOPAUSE -dN
OPROMPT -dMaxBitmap=500000000 -dEPSCrop -dAlignToPixels=0 -dGridFitTT=0 "-sDEVIC
E=pnmraw" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r72x72" -g504x56 "-sOutputF
ile=C:/Users/ADMINI~1/AppData/Local/Temp/magick-FbSZKyMq" "-fC:/Users/ADMINI~1/A
ppData/Local/Temp/magick-Gnd2D6Yq" "-fC:/Users/ADMINI~1/AppData/Local/Temp/magic
k-5WTONKYu" @ utility.c/SystemCommand/1964.
Magick: `%s': %s "gswin32c.exe" -q -dQUIET -dPARANOIDSAFER -dBATCH -dNOPAUSE -dN
OPROMPT -dMaxBitmap=500000000 -dEPSCrop -dAlignToPixels=0 -dGridFitTT=0 "-sDEVIC
E=pnmraw" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r72x72" -g504x56 "-sOutputF
ile=C:/Users/ADMINI~1/AppData/Local/Temp/magick-FbSZKyMq" "-fC:/Users/ADMINI~1/A
ppData/Local/Temp/magick-Gnd2D6Yq" "-fC:/Users/ADMINI~1/AppData/Local/Temp/magic
k-5WTONKYu" -c showpage @ utility.c/SystemCommand/1964.
Magick: Postscript delegate failed `C:/Users/ADMINI~1/AppData/Local/Temp/magick-
JvN9N2gc': No such file or directory @ ps.c/ReadPSImage/765.
Magick: unable to read font `C:\Program Files\ImageMagick-6.5.8-Q16\config\@ghos
tscript_font_path@n019003l.pfb' @ annotate.c/RenderFreetype/1043.
Magick: `%s': %s "gswin32c.exe" -q -dQUIET -dPARANOIDSAFER -dBATCH -dNOPAUSE -dN
OPROMPT -dMaxBitmap=500000000 -dEPSCrop -dAlignToPixels=0 -dGridFitTT=0 "-sDEVIC
E=pnmraw" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r72x72" -g238x28 "-sOutputF
ile=C:/Users/ADMINI~1/AppData/Local/Temp/magick-2Miz9kAm" "-fC:/Users/ADMINI~1/A
ppData/Local/Temp/magick-HRx4bqQT" "-fC:/Users/ADMINI~1/AppData/Local/Temp/magic
k-QSalWIb8" @ utility.c/SystemCommand/1964.
Magick: `%s': %s "gswin32c.exe" -q -dQUIET -dPARANOIDSAFER -dBATCH -dNOPAUSE -dN
OPROMPT -dMaxBitmap=500000000 -dEPSCrop -dAlignToPixels=0 -dGridFitTT=0 "-sDEVIC
E=pnmraw" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r72x72" -g238x28 "-sOutputF
ile=C:/Users/ADMINI~1/AppData/Local/Temp/magick-2Miz9kAm" "-fC:/Users/ADMINI~1/A
ppData/Local/Temp/magick-HRx4bqQT" "-fC:/Users/ADMINI~1/AppData/Local/Temp/magic
k-QSalWIb8" -c showpage @ utility.c/SystemCommand/1964.
Magick: Postscript delegate failed `C:/Users/ADMINI~1/AppData/Local/Temp/magick-
tb1qMA8g': No such file or directory @ ps.c/ReadPSImage/765.
Magick: unable to read font `C:\Program Files\ImageMagick-6.5.8-Q16\config\@ghos
tscript_font_path@n019003l.pfb' @ annotate.c/RenderFreetype/1043.
Magick: `%s': %s "gswin32c.exe" -q -dQUIET -dPARANOIDSAFER -dBATCH -dNOPAUSE -dN
OPROMPT -dMaxBitmap=500000000 -dEPSCrop -dAlignToPixels=0 -dGridFitTT=0 "-sDEVIC
E=pnmraw" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r72x72" -g238x28 "-sOutputF
ile=C:/Users/ADMINI~1/AppData/Local/Temp/magick-FeB86aNr" "-fC:/Users/ADMINI~1/A
ppData/Local/Temp/magick-HmN7-OlD" "-fC:/Users/ADMINI~1/AppData/Local/Temp/magic
k-mRm8neL_" @ utility.c/SystemCommand/1964.
Magick: `%s': %s "gswin32c.exe" -q -dQUIET -dPARANOIDSAFER -dBATCH -dNOPAUSE -dN
OPROMPT -dMaxBitmap=500000000 -dEPSCrop -dAlignToPixels=0 -dGridFitTT=0 "-sDEVIC
E=pnmraw" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r72x72" -g238x28 "-sOutputF
ile=C:/Users/ADMINI~1/AppData/Local/Temp/magick-FeB86aNr" "-fC:/Users/ADMINI~1/A
ppData/Local/Temp/magick-HmN7-OlD" "-fC:/Users/ADMINI~1/AppData/Local/Temp/magic
k-mRm8neL_" -c showpage @ utility.c/SystemCommand/1964.
Magick: Postscript delegate failed `C:/Users/ADMINI~1/AppData/Local/Temp/magick-
bn82zEVq': No such file or directory @ ps.c/ReadPSImage/765.
Magick: unable to read font `C:\Program Files\ImageMagick-6.5.8-Q16\config\@ghos
tscript_font_path@n019003l.pfb' @ annotate.c/RenderFreetype/1043.
Magick: `%s': %s "gswin32c.exe" -q -dQUIET -dPARANOIDSAFER -dBATCH -dNOPAUSE -dN
OPROMPT -dMaxBitmap=500000000 -dEPSCrop -dAlignToPixels=0 -dGridFitTT=0 "-sDEVIC
E=pnmraw" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r72x72" -g160x40 "-sOutputF
ile=C:/Users/ADMINI~1/AppData/Local/Temp/magick-1GE9y75e" "-fC:/Users/ADMINI~1/A
ppData/Local/Temp/magick-1uwIiJnD" "-fC:/Users/ADMINI~1/AppData/Local/Temp/magic
k-eHRXP-r2" @ utility.c/SystemCommand/1964.
Magick: `%s': %s "gswin32c.exe" -q -dQUIET -dPARANOIDSAFER -dBATCH -dNOPAUSE -dN
OPROMPT -dMaxBitmap=500000000 -dEPSCrop -dAlignToPixels=0 -dGridFitTT=0 "-sDEVIC
E=pnmraw" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r72x72" -g160x40 "-sOutputF
ile=C:/Users/ADMINI~1/AppData/Local/Temp/magick-1GE9y75e" "-fC:/Users/ADMINI~1/A
ppData/Local/Temp/magick-1uwIiJnD" "-fC:/Users/ADMINI~1/AppData/Local/Temp/magic
k-eHRXP-r2" -c showpage @ utility.c/SystemCommand/1964.
Magick: Postscript delegate failed `C:/Users/ADMINI~1/AppData/Local/Temp/magick-
IImK02NO': No such file or directory @ ps.c/ReadPSImage/765.
Magick: unable to read font `C:\Program Files\ImageMagick-6.5.8-Q16\config\@ghos
tscript_font_path@n019003l.pfb' @ annotate.c/RenderFreetype/1043.
Magick: `%s': %s "gswin32c.exe" -q -dQUIET -dPARANOIDSAFER -dBATCH -dNOPAUSE -dN
OPROMPT -dMaxBitmap=500000000 -dEPSCrop -dAlignToPixels=0 -dGridFitTT=0 "-sDEVIC
E=pnmraw" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r72x72" -g160x40 "-sOutputF
ile=C:/Users/ADMINI~1/AppData/Local/Temp/magick-6I4Gg4AB" "-fC:/Users/ADMINI~1/A
ppData/Local/Temp/magick-cJgXFm_J" "-fC:/Users/ADMINI~1/AppData/Local/Temp/magic
k-B5qfTMHQ" @ utility.c/SystemCommand/1964.
Magick: `%s': %s "gswin32c.exe" -q -dQUIET -dPARANOIDSAFER -dBATCH -dNOPAUSE -dN
OPROMPT -dMaxBitmap=500000000 -dEPSCrop -dAlignToPixels=0 -dGridFitTT=0 "-sDEVIC
E=pnmraw" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r72x72" -g160x40 "-sOutputF
ile=C:/Users/ADMINI~1/AppData/Local/Temp/magick-6I4Gg4AB" "-fC:/Users/ADMINI~1/A
ppData/Local/Temp/magick-cJgXFm_J" "-fC:/Users/ADMINI~1/AppData/Local/Temp/magic
k-B5qfTMHQ" -c showpage @ utility.c/SystemCommand/1964.
Magick: Postscript delegate failed `C:/Users/ADMINI~1/AppData/Local/Temp/magick-
kvpX99xU': No such file or directory @ ps.c/ReadPSImage/765.
Magick: unable to read font `C:\Program Files\ImageMagick-6.5.8-Q16\config\@ghos
tscript_font_path@n019003l.pfb' @ annotate.c/RenderFreetype/1043.
Magick: `%s': %s "gswin32c.exe" -q -dQUIET -dPARANOIDSAFER -dBATCH -dNOPAUSE -dN
OPROMPT -dMaxBitmap=500000000 -dEPSCrop -dAlignToPixels=0 -dGridFitTT=0 "-sDEVIC
E=pnmraw" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r72x72" -g80x40 "-sOutputFi
le=C:/Users/ADMINI~1/AppData/Local/Temp/magick-M-CakD2-" "-fC:/Users/ADMINI~1/Ap
pData/Local/Temp/magick-jF9POr32" "-fC:/Users/ADMINI~1/AppData/Local/Temp/magick
-yzJKhSsR" @ utility.c/SystemCommand/1964.
Magick: `%s': %s "gswin32c.exe" -q -dQUIET -dPARANOIDSAFER -dBATCH -dNOPAUSE -dN
OPROMPT -dMaxBitmap=500000000 -dEPSCrop -dAlignToPixels=0 -dGridFitTT=0 "-sDEVIC
E=pnmraw" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r72x72" -g80x40 "-sOutputFi
le=C:/Users/ADMINI~1/AppData/Local/Temp/magick-M-CakD2-" "-fC:/Users/ADMINI~1/Ap
pData/Local/Temp/magick-jF9POr32" "-fC:/Users/ADMINI~1/AppData/Local/Temp/magick
-yzJKhSsR" -c showpage @ utility.c/SystemCommand/1964.
Magick: Postscript delegate failed `C:/Users/ADMINI~1/AppData/Local/Temp/magick-
53mMqE_u': No such file or directory @ ps.c/ReadPSImage/765.
Magick: unable to read font `C:\Program Files\ImageMagick-6.5.8-Q16\config\@ghos
tscript_font_path@n019003l.pfb' @ annotate.c/RenderFreetype/1043.
Magick: `%s': %s "gswin32c.exe" -q -dQUIET -dPARANOIDSAFER -dBATCH -dNOPAUSE -dN
OPROMPT -dMaxBitmap=500000000 -dEPSCrop -dAlignToPixels=0 -dGridFitTT=0 "-sDEVIC
E=pnmraw" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r72x72" -g80x40 "-sOutputFi
le=C:/Users/ADMINI~1/AppData/Local/Temp/magick-16335d4v" "-fC:/Users/ADMINI~1/Ap
pData/Local/Temp/magick-Ow4ChBgd" "-fC:/Users/ADMINI~1/AppData/Local/Temp/magick
-VbR_WdXV" @ utility.c/SystemCommand/1964.
Magick: `%s': %s "gswin32c.exe" -q -dQUIET -dPARANOIDSAFER -dBATCH -dNOPAUSE -dN
OPROMPT -dMaxBitmap=500000000 -dEPSCrop -dAlignToPixels=0 -dGridFitTT=0 "-sDEVIC
E=pnmraw" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r72x72" -g80x40 "-sOutputFi
le=C:/Users/ADMINI~1/AppData/Local/Temp/magick-16335d4v" "-fC:/Users/ADMINI~1/Ap
pData/Local/Temp/magick-Ow4ChBgd" "-fC:/Users/ADMINI~1/AppData/Local/Temp/magick
-VbR_WdXV" -c showpage @ utility.c/SystemCommand/1964.
Magick: Postscript delegate failed `C:/Users/ADMINI~1/AppData/Local/Temp/magick-
0pvbqvIb': No such file or directory @ ps.c/ReadPSImage/765.
Press a button to continue...
If you don't believe at my word, please try it...
Code: Select all
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <windows.h>
#include "wand/magick_wand.h"
using namespace std;
//#define ThrowWandException(wand) \
//{ \
// char \
// *description; \
// \
// ExceptionType \
// severity; \
// \
// description=MagickGetException(wand,&severity); \
// (void) fprintf(stderr,"%s %s %lu %s\n",GetMagickModule(),description); \
// description=(char *) MagickRelinquishMemory(description); \
// exit(-1); \
//}
void DrawText(char * nome_conferenza, char * data, char * nome_utente, char * ID_utente) {
MagickBooleanType status;
MagickWand *magick_wand = NULL;
DrawingWand *d_wand = NULL;
PixelWand *p_wand = NULL;
magick_wand = NewMagickWand();
d_wand = NewDrawingWand();
p_wand = NewPixelWand();
char * utente = "Utente";
char * ID = "ID";
// initialize MagickWand environment
MagickWandGenesis();
// Read the image. Change "logo:" to the name of your input image file
status = MagickReadImage(magick_wand,"Asterisk_logo.jpg");
//if (status == MagickFalse)
//ThrowWandException(magick_wand);
// Set up the font size and colour
DrawSetFont(d_wand,"Helvetica");
PixelSetColor(p_wand,"black");
DrawSetFillColor(d_wand,p_wand);
DrawSetFontSize(d_wand,28);
// Now draw the text
DrawAnnotation(d_wand,10,50,(const unsigned char *) nome_conferenza);
DrawSetFontSize(d_wand,14);
DrawAnnotation(d_wand,150,15,(const unsigned char *) data);
// same font - different colour and size
PixelSetColor(p_wand,"yellow");
DrawSetFillColor(d_wand,p_wand);
DrawSetFontSize(d_wand,20);
// Now draw the text
DrawAnnotation(d_wand,30,90,(const unsigned char *) utente);
// same font, size and colour
DrawAnnotation(d_wand,180,90,(const unsigned char *) ID);
// Draw the image on to the magick_wand
MagickDrawImage(magick_wand,d_wand);
// and write it
status = MagickWriteImage(magick_wand,"campione_text.jpg");
/* Clean up */
// if (status == MagickFalse)
// ThrowWandException(magick_wand);
if(magick_wand) magick_wand = DestroyMagickWand(magick_wand);
if(d_wand) d_wand = DestroyDrawingWand(d_wand);
if(p_wand) p_wand = DestroyPixelWand(p_wand);
// terminate the MagickWand environment
MagickWandTerminus();
}
void main() {
char * nome_conferenza = "Conferenza Prova";
char * data = "2/12/2009 17:03";
char * nome_utente = "cane";
char * ID_utente = "3";
DrawText(nome_conferenza, data, nome_utente, ID_utente);
system ("Pause");
}