29# include <sys/types.h>
30# include <magick/api.h>
34#include "pixmapFrame.h"
35#include "fileheader.h"
40PixmapFrame::PixmapFrame()
47PixmapFrame::~PixmapFrame()
49 kdDebug(30522) << "Destruction of a pixmap" << endl;
51void PixmapFrame::setKeepAspectRatio( const TQString ratio)
54 _keepAspectRatio = true;
56 _keepAspectRatio = false;
72 kdDebug(30522) << "FRAME ANALYSE (Pixmap)" << endl;
75 for( int index = 0; index < getNbChild(balise); index++)
77 if(getChildName(balise, index).compare( "FRAME")== 0)
79 analyseParamFrame(balise);
81 else if(getChildName(balise, index).compare( "PICTURE")== 0)
83 getPixmap(getChild(balise, "PICTURE"));
87 kdDebug(30522) << "END OF A FRAME" << endl;
96void PixmapFrame::getPixmap( const TQDomNode balise_initiale)
98 kdDebug(30522) << "PIXMAP" << endl;
99 setKeepAspectRatio(getAttr(balise_initiale, "keepAspectRatio"));
100 TQDomNode balise = getChild(balise_initiale, "KEY");
101 setKey(getAttr(balise, "filename"));
102 FileHeader::instance()->useGraphics();
103 TQString file = getKey();
105 int posExt = file.findRev( '.');
106 file.truncate(posExt);
108 file = file.section( '/', -1);
109 setFilenamePS(file + ".eps");
110 kdDebug(30522) << "PS : " << getFilenamePS() << endl;
111 kdDebug(30522) << "END PIXMAP" << endl;
117void PixmapFrame::analyseParamFrame( const TQDomNode balise)
121 _left = getAttr(balise, "left").toInt();
122 _top = getAttr(balise, "top").toInt();
123 _right = getAttr(balise, "right").toInt();
124 _bottom = getAttr(balise, "bottom").toInt();
126 setAroundGap(getAttr(balise, "runaroundGap").toInt());
127 setAutoCreate(getAttr(balise, "autoCreateNewFrame").toInt());
128 setNewFrame(getAttr(balise, "newFrameBehaviour").toInt());
129 setSheetSide(getAttr(balise, "sheetside").toInt());
138 kdDebug(30522) << "CONVERT PICTURE IN EPS" << endl;
139 ExceptionInfo exception;
149 InitializeMagick(NULL);
150 GetExceptionInfo(&exception);
151 image_info = CloneImageInfo((ImageInfo *) NULL);
153 TQString filename = "file:///" + getRoot()-> extractData(getKey());
154 strncpy(image_info->filename, filename.latin1(), filename.length());
155 image = ReadImage(image_info, &exception);
156 if (image == (Image *) NULL)
157 MagickError(exception.severity, exception.reason, exception.description);
165 if( Config::instance()->getPicturesDir().isEmpty() ||
166 Config::instance()->getPicturesDir() == NULL)
169 dir.truncate(getFilename().findRev( '/'));
172 dir = Config::instance()->getPicturesDir();
173 kdDebug(30522) << "file " << getFilename() << endl;
174 kdDebug(30522) << "path " << dir << endl;
175 (void) strcpy(image->filename, (dir + "/" + getFilenamePS()).latin1());
176 WriteImage(image_info, image);
179 DestroyImageInfo(image_info);
180 DestroyExceptionInfo(&exception);
182 kdDebug(30522) << "CONVERTION DONE" << endl;
191void PixmapFrame::generate(TQTextStream &out)
193 if(Config::instance()->convertPictures())
196 Config::instance()->writeIndent(out);
197 out << "\\includegraphics{" << getFilenamePS()<< "}" << endl;
TQString extractData(TQString key) Save the file in a temp file.
virtual void analyse(const TQDomNode) Helpfull functions.
void convert() Convert a pixmap file in eps file.
void setRunAround(const int a) Modifiers.
void analyse(const TQDomNode) Helpfull functions.
|