25#include <magick/api.h>
28#include <tqfileinfo.h>
31#include <tdeapplication.h>
34#include <tdeio/netaccess.h>
39#include "kis_global.h"
43#include "kis_undo_adapter.h"
44#include "kis_image_magick_converter.h"
45#include "kis_meta_registry.h"
46#include "kis_colorspace_factory_registry.h"
47#include "kis_iterators_pixel.h"
48#include "kis_colorspace.h"
49#include "kis_profile.h"
50#include "kis_annotation.h"
51#include "kis_paint_layer.h"
52#include "kis_group_layer.h"
53#include "kis_paint_device.h"
55#include "../../../config.h"
59 const TQ_UINT8 PIXEL_BLUE = 0;
60 const TQ_UINT8 PIXEL_GREEN = 1;
61 const TQ_UINT8 PIXEL_RED = 2;
62 const TQ_UINT8 PIXEL_ALPHA = 3;
64 static const TQ_UINT8 PIXEL_CYAN = 0;
65 static const TQ_UINT8 PIXEL_MAGENTA = 1;
66 static const TQ_UINT8 PIXEL_YELLOW = 2;
67 static const TQ_UINT8 PIXEL_BLACK = 3;
68 static const TQ_UINT8 PIXEL_CMYK_ALPHA = 4;
70 static const TQ_UINT8 PIXEL_GRAY = 0;
71 static const TQ_UINT8 PIXEL_GRAY_ALPHA = 1;
77 TQString getColorSpaceName(ColorspaceType type,
unsigned long imageDepth = 8)
80 if (type == GRAYColorspace) {
83 else if ( imageDepth == 16 )
86 else if (type == CMYKColorspace) {
89 else if ( imageDepth == 16 ) {
93 else if (type == LABColorspace) {
94 kdDebug(41008) <<
"Lab!\n";
97 else if (type == RGBColorspace || type == sRGBColorspace || type == TransparentColorspace) {
100 else if (imageDepth == 16)
107 ColorspaceType getColorTypeforColorSpace( KisColorSpace * cs )
109 if ( cs->id() == KisID(
"GRAYA") || cs->id() == KisID(
"GRAYA16") )
return GRAYColorspace;
110 if ( cs->id() == KisID(
"RGBA") || cs->id() == KisID(
"RGBA16") )
return RGBColorspace;
111 if ( cs->id() == KisID(
"CMYK") || cs->id() == KisID(
"CMYK16") )
return CMYKColorspace;
112 if ( cs->id() == KisID(
"LABA") )
return LABColorspace;
114 kdDebug(41008) <<
"Cannot export images in " + cs->id().name() +
" yet.\n";
115 return RGBColorspace;
119 KisProfile * getProfileForProfileInfo(
const Image * image)
123 const unsigned char * profiledata = GetImageProfile(image,
"ICM", &length);
124 if( profiledata == NULL )
127 rawdata.resize(length);
128 memcpy(rawdata.data(), profiledata, length);
130 KisProfile* p =
new KisProfile(rawdata);
136 if (image->profiles == NULL)
140 const StringInfo *profile;
144 ResetImageProfileIterator(image);
145 for (name = GetNextImageProfile(image); name != (
char *) NULL; )
147 profile = GetImageProfile(image, name);
148 if (profile == (StringInfo *) NULL)
152 if (TQString::compare(name,
"icc") == 0) {
154 rawdata.resize(profile->length);
155 memcpy(rawdata.data(), profile->datum, profile->length);
157 p =
new KisProfile(rawdata);
161 name = GetNextImageProfile(image);
167 void setAnnotationsForImage(
const Image * src, KisImageSP image)
171 const unsigned char * profiledata = GetImageProfile(src,
"IPTC", &length);
172 if( profiledata != NULL )
175 rawdata.resize(length);
176 memcpy(rawdata.data(), profiledata, length);
178 KisAnnotation* annotation =
new KisAnnotation(TQString(
"IPTC"),
"", rawdata);
179 TQ_CHECK_PTR(annotation);
181 image -> addAnnotation(annotation);
185 for(
int i = 0; i < src->generic_profiles; i++)
188 rawdata.resize(length);
189 memcpy(rawdata.data(), src->generic_profile[i].info, src->generic_profile[i].length);
191 KisAnnotation* annotation =
new KisAnnotation(TQString(src->generic_profile[i].name),
"", rawdata);
192 TQ_CHECK_PTR(annotation);
194 image -> addAnnotation(annotation);
198 const ImageAttribute* imgAttr = GetImageAttribute(src, NULL);
202 int len = strlen(imgAttr -> value) + 1;
204 memcpy(rawdata.data(), imgAttr -> value, len);
206 KisAnnotation* annotation =
new KisAnnotation( TQString(
"chalk_attribute:%1").arg(TQString(imgAttr -> key)),
"", rawdata );
207 TQ_CHECK_PTR(annotation);
209 image -> addAnnotation(annotation);
211 imgAttr = imgAttr->next;
215 if (src->profiles == NULL)
218 const char *name = 0;
219 const StringInfo *profile;
220 KisAnnotation* annotation = 0;
223 ResetImageProfileIterator(src);
224 while((name = GetNextImageProfile(src))) {
225 profile = GetImageProfile(src, name);
226 if (profile == (StringInfo *) NULL)
230 if (TQString::compare(name,
"icc") == 0)
234 rawdata.resize(profile->length);
235 memcpy(rawdata.data(), profile->datum, profile->length);
237 annotation =
new KisAnnotation(TQString(name),
"", rawdata);
238 TQ_CHECK_PTR(annotation);
240 image -> addAnnotation(annotation);
248#if MagickLibVersion >= 0x621
249 const ImageAttribute * attr;
250 ResetImageAttributeIterator(src);
251 while ( (attr = GetNextImageAttribute(src)) ) {
253 ImageAttribute * attr = src -> attributes;
257 int len = strlen(attr -> value) + 1;
259 memcpy(rawdata.data(), attr -> value, len);
261 annotation =
new KisAnnotation(
262 TQString(
"chalk_attribute:%1").arg(TQString(attr -> key)),
"", rawdata);
263 TQ_CHECK_PTR(annotation);
265 image -> addAnnotation(annotation);
266#if MagickLibVersion < 0x620
275 void exportAnnotationsForImage(Image * dst, vKisAnnotationSP_it& it, vKisAnnotationSP_it& annotationsEnd)
277 while(it != annotationsEnd) {
278 if (!(*it) || (*it) -> type() == TQString()) {
279 kdDebug(41008) <<
"Warning: empty annotation" << endl;
284 kdDebug(41008) <<
"Trying to store annotation of type " << (*it) -> type() <<
" of size " << (*it) -> annotation() . size() << endl;
286 if ((*it) -> type().startsWith(
"chalk_attribute:")) {
287 if (!SetImageAttribute(dst,
288 (*it) -> type().mid(strlen(
"chalk_attribute:")).ascii(),
289 (*it) -> annotation() . data()) ) {
290 kdDebug(41008) <<
"Storing of attribute " << (*it) -> type() <<
"failed!\n";
293 unsigned char * profiledata =
new unsigned char[(*it) -> annotation() . size()];
294 memcpy( profiledata, (*it) -> annotation() . data(), (*it) -> annotation() . size());
295 if (!ProfileImage(dst, (*it) -> type().ascii(),
296 profiledata, (*it) -> annotation() . size(), MagickFalse)) {
297 kdDebug(41008) <<
"Storing failed!" << endl;
305 void InitGlobalMagick()
307 static bool init =
false;
310 TDEApplication *app = TDEApplication::kApplication();
312 InitializeMagick(*app -> argv());
313 atexit(DestroyMagick);
329 MagickBooleanType monitor(
const char *text,
const ExtendedSignedIntegralType,
const ExtendedUnsignedIntegralType, ExceptionInfo *)
331 TDEApplication *app = TDEApplication::kApplication();
335 if (app -> hasPendingEvents())
336 app -> processEvents();
338 printf(
"%s\n", text);
342 unsigned int monitor(
const char *text,
const ExtendedSignedIntegralType,
const ExtendedUnsignedIntegralType, ExceptionInfo *)
344 TDEApplication *app = TDEApplication::kApplication();
348 if (app -> hasPendingEvents())
349 app -> processEvents();
351 printf(
"%s\n", text);
358KisImageMagickConverter::KisImageMagickConverter(KisDoc *doc, KisUndoAdapter *adapter)
362 SetMonitorHandler(monitor);
366KisImageMagickConverter::~KisImageMagickConverter()
370KisImageBuilder_Result KisImageMagickConverter::decode(
const KURL& uri,
bool isBlob)
379 return KisImageBuilder_RESULT_INTR;
382 GetExceptionInfo(&ei);
383 ii = CloneImageInfo(0);
388 Q_ASSERT(uri.isEmpty());
389 images = BlobToImage(ii, &m_data[0], m_data.size(), &ei);
392 tqstrncpy(ii -> filename, TQFile::encodeName(uri.path()), MaxTextExtent - 1);
394 if (ii -> filename[MaxTextExtent - 1]) {
395 emit notifyProgressError();
396 return KisImageBuilder_RESULT_PATH;
399 images = ReadImage(ii, &ei);
403 if (ei.severity != UndefinedException)
406 kdDebug(41008) <<
"Exceptions happen when loading" << endl;
407 return KisImageBuilder_RESULT_FAILURE;
412 DestroyImageInfo(ii);
413 DestroyExceptionInfo(&ei);
414 emit notifyProgressError();
415 return KisImageBuilder_RESULT_FAILURE;
418 emit notifyProgressStage(i18n(
"Importing..."), 0);
422 while ((image = RemoveFirstImageFromList(&images))) {
423 if(image->rows == 0 or image->columns == 0)
return KisImageBuilder_RESULT_FAILURE;
424 ViewInfo *vi = OpenCacheView(image);
427 unsigned long imageDepth = image->depth;
428 kdDebug(41008) <<
"Image depth: " << imageDepth <<
"\n";
431 KisColorSpace * cs = 0;
432 ColorspaceType colorspaceType;
435 if (GetImageType(image, &ei) == GrayscaleType || GetImageType(image, &ei) == GrayscaleMatteType) {
438 else if ( imageDepth == 16 )
440 colorspaceType = GRAYColorspace;
443 colorspaceType = image->colorspace;
444 csName = getColorSpaceName(image -> colorspace, imageDepth);
447 kdDebug(41008) <<
"image has " << csName <<
" colorspace\n";
449 KisProfile * profile = getProfileForProfileInfo(image);
452 kdDebug(41008) <<
"image has embedded profile: " << profile -> productName() <<
"\n";
453 cs = KisMetaRegistry::instance()->csRegistry()->getColorSpace(csName, profile);
456 cs = KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID(csName,
""),
"");
459 kdDebug(41008) <<
"Chalk does not support colorspace " << image -> colorspace <<
"\n";
462 DestroyExceptionInfo(&ei);
463 DestroyImageList(images);
464 DestroyImageInfo(ii);
465 emit notifyProgressError();
466 return KisImageBuilder_RESULT_UNSUPPORTED_COLORSPACE;
470 m_img =
new KisImage(m_doc->undoAdapter(), image -> columns, image -> rows, cs,
"built image");
472 m_img->blockSignals(
true);
475 setAnnotationsForImage(image, m_img);
478 if (image -> columns && image -> rows) {
481 TQ_UINT8 opacity = OPACITY_OPAQUE;
482 const ImageAttribute * attr = GetImageAttribute(image,
"[layer-opacity]");
484 opacity = TQ_UINT8_MAX - ScaleQuantumToChar(TQString(attr->value).toInt());
487 KisPaintLayerSP layer = 0;
489 attr = GetImageAttribute(image,
"[layer-name]");
491 layer =
new KisPaintLayer(m_img, attr->value, opacity);
494 layer =
new KisPaintLayer(m_img, m_img -> nextLayerName(), opacity);
500 TQ_INT32 x_offset = 0;
501 TQ_INT32 y_offset = 0;
503 attr = GetImageAttribute(image,
"[layer-xpos]");
505 x_offset = TQString(attr->value).toInt();
508 attr = GetImageAttribute(image,
"[layer-ypos]");
510 y_offset = TQString(attr->value).toInt();
514 for (TQ_UINT32 y = 0; y < image->rows; y ++)
516 const PixelPacket *pp = AcquireCacheView(vi, 0, y, image->columns, 1, &ei);
521 DestroyImageList(images);
522 DestroyImageInfo(ii);
523 DestroyExceptionInfo(&ei);
524 emit notifyProgressError();
525 return KisImageBuilder_RESULT_FAILURE;
528 IndexPacket * indexes = GetCacheViewIndexes(vi);
530 KisHLineIteratorPixel hiter = layer->paintDevice()->createHLineIterator(0, y, image->columns,
true);
532 if (colorspaceType== CMYKColorspace) {
533 if (imageDepth == 8) {
535 while (!hiter.isDone())
537 TQ_UINT8 *ptr= hiter.rawData();
538 *(ptr++) = ScaleQuantumToChar(pp->red);
539 *(ptr++) = ScaleQuantumToChar(pp->green);
540 *(ptr++) = ScaleQuantumToChar(pp->blue);
541 *(ptr++) = ScaleQuantumToChar(indexes[x]);
544 if (image->matte != MagickFalse) {
546 if (image->matte ==
true) {
548 *(ptr++) = OPACITY_OPAQUE - ScaleQuantumToChar(pp->opacity);
551 *(ptr++) = OPACITY_OPAQUE;
559 else if (colorspaceType == LABColorspace) {
560 while(! hiter.isDone())
562 TQ_UINT16 *ptr =
reinterpret_cast<TQ_UINT16 *
>(hiter.rawData());
564 *(ptr++) = ScaleQuantumToShort(pp->red);
565 *(ptr++) = ScaleQuantumToShort(pp->green);
566 *(ptr++) = ScaleQuantumToShort(pp->blue);
567 *(ptr++) = 65535 - ScaleQuantumToShort(pp->opacity);
573 else if (colorspaceType == RGBColorspace ||
574 colorspaceType == sRGBColorspace ||
575 colorspaceType == TransparentColorspace)
577 if (imageDepth == 8) {
578 while(! hiter.isDone())
580 TQ_UINT8 *ptr= hiter.rawData();
582 *(ptr++) = ScaleQuantumToChar(pp->blue);
583 *(ptr++) = ScaleQuantumToChar(pp->green);
584 *(ptr++) = ScaleQuantumToChar(pp->red);
585 *(ptr++) = OPACITY_OPAQUE - ScaleQuantumToChar(pp->opacity);
591 else if (imageDepth == 16) {
592 while(! hiter.isDone())
594 TQ_UINT16 *ptr =
reinterpret_cast<TQ_UINT16 *
>(hiter.rawData());
596 *(ptr++) = ScaleQuantumToShort(pp->blue);
597 *(ptr++) = ScaleQuantumToShort(pp->green);
598 *(ptr++) = ScaleQuantumToShort(pp->red);
599 *(ptr++) = 65535 - ScaleQuantumToShort(pp->opacity);
606 else if ( colorspaceType == GRAYColorspace) {
607 if (imageDepth == 8) {
608 while(! hiter.isDone())
610 TQ_UINT8 *ptr= hiter.rawData();
612 *(ptr++) = ScaleQuantumToChar(pp->blue);
613 *(ptr++) = OPACITY_OPAQUE - ScaleQuantumToChar(pp->opacity);
619 else if (imageDepth == 16) {
620 while(! hiter.isDone())
622 TQ_UINT16 *ptr =
reinterpret_cast<TQ_UINT16 *
>(hiter.rawData());
624 *(ptr++) = ScaleQuantumToShort(pp->blue);
625 *(ptr++) = 65535 - ScaleQuantumToShort(pp->opacity);
633 emit notifyProgress(y * 100 / image->rows);
638 DestroyImageList(images);
639 DestroyImageInfo(ii);
640 DestroyExceptionInfo(&ei);
642 return KisImageBuilder_RESULT_INTR;
645 m_img->addLayer(layer.data(), m_img->rootLayer());
646 layer->paintDevice()->move(x_offset, y_offset);
649 emit notifyProgressDone();
654 emit notifyProgressDone();
655 DestroyImageList(images);
656 DestroyImageInfo(ii);
657 DestroyExceptionInfo(&ei);
658 return KisImageBuilder_RESULT_OK;
661 KisImageBuilder_Result KisImageMagickConverter::buildImage(
const KURL& uri)
664 return KisImageBuilder_RESULT_NO_URI;
666 if (!TDEIO::NetAccess::exists(uri,
false, tqApp -> mainWidget())) {
667 return KisImageBuilder_RESULT_NOT_EXIST;
670 KisImageBuilder_Result result = KisImageBuilder_RESULT_FAILURE;
673 if (TDEIO::NetAccess::download(uri, tmpFile, tqApp -> mainWidget())) {
675 uriTF.setPath( tmpFile );
676 result = decode(uriTF,
false);
677 TDEIO::NetAccess::removeTempFile(tmpFile);
684 KisImageSP KisImageMagickConverter::image()
689 void KisImageMagickConverter::init(KisDoc *doc, KisUndoAdapter *adapter)
696 KisImageBuilder_Result KisImageMagickConverter::buildFile(
const KURL& uri, KisPaintLayerSP layer, vKisAnnotationSP_it annotationsStart, vKisAnnotationSP_it annotationsEnd)
703 return KisImageBuilder_RESULT_INVALID_ARG;
705 KisImageSP img = layer->image();
707 return KisImageBuilder_RESULT_EMPTY;
710 return KisImageBuilder_RESULT_NO_URI;
712 if (!uri.isLocalFile())
713 return KisImageBuilder_RESULT_NOT_LOCAL;
716 TQ_UINT32 layerBytesPerChannel = layer->paintDevice()->pixelSize() / layer->paintDevice()->nChannels();
718 GetExceptionInfo(&ei);
720 ii = CloneImageInfo(0);
722 tqstrncpy(ii -> filename, TQFile::encodeName(uri.path()), MaxTextExtent - 1);
724 if (ii -> filename[MaxTextExtent - 1]) {
725 emit notifyProgressError();
726 return KisImageBuilder_RESULT_PATH;
729 if (!img -> width() || !img -> height())
730 return KisImageBuilder_RESULT_EMPTY;
732 if (layerBytesPerChannel < 2) {
739 ii->colorspace = getColorTypeforColorSpace(layer->paintDevice()->colorSpace());
741 image = AllocateImage(ii);
743 image -> columns = img -> width();
744 image -> rows = img -> height();
746 kdDebug(41008) <<
"Saving with colorspace " << image->colorspace <<
", (" << layer->paintDevice()->colorSpace()->id().name() <<
")\n";
747 kdDebug(41008) <<
"IM Image thinks it has depth: " << image->depth <<
"\n";
751 image -> matte = MagickTrue;
756 image -> matte =
true;
759 TQ_INT32 y, height, width;
761 height = img -> height();
762 width = img -> width();
765 TQString ext = TQFileInfo(TQFile::encodeName(uri.path())).extension(
false).upper();
768 tqstrncpy(ii->magick,
"BMP2", MaxTextExtent - 1);
770 else if (ext ==
"RGB") {
771 tqstrncpy(ii->magick,
"SGI", MaxTextExtent - 1);
774 for (y = 0; y < height; y++) {
777 PixelPacket * pp = SetImagePixels(image, 0, y, width, 1);
780 DestroyExceptionInfo(&ei);
782 emit notifyProgressError();
783 return KisImageBuilder_RESULT_FAILURE;
787 KisHLineIterator it = layer->paintDevice()->createHLineIterator(0, y, width,
false);
789 SetImageType(image, TrueColorMatteType);
791 SetImageType(image, TrueColorType);
793 if (image->colorspace== CMYKColorspace) {
795 IndexPacket * indexes = GetIndexes(image);
797 if (layerBytesPerChannel == 2) {
798 while (!it.isDone()) {
800 const TQ_UINT16 *d =
reinterpret_cast<const TQ_UINT16 *
>(it.rawData());
801 pp -> red = ScaleShortToQuantum(d[PIXEL_CYAN]);
802 pp -> green = ScaleShortToQuantum(d[PIXEL_MAGENTA]);
803 pp -> blue = ScaleShortToQuantum(d[PIXEL_YELLOW]);
805 pp -> opacity = ScaleShortToQuantum(65535 - d[PIXEL_CMYK_ALPHA]);
806 indexes[x] = ScaleShortToQuantum(d[PIXEL_BLACK]);
813 while (!it.isDone()) {
815 TQ_UINT8 * d = it.rawData();
816 pp -> red = ScaleCharToQuantum(d[PIXEL_CYAN]);
817 pp -> green = ScaleCharToQuantum(d[PIXEL_MAGENTA]);
818 pp -> blue = ScaleCharToQuantum(d[PIXEL_YELLOW]);
820 pp -> opacity = ScaleCharToQuantum(OPACITY_OPAQUE - d[PIXEL_CMYK_ALPHA]);
821 indexes[x]= ScaleCharToQuantum(d[PIXEL_BLACK]);
829 else if (image->colorspace== RGBColorspace ||
830 image->colorspace == sRGBColorspace ||
831 image->colorspace == TransparentColorspace)
833 if (layerBytesPerChannel == 2) {
834 while (!it.isDone()) {
836 const TQ_UINT16 *d =
reinterpret_cast<const TQ_UINT16 *
>(it.rawData());
837 pp -> red = ScaleShortToQuantum(d[PIXEL_RED]);
838 pp -> green = ScaleShortToQuantum(d[PIXEL_GREEN]);
839 pp -> blue = ScaleShortToQuantum(d[PIXEL_BLUE]);
841 pp -> opacity = ScaleShortToQuantum(65535 - d[PIXEL_ALPHA]);
848 while (!it.isDone()) {
850 TQ_UINT8 * d = it.rawData();
851 pp -> red = ScaleCharToQuantum(d[PIXEL_RED]);
852 pp -> green = ScaleCharToQuantum(d[PIXEL_GREEN]);
853 pp -> blue = ScaleCharToQuantum(d[PIXEL_BLUE]);
855 pp -> opacity = ScaleCharToQuantum(OPACITY_OPAQUE - d[PIXEL_ALPHA]);
862 else if (image->colorspace == GRAYColorspace)
864 SetImageType(image, GrayscaleMatteType);
865 if (layerBytesPerChannel == 2) {
866 while (!it.isDone()) {
868 const TQ_UINT16 *d =
reinterpret_cast<const TQ_UINT16 *
>(it.rawData());
869 pp -> red = ScaleShortToQuantum(d[PIXEL_GRAY]);
870 pp -> green = ScaleShortToQuantum(d[PIXEL_GRAY]);
871 pp -> blue = ScaleShortToQuantum(d[PIXEL_GRAY]);
873 pp -> opacity = ScaleShortToQuantum(65535 - d[PIXEL_GRAY_ALPHA]);
880 while (!it.isDone()) {
881 TQ_UINT8 * d = it.rawData();
882 pp -> red = ScaleCharToQuantum(d[PIXEL_GRAY]);
883 pp -> green = ScaleCharToQuantum(d[PIXEL_GRAY]);
884 pp -> blue = ScaleCharToQuantum(d[PIXEL_GRAY]);
886 pp -> opacity = ScaleCharToQuantum(OPACITY_OPAQUE - d[PIXEL_GRAY_ALPHA]);
894 kdDebug(41008) <<
"Unsupported image format\n";
895 return KisImageBuilder_RESULT_INVALID_ARG;
898 emit notifyProgressStage(i18n(
"Saving..."), y * 100 / height);
901 if (SyncImagePixels(image) == MagickFalse)
902 kdDebug(41008) <<
"Syncing pixels failed\n";
904 if (!SyncImagePixels(image))
905 kdDebug(41008) <<
"Syncing pixels failed\n";
910 exportAnnotationsForImage(image, annotationsStart, annotationsEnd);
915 WriteImage(ii, image);
916 DestroyExceptionInfo(&ei);
918 emit notifyProgressDone();
919 return KisImageBuilder_RESULT_OK;
922 void KisImageMagickConverter::ioData(TDEIO::Job *job,
const TQByteArray& data)
924 if (data.isNull() || data.isEmpty()) {
925 emit notifyProgressStage(i18n(
"Loading..."), 0);
929 if (m_data.empty()) {
934 ii = CloneImageInfo(0);
935 GetExceptionInfo(&ei);
936 image = PingBlob(ii, data.data(), data.size(), &ei);
938 if (image == 0 || ei.severity == BlobError) {
939 DestroyExceptionInfo(&ei);
940 DestroyImageInfo(ii);
942 emit notifyProgressError();
947 DestroyExceptionInfo(&ei);
948 DestroyImageInfo(ii);
949 emit notifyProgressStage(i18n(
"Loading..."), 0);
952 Q_ASSERT(data.size() + m_data.size() <= m_size);
953 memcpy(&m_data[m_data.size()], data.data(), data.count());
954 m_data.resize(m_data.size() + data.count());
955 emit notifyProgressStage(i18n(
"Loading..."), m_data.size() * 100 / m_size);
961 void KisImageMagickConverter::ioResult(TDEIO::Job *job)
966 emit notifyProgressError();
968 decode(KURL(),
true);
971 void KisImageMagickConverter::ioTotalSize(TDEIO::Job * , TDEIO::filesize_t size)
974 m_data.reserve(size);
975 emit notifyProgressStage(i18n(
"Loading..."), 0);
978 void KisImageMagickConverter::cancel()
987 TQString KisImageMagickConverter::readFilters()
992 TQString description;
993 unsigned long matches;
1007 const MagickInfo *mi;
1009 GetExceptionInfo(&ei);
1010 mi = GetMagickInfo(
"*", &ei);
1011 DestroyExceptionInfo(&ei);
1037 for (; mi; mi =
reinterpret_cast<const MagickInfo*
>(mi -> next)) {
1040 if (mi -> decoder) {
1042 description = mi -> description;
1043 kdDebug(41008) <<
"Found import filter for: " << name <<
"\n";
1045 if (!description.isEmpty() && !description.contains(
'/')) {
1046 all +=
"*." + name.lower() +
" *." + name +
" ";
1047 s +=
"*." + name.lower() +
" *." + name +
"|";
1048 s += i18n(description.utf8());
1055 all +=
"|" + i18n(
"All Images");
1061 TQString KisImageMagickConverter::writeFilters()
1066 TQString description;
1067 unsigned long matches;
1081 const MagickInfo *mi;
1083 GetExceptionInfo(&ei);
1084 mi = GetMagickInfo(
"*", &ei);
1085 DestroyExceptionInfo(&ei);
1089 kdDebug(41008) <<
"Eek, no magick info!\n";
1114 for (; mi; mi =
reinterpret_cast<const MagickInfo*
>(mi -> next)) {
1115 kdDebug(41008) <<
"Found export filter for: " << mi -> name <<
"\n";
1119 if (mi -> encoder) {
1122 description = mi -> description;
1124 if (!description.isEmpty() && !description.contains(
'/')) {
1125 all +=
"*." + name.lower() +
" *." + name +
" ";
1126 s +=
"*." + name.lower() +
" *." + name +
"|";
1127 s += i18n(description.utf8());
1135 all +=
"|" + i18n(
"All Images");
1141#include "kis_image_magick_converter.moc"