25#include <magick/api.h>
28#include <tqfileinfo.h>
31#include <tdeversion.h>
33#include <tdeapplication.h>
36#include <tdeio/netaccess.h>
41#include "kis_global.h"
45#include "kis_undo_adapter.h"
46#include "kis_image_magick_converter.h"
47#include "kis_meta_registry.h"
48#include "kis_colorspace_factory_registry.h"
49#include "kis_iterators_pixel.h"
50#include "kis_colorspace.h"
51#include "kis_profile.h"
52#include "kis_annotation.h"
53#include "kis_paint_layer.h"
54#include "kis_group_layer.h"
55#include "kis_paint_device.h"
57#include "../../../config.h"
61 const TQ_UINT8 PIXEL_BLUE = 0;
62 const TQ_UINT8 PIXEL_GREEN = 1;
63 const TQ_UINT8 PIXEL_RED = 2;
64 const TQ_UINT8 PIXEL_ALPHA = 3;
66 static const TQ_UINT8 PIXEL_CYAN = 0;
67 static const TQ_UINT8 PIXEL_MAGENTA = 1;
68 static const TQ_UINT8 PIXEL_YELLOW = 2;
69 static const TQ_UINT8 PIXEL_BLACK = 3;
70 static const TQ_UINT8 PIXEL_CMYK_ALPHA = 4;
72 static const TQ_UINT8 PIXEL_GRAY = 0;
73 static const TQ_UINT8 PIXEL_GRAY_ALPHA = 1;
79 TQString getColorSpaceName(ColorspaceType type,
unsigned long imageDepth = 8)
82 if (type == GRAYColorspace) {
85 else if ( imageDepth == 16 )
88 else if (type == CMYKColorspace) {
91 else if ( imageDepth == 16 ) {
95 else if (type == LABColorspace) {
96 kdDebug(41008) <<
"Lab!\n";
99 else if (type == RGBColorspace || type == sRGBColorspace || type == TransparentColorspace) {
102 else if (imageDepth == 16)
109 ColorspaceType getColorTypeforColorSpace( KisColorSpace * cs )
111 if ( cs->id() == KisID(
"GRAYA") || cs->id() == KisID(
"GRAYA16") )
return GRAYColorspace;
112 if ( cs->id() == KisID(
"RGBA") || cs->id() == KisID(
"RGBA16") )
return RGBColorspace;
113 if ( cs->id() == KisID(
"CMYK") || cs->id() == KisID(
"CMYK16") )
return CMYKColorspace;
114 if ( cs->id() == KisID(
"LABA") )
return LABColorspace;
116 kdDebug(41008) <<
"Cannot export images in " + cs->id().name() +
" yet.\n";
117 return RGBColorspace;
121 KisProfile * getProfileForProfileInfo(
const Image * image)
125 const unsigned char * profiledata = GetImageProfile(image,
"ICM", &length);
126 if( profiledata == NULL )
129 rawdata.resize(length);
130 memcpy(rawdata.data(), profiledata, length);
132 KisProfile* p =
new KisProfile(rawdata);
138 if (image->profiles == NULL)
142 const StringInfo *profile;
146 ResetImageProfileIterator(image);
147 for (name = GetNextImageProfile(image); name != (
char *) NULL; )
149 profile = GetImageProfile(image, name);
150 if (profile == (StringInfo *) NULL)
154 if (TQString::compare(name,
"icc") == 0) {
156 rawdata.resize(profile->length);
157 memcpy(rawdata.data(), profile->datum, profile->length);
159 p =
new KisProfile(rawdata);
163 name = GetNextImageProfile(image);
169 void setAnnotationsForImage(
const Image * src, KisImageSP image)
173 const unsigned char * profiledata = GetImageProfile(src,
"IPTC", &length);
174 if( profiledata != NULL )
177 rawdata.resize(length);
178 memcpy(rawdata.data(), profiledata, length);
180 KisAnnotation* annotation =
new KisAnnotation(TQString(
"IPTC"),
"", rawdata);
181 TQ_CHECK_PTR(annotation);
183 image -> addAnnotation(annotation);
187 for(
int i = 0; i < src->generic_profiles; i++)
190 rawdata.resize(length);
191 memcpy(rawdata.data(), src->generic_profile[i].info, src->generic_profile[i].length);
193 KisAnnotation* annotation =
new KisAnnotation(TQString(src->generic_profile[i].name),
"", rawdata);
194 TQ_CHECK_PTR(annotation);
196 image -> addAnnotation(annotation);
200 const ImageAttribute* imgAttr = GetImageAttribute(src, NULL);
204 int len = strlen(imgAttr -> value) + 1;
206 memcpy(rawdata.data(), imgAttr -> value, len);
208 KisAnnotation* annotation =
new KisAnnotation( TQString(
"chalk_attribute:%1").arg(TQString(imgAttr -> key)),
"", rawdata );
209 TQ_CHECK_PTR(annotation);
211 image -> addAnnotation(annotation);
213 imgAttr = imgAttr->next;
217 if (src->profiles == NULL)
220 const char *name = 0;
221 const StringInfo *profile;
222 KisAnnotation* annotation = 0;
225 ResetImageProfileIterator(src);
226 while((name = GetNextImageProfile(src))) {
227 profile = GetImageProfile(src, name);
228 if (profile == (StringInfo *) NULL)
232 if (TQString::compare(name,
"icc") == 0)
236 rawdata.resize(profile->length);
237 memcpy(rawdata.data(), profile->datum, profile->length);
239 annotation =
new KisAnnotation(TQString(name),
"", rawdata);
240 TQ_CHECK_PTR(annotation);
242 image -> addAnnotation(annotation);
250#if MagickLibVersion >= 0x621
251 const ImageAttribute * attr;
252 ResetImageAttributeIterator(src);
253 while ( (attr = GetNextImageAttribute(src)) ) {
255 ImageAttribute * attr = src -> attributes;
259 int len = strlen(attr -> value) + 1;
261 memcpy(rawdata.data(), attr -> value, len);
263 annotation =
new KisAnnotation(
264 TQString(
"chalk_attribute:%1").arg(TQString(attr -> key)),
"", rawdata);
265 TQ_CHECK_PTR(annotation);
267 image -> addAnnotation(annotation);
268#if MagickLibVersion < 0x620
277 void exportAnnotationsForImage(Image * dst, vKisAnnotationSP_it& it, vKisAnnotationSP_it& annotationsEnd)
279 while(it != annotationsEnd) {
280 if (!(*it) || (*it) -> type() == TQString()) {
281 kdDebug(41008) <<
"Warning: empty annotation" << endl;
286 kdDebug(41008) <<
"Trying to store annotation of type " << (*it) -> type() <<
" of size " << (*it) -> annotation() . size() << endl;
288 if ((*it) -> type().startsWith(
"chalk_attribute:")) {
289 if (!SetImageAttribute(dst,
290 (*it) -> type().mid(strlen(
"chalk_attribute:")).ascii(),
291 (*it) -> annotation() . data()) ) {
292 kdDebug(41008) <<
"Storing of attribute " << (*it) -> type() <<
"failed!\n";
295 unsigned char * profiledata =
new unsigned char[(*it) -> annotation() . size()];
296 memcpy( profiledata, (*it) -> annotation() . data(), (*it) -> annotation() . size());
297 if (!ProfileImage(dst, (*it) -> type().ascii(),
298 profiledata, (*it) -> annotation() . size(), MagickFalse)) {
299 kdDebug(41008) <<
"Storing failed!" << endl;
307 void InitGlobalMagick()
309 static bool init =
false;
312 TDEApplication *app = TDEApplication::kApplication();
314 InitializeMagick(*app -> argv());
315 atexit(DestroyMagick);
331 MagickBooleanType monitor(
const char *text,
const ExtendedSignedIntegralType,
const ExtendedUnsignedIntegralType, ExceptionInfo *)
333 TDEApplication *app = TDEApplication::kApplication();
337 if (app -> hasPendingEvents())
338 app -> processEvents();
340 printf(
"%s\n", text);
344 unsigned int monitor(
const char *text,
const ExtendedSignedIntegralType,
const ExtendedUnsignedIntegralType, ExceptionInfo *)
346 TDEApplication *app = TDEApplication::kApplication();
350 if (app -> hasPendingEvents())
351 app -> processEvents();
353 printf(
"%s\n", text);
360KisImageMagickConverter::KisImageMagickConverter(KisDoc *doc, KisUndoAdapter *adapter)
364 SetMonitorHandler(monitor);
368KisImageMagickConverter::~KisImageMagickConverter()
372KisImageBuilder_Result KisImageMagickConverter::decode(
const KURL& uri,
bool isBlob)
381 return KisImageBuilder_RESULT_INTR;
384 GetExceptionInfo(&ei);
385 ii = CloneImageInfo(0);
390 Q_ASSERT(uri.isEmpty());
391 images = BlobToImage(ii, &m_data[0], m_data.size(), &ei);
394 tqstrncpy(ii -> filename, TQFile::encodeName(uri.path()), MaxTextExtent - 1);
396 if (ii -> filename[MaxTextExtent - 1]) {
397 emit notifyProgressError();
398 return KisImageBuilder_RESULT_PATH;
401 images = ReadImage(ii, &ei);
405 if (ei.severity != UndefinedException)
408 kdDebug(41008) <<
"Exceptions happen when loading" << endl;
409 return KisImageBuilder_RESULT_FAILURE;
414 DestroyImageInfo(ii);
415 DestroyExceptionInfo(&ei);
416 emit notifyProgressError();
417 return KisImageBuilder_RESULT_FAILURE;
420 emit notifyProgressStage(i18n(
"Importing..."), 0);
424 while ((image = RemoveFirstImageFromList(&images))) {
425 if(image->rows == 0 or image->columns == 0)
return KisImageBuilder_RESULT_FAILURE;
426 ViewInfo *vi = OpenCacheView(image);
429 unsigned long imageDepth = image->depth;
430 kdDebug(41008) <<
"Image depth: " << imageDepth <<
"\n";
433 KisColorSpace * cs = 0;
434 ColorspaceType colorspaceType;
437 if (GetImageType(image, &ei) == GrayscaleType || GetImageType(image, &ei) == GrayscaleMatteType) {
440 else if ( imageDepth == 16 )
442 colorspaceType = GRAYColorspace;
445 colorspaceType = image->colorspace;
446 csName = getColorSpaceName(image -> colorspace, imageDepth);
449 kdDebug(41008) <<
"image has " << csName <<
" colorspace\n";
451 KisProfile * profile = getProfileForProfileInfo(image);
454 kdDebug(41008) <<
"image has embedded profile: " << profile -> productName() <<
"\n";
455 cs = KisMetaRegistry::instance()->csRegistry()->getColorSpace(csName, profile);
458 cs = KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID(csName,
""),
"");
461 kdDebug(41008) <<
"Chalk does not support colorspace " << image -> colorspace <<
"\n";
464 DestroyExceptionInfo(&ei);
465 DestroyImageList(images);
466 DestroyImageInfo(ii);
467 emit notifyProgressError();
468 return KisImageBuilder_RESULT_UNSUPPORTED_COLORSPACE;
472 m_img =
new KisImage(m_doc->undoAdapter(), image -> columns, image -> rows, cs,
"built image");
474 m_img->blockSignals(
true);
477 setAnnotationsForImage(image, m_img);
480 if (image -> columns && image -> rows) {
483 TQ_UINT8 opacity = OPACITY_OPAQUE;
484 const ImageAttribute * attr = GetImageAttribute(image,
"[layer-opacity]");
486 opacity = TQ_UINT8_MAX - ScaleQuantumToChar(TQString(attr->value).toInt());
489 KisPaintLayerSP layer = 0;
491 attr = GetImageAttribute(image,
"[layer-name]");
493 layer =
new KisPaintLayer(m_img, attr->value, opacity);
496 layer =
new KisPaintLayer(m_img, m_img -> nextLayerName(), opacity);
502 TQ_INT32 x_offset = 0;
503 TQ_INT32 y_offset = 0;
505 attr = GetImageAttribute(image,
"[layer-xpos]");
507 x_offset = TQString(attr->value).toInt();
510 attr = GetImageAttribute(image,
"[layer-ypos]");
512 y_offset = TQString(attr->value).toInt();
516 for (TQ_UINT32 y = 0; y < image->rows; y ++)
518 const PixelPacket *pp = AcquireCacheView(vi, 0, y, image->columns, 1, &ei);
523 DestroyImageList(images);
524 DestroyImageInfo(ii);
525 DestroyExceptionInfo(&ei);
526 emit notifyProgressError();
527 return KisImageBuilder_RESULT_FAILURE;
530 IndexPacket * indexes = GetCacheViewIndexes(vi);
532 KisHLineIteratorPixel hiter = layer->paintDevice()->createHLineIterator(0, y, image->columns,
true);
534 if (colorspaceType== CMYKColorspace) {
535 if (imageDepth == 8) {
537 while (!hiter.isDone())
539 TQ_UINT8 *ptr= hiter.rawData();
540 *(ptr++) = ScaleQuantumToChar(pp->red);
541 *(ptr++) = ScaleQuantumToChar(pp->green);
542 *(ptr++) = ScaleQuantumToChar(pp->blue);
543 *(ptr++) = ScaleQuantumToChar(indexes[x]);
546 if (image->matte != MagickFalse) {
548 if (image->matte ==
true) {
550 *(ptr++) = OPACITY_OPAQUE - ScaleQuantumToChar(pp->opacity);
553 *(ptr++) = OPACITY_OPAQUE;
561 else if (colorspaceType == LABColorspace) {
562 while(! hiter.isDone())
564 TQ_UINT16 *ptr =
reinterpret_cast<TQ_UINT16 *
>(hiter.rawData());
566 *(ptr++) = ScaleQuantumToShort(pp->red);
567 *(ptr++) = ScaleQuantumToShort(pp->green);
568 *(ptr++) = ScaleQuantumToShort(pp->blue);
569 *(ptr++) = 65535 - ScaleQuantumToShort(pp->opacity);
575 else if (colorspaceType == RGBColorspace ||
576 colorspaceType == sRGBColorspace ||
577 colorspaceType == TransparentColorspace)
579 if (imageDepth == 8) {
580 while(! hiter.isDone())
582 TQ_UINT8 *ptr= hiter.rawData();
584 *(ptr++) = ScaleQuantumToChar(pp->blue);
585 *(ptr++) = ScaleQuantumToChar(pp->green);
586 *(ptr++) = ScaleQuantumToChar(pp->red);
587 *(ptr++) = OPACITY_OPAQUE - ScaleQuantumToChar(pp->opacity);
593 else if (imageDepth == 16) {
594 while(! hiter.isDone())
596 TQ_UINT16 *ptr =
reinterpret_cast<TQ_UINT16 *
>(hiter.rawData());
598 *(ptr++) = ScaleQuantumToShort(pp->blue);
599 *(ptr++) = ScaleQuantumToShort(pp->green);
600 *(ptr++) = ScaleQuantumToShort(pp->red);
601 *(ptr++) = 65535 - ScaleQuantumToShort(pp->opacity);
608 else if ( colorspaceType == GRAYColorspace) {
609 if (imageDepth == 8) {
610 while(! hiter.isDone())
612 TQ_UINT8 *ptr= hiter.rawData();
614 *(ptr++) = ScaleQuantumToChar(pp->blue);
615 *(ptr++) = OPACITY_OPAQUE - ScaleQuantumToChar(pp->opacity);
621 else if (imageDepth == 16) {
622 while(! hiter.isDone())
624 TQ_UINT16 *ptr =
reinterpret_cast<TQ_UINT16 *
>(hiter.rawData());
626 *(ptr++) = ScaleQuantumToShort(pp->blue);
627 *(ptr++) = 65535 - ScaleQuantumToShort(pp->opacity);
635 emit notifyProgress(y * 100 / image->rows);
640 DestroyImageList(images);
641 DestroyImageInfo(ii);
642 DestroyExceptionInfo(&ei);
644 return KisImageBuilder_RESULT_INTR;
647 m_img->addLayer(layer.data(), m_img->rootLayer());
648 layer->paintDevice()->move(x_offset, y_offset);
651 emit notifyProgressDone();
656 emit notifyProgressDone();
657 DestroyImageList(images);
658 DestroyImageInfo(ii);
659 DestroyExceptionInfo(&ei);
660 return KisImageBuilder_RESULT_OK;
663 KisImageBuilder_Result KisImageMagickConverter::buildImage(
const KURL& uri)
666 return KisImageBuilder_RESULT_NO_URI;
668 if (!TDEIO::NetAccess::exists(uri,
false, tqApp -> mainWidget())) {
669 return KisImageBuilder_RESULT_NOT_EXIST;
672 KisImageBuilder_Result result = KisImageBuilder_RESULT_FAILURE;
675 if (TDEIO::NetAccess::download(uri, tmpFile, tqApp -> mainWidget())) {
677 uriTF.setPath( tmpFile );
678 result = decode(uriTF,
false);
679 TDEIO::NetAccess::removeTempFile(tmpFile);
686 KisImageSP KisImageMagickConverter::image()
691 void KisImageMagickConverter::init(KisDoc *doc, KisUndoAdapter *adapter)
698 KisImageBuilder_Result KisImageMagickConverter::buildFile(
const KURL& uri, KisPaintLayerSP layer, vKisAnnotationSP_it annotationsStart, vKisAnnotationSP_it annotationsEnd)
705 return KisImageBuilder_RESULT_INVALID_ARG;
707 KisImageSP img = layer->image();
709 return KisImageBuilder_RESULT_EMPTY;
712 return KisImageBuilder_RESULT_NO_URI;
714 if (!uri.isLocalFile())
715 return KisImageBuilder_RESULT_NOT_LOCAL;
718 TQ_UINT32 layerBytesPerChannel = layer->paintDevice()->pixelSize() / layer->paintDevice()->nChannels();
720 GetExceptionInfo(&ei);
722 ii = CloneImageInfo(0);
724 tqstrncpy(ii -> filename, TQFile::encodeName(uri.path()), MaxTextExtent - 1);
726 if (ii -> filename[MaxTextExtent - 1]) {
727 emit notifyProgressError();
728 return KisImageBuilder_RESULT_PATH;
731 if (!img -> width() || !img -> height())
732 return KisImageBuilder_RESULT_EMPTY;
734 if (layerBytesPerChannel < 2) {
741 ii->colorspace = getColorTypeforColorSpace(layer->paintDevice()->colorSpace());
743 image = AllocateImage(ii);
745 image -> columns = img -> width();
746 image -> rows = img -> height();
748 kdDebug(41008) <<
"Saving with colorspace " << image->colorspace <<
", (" << layer->paintDevice()->colorSpace()->id().name() <<
")\n";
749 kdDebug(41008) <<
"IM Image thinks it has depth: " << image->depth <<
"\n";
753 image -> matte = MagickTrue;
758 image -> matte =
true;
761 TQ_INT32 y, height, width;
763 height = img -> height();
764 width = img -> width();
767 TQString ext = TQFileInfo(TQFile::encodeName(uri.path())).extension(
false).upper();
770 tqstrncpy(ii->magick,
"BMP2", MaxTextExtent - 1);
772 else if (ext ==
"RGB") {
773 tqstrncpy(ii->magick,
"SGI", MaxTextExtent - 1);
776 for (y = 0; y < height; y++) {
779 PixelPacket * pp = SetImagePixels(image, 0, y, width, 1);
782 DestroyExceptionInfo(&ei);
784 emit notifyProgressError();
785 return KisImageBuilder_RESULT_FAILURE;
789 KisHLineIterator it = layer->paintDevice()->createHLineIterator(0, y, width,
false);
791 SetImageType(image, TrueColorMatteType);
793 SetImageType(image, TrueColorType);
795 if (image->colorspace== CMYKColorspace) {
797 IndexPacket * indexes = GetIndexes(image);
799 if (layerBytesPerChannel == 2) {
800 while (!it.isDone()) {
802 const TQ_UINT16 *d =
reinterpret_cast<const TQ_UINT16 *
>(it.rawData());
803 pp -> red = ScaleShortToQuantum(d[PIXEL_CYAN]);
804 pp -> green = ScaleShortToQuantum(d[PIXEL_MAGENTA]);
805 pp -> blue = ScaleShortToQuantum(d[PIXEL_YELLOW]);
807 pp -> opacity = ScaleShortToQuantum(65535 - d[PIXEL_CMYK_ALPHA]);
808 indexes[x] = ScaleShortToQuantum(d[PIXEL_BLACK]);
815 while (!it.isDone()) {
817 TQ_UINT8 * d = it.rawData();
818 pp -> red = ScaleCharToQuantum(d[PIXEL_CYAN]);
819 pp -> green = ScaleCharToQuantum(d[PIXEL_MAGENTA]);
820 pp -> blue = ScaleCharToQuantum(d[PIXEL_YELLOW]);
822 pp -> opacity = ScaleCharToQuantum(OPACITY_OPAQUE - d[PIXEL_CMYK_ALPHA]);
823 indexes[x]= ScaleCharToQuantum(d[PIXEL_BLACK]);
831 else if (image->colorspace== RGBColorspace ||
832 image->colorspace == sRGBColorspace ||
833 image->colorspace == TransparentColorspace)
835 if (layerBytesPerChannel == 2) {
836 while (!it.isDone()) {
838 const TQ_UINT16 *d =
reinterpret_cast<const TQ_UINT16 *
>(it.rawData());
839 pp -> red = ScaleShortToQuantum(d[PIXEL_RED]);
840 pp -> green = ScaleShortToQuantum(d[PIXEL_GREEN]);
841 pp -> blue = ScaleShortToQuantum(d[PIXEL_BLUE]);
843 pp -> opacity = ScaleShortToQuantum(65535 - d[PIXEL_ALPHA]);
850 while (!it.isDone()) {
852 TQ_UINT8 * d = it.rawData();
853 pp -> red = ScaleCharToQuantum(d[PIXEL_RED]);
854 pp -> green = ScaleCharToQuantum(d[PIXEL_GREEN]);
855 pp -> blue = ScaleCharToQuantum(d[PIXEL_BLUE]);
857 pp -> opacity = ScaleCharToQuantum(OPACITY_OPAQUE - d[PIXEL_ALPHA]);
864 else if (image->colorspace == GRAYColorspace)
866 SetImageType(image, GrayscaleMatteType);
867 if (layerBytesPerChannel == 2) {
868 while (!it.isDone()) {
870 const TQ_UINT16 *d =
reinterpret_cast<const TQ_UINT16 *
>(it.rawData());
871 pp -> red = ScaleShortToQuantum(d[PIXEL_GRAY]);
872 pp -> green = ScaleShortToQuantum(d[PIXEL_GRAY]);
873 pp -> blue = ScaleShortToQuantum(d[PIXEL_GRAY]);
875 pp -> opacity = ScaleShortToQuantum(65535 - d[PIXEL_GRAY_ALPHA]);
882 while (!it.isDone()) {
883 TQ_UINT8 * d = it.rawData();
884 pp -> red = ScaleCharToQuantum(d[PIXEL_GRAY]);
885 pp -> green = ScaleCharToQuantum(d[PIXEL_GRAY]);
886 pp -> blue = ScaleCharToQuantum(d[PIXEL_GRAY]);
888 pp -> opacity = ScaleCharToQuantum(OPACITY_OPAQUE - d[PIXEL_GRAY_ALPHA]);
896 kdDebug(41008) <<
"Unsupported image format\n";
897 return KisImageBuilder_RESULT_INVALID_ARG;
900 emit notifyProgressStage(i18n(
"Saving..."), y * 100 / height);
903 if (SyncImagePixels(image) == MagickFalse)
904 kdDebug(41008) <<
"Syncing pixels failed\n";
906 if (!SyncImagePixels(image))
907 kdDebug(41008) <<
"Syncing pixels failed\n";
912 exportAnnotationsForImage(image, annotationsStart, annotationsEnd);
917 WriteImage(ii, image);
918 DestroyExceptionInfo(&ei);
920 emit notifyProgressDone();
921 return KisImageBuilder_RESULT_OK;
924 void KisImageMagickConverter::ioData(TDEIO::Job *job,
const TQByteArray& data)
926 if (data.isNull() || data.isEmpty()) {
927 emit notifyProgressStage(i18n(
"Loading..."), 0);
931 if (m_data.empty()) {
936 ii = CloneImageInfo(0);
937 GetExceptionInfo(&ei);
938 image = PingBlob(ii, data.data(), data.size(), &ei);
940 if (image == 0 || ei.severity == BlobError) {
941 DestroyExceptionInfo(&ei);
942 DestroyImageInfo(ii);
944 emit notifyProgressError();
949 DestroyExceptionInfo(&ei);
950 DestroyImageInfo(ii);
951 emit notifyProgressStage(i18n(
"Loading..."), 0);
954 Q_ASSERT(data.size() + m_data.size() <= m_size);
955 memcpy(&m_data[m_data.size()], data.data(), data.count());
956 m_data.resize(m_data.size() + data.count());
957 emit notifyProgressStage(i18n(
"Loading..."), m_data.size() * 100 / m_size);
963 void KisImageMagickConverter::ioResult(TDEIO::Job *job)
968 emit notifyProgressError();
970 decode(KURL(),
true);
973 void KisImageMagickConverter::ioTotalSize(TDEIO::Job * , TDEIO::filesize_t size)
976 m_data.reserve(size);
977 emit notifyProgressStage(i18n(
"Loading..."), 0);
980 void KisImageMagickConverter::cancel()
989 TQString KisImageMagickConverter::readFilters()
994 TQString description;
995 unsigned long matches;
1009 const MagickInfo *mi;
1011 GetExceptionInfo(&ei);
1012 mi = GetMagickInfo(
"*", &ei);
1013 DestroyExceptionInfo(&ei);
1039 for (; mi; mi =
reinterpret_cast<const MagickInfo*
>(mi -> next)) {
1042 if (mi -> decoder) {
1044 description = mi -> description;
1045 kdDebug(41008) <<
"Found import filter for: " << name <<
"\n";
1047 if (!description.isEmpty() && !description.contains(
'/')) {
1048 all +=
"*." + name.lower() +
" *." + name +
" ";
1049 s +=
"*." + name.lower() +
" *." + name +
"|";
1050 s += i18n(description.utf8());
1057 all +=
"|" + i18n(
"All Images");
1063 TQString KisImageMagickConverter::writeFilters()
1068 TQString description;
1069 unsigned long matches;
1083 const MagickInfo *mi;
1085 GetExceptionInfo(&ei);
1086 mi = GetMagickInfo(
"*", &ei);
1087 DestroyExceptionInfo(&ei);
1091 kdDebug(41008) <<
"Eek, no magick info!\n";
1116 for (; mi; mi =
reinterpret_cast<const MagickInfo*
>(mi -> next)) {
1117 kdDebug(41008) <<
"Found export filter for: " << mi -> name <<
"\n";
1121 if (mi -> encoder) {
1124 description = mi -> description;
1126 if (!description.isEmpty() && !description.contains(
'/')) {
1127 all +=
"*." + name.lower() +
" *." + name +
" ";
1128 s +=
"*." + name.lower() +
" *." + name +
"|";
1129 s += i18n(description.utf8());
1137 all +=
"|" + i18n(
"All Images");
1143#include "kis_image_magick_converter.moc"