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();
311 InitializeMagick(*app -> argv());
312 atexit(DestroyMagick);
328 MagickBooleanType monitor(
const char *text,
const ExtendedSignedIntegralType,
const ExtendedUnsignedIntegralType, ExceptionInfo *)
330 TDEApplication *app = TDEApplication::kApplication();
333 if (app -> hasPendingEvents())
334 app -> processEvents();
336 printf(
"%s\n", text);
340 unsigned int monitor(
const char *text,
const ExtendedSignedIntegralType,
const ExtendedUnsignedIntegralType, ExceptionInfo *)
342 TDEApplication *app = TDEApplication::kApplication();
346 if (app -> hasPendingEvents())
347 app -> processEvents();
349 printf(
"%s\n", text);
356KisImageMagickConverter::KisImageMagickConverter(KisDoc *doc, KisUndoAdapter *adapter)
360 SetMonitorHandler(monitor);
364KisImageMagickConverter::~KisImageMagickConverter()
368KisImageBuilder_Result KisImageMagickConverter::decode(
const KURL& uri,
bool isBlob)
377 return KisImageBuilder_RESULT_INTR;
380 GetExceptionInfo(&ei);
381 ii = CloneImageInfo(0);
386 Q_ASSERT(uri.isEmpty());
387 images = BlobToImage(ii, &m_data[0], m_data.size(), &ei);
390 tqstrncpy(ii -> filename, TQFile::encodeName(uri.path()), MaxTextExtent - 1);
392 if (ii -> filename[MaxTextExtent - 1]) {
393 emit notifyProgressError();
394 return KisImageBuilder_RESULT_PATH;
397 images = ReadImage(ii, &ei);
401 if (ei.severity != UndefinedException)
404 kdDebug(41008) <<
"Exceptions happen when loading" << endl;
405 return KisImageBuilder_RESULT_FAILURE;
410 DestroyImageInfo(ii);
411 DestroyExceptionInfo(&ei);
412 emit notifyProgressError();
413 return KisImageBuilder_RESULT_FAILURE;
416 emit notifyProgressStage(i18n(
"Importing..."), 0);
420 while ((image = RemoveFirstImageFromList(&images))) {
421 if(image->rows == 0 or image->columns == 0)
return KisImageBuilder_RESULT_FAILURE;
422 ViewInfo *vi = OpenCacheView(image);
425 unsigned long imageDepth = image->depth;
426 kdDebug(41008) <<
"Image depth: " << imageDepth <<
"\n";
429 KisColorSpace * cs = 0;
430 ColorspaceType colorspaceType;
433 if (GetImageType(image, &ei) == GrayscaleType || GetImageType(image, &ei) == GrayscaleMatteType) {
436 else if ( imageDepth == 16 )
438 colorspaceType = GRAYColorspace;
441 colorspaceType = image->colorspace;
442 csName = getColorSpaceName(image -> colorspace, imageDepth);
445 kdDebug(41008) <<
"image has " << csName <<
" colorspace\n";
447 KisProfile * profile = getProfileForProfileInfo(image);
450 kdDebug(41008) <<
"image has embedded profile: " << profile -> productName() <<
"\n";
451 cs = KisMetaRegistry::instance()->csRegistry()->getColorSpace(csName, profile);
454 cs = KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID(csName,
""),
"");
457 kdDebug(41008) <<
"Chalk does not support colorspace " << image -> colorspace <<
"\n";
460 DestroyExceptionInfo(&ei);
461 DestroyImageList(images);
462 DestroyImageInfo(ii);
463 emit notifyProgressError();
464 return KisImageBuilder_RESULT_UNSUPPORTED_COLORSPACE;
468 m_img =
new KisImage(m_doc->undoAdapter(), image -> columns, image -> rows, cs,
"built image");
470 m_img->blockSignals(
true);
473 setAnnotationsForImage(image, m_img);
476 if (image -> columns && image -> rows) {
479 TQ_UINT8 opacity = OPACITY_OPAQUE;
480 const ImageAttribute * attr = GetImageAttribute(image,
"[layer-opacity]");
482 opacity = TQ_UINT8_MAX - ScaleQuantumToChar(TQString(attr->value).toInt());
485 KisPaintLayerSP layer = 0;
487 attr = GetImageAttribute(image,
"[layer-name]");
489 layer =
new KisPaintLayer(m_img, attr->value, opacity);
492 layer =
new KisPaintLayer(m_img, m_img -> nextLayerName(), opacity);
498 TQ_INT32 x_offset = 0;
499 TQ_INT32 y_offset = 0;
501 attr = GetImageAttribute(image,
"[layer-xpos]");
503 x_offset = TQString(attr->value).toInt();
506 attr = GetImageAttribute(image,
"[layer-ypos]");
508 y_offset = TQString(attr->value).toInt();
512 for (TQ_UINT32 y = 0; y < image->rows; y ++)
514 const PixelPacket *pp = AcquireCacheView(vi, 0, y, image->columns, 1, &ei);
519 DestroyImageList(images);
520 DestroyImageInfo(ii);
521 DestroyExceptionInfo(&ei);
522 emit notifyProgressError();
523 return KisImageBuilder_RESULT_FAILURE;
526 IndexPacket * indexes = GetCacheViewIndexes(vi);
528 KisHLineIteratorPixel hiter = layer->paintDevice()->createHLineIterator(0, y, image->columns,
true);
530 if (colorspaceType== CMYKColorspace) {
531 if (imageDepth == 8) {
533 while (!hiter.isDone())
535 TQ_UINT8 *ptr= hiter.rawData();
536 *(ptr++) = ScaleQuantumToChar(pp->red);
537 *(ptr++) = ScaleQuantumToChar(pp->green);
538 *(ptr++) = ScaleQuantumToChar(pp->blue);
539 *(ptr++) = ScaleQuantumToChar(indexes[x]);
542 if (image->matte != MagickFalse) {
544 if (image->matte ==
true) {
546 *(ptr++) = OPACITY_OPAQUE - ScaleQuantumToChar(pp->opacity);
549 *(ptr++) = OPACITY_OPAQUE;
557 else if (colorspaceType == LABColorspace) {
558 while(! hiter.isDone())
560 TQ_UINT16 *ptr =
reinterpret_cast<TQ_UINT16 *
>(hiter.rawData());
562 *(ptr++) = ScaleQuantumToShort(pp->red);
563 *(ptr++) = ScaleQuantumToShort(pp->green);
564 *(ptr++) = ScaleQuantumToShort(pp->blue);
565 *(ptr++) = 65535 - ScaleQuantumToShort(pp->opacity);
571 else if (colorspaceType == RGBColorspace ||
572 colorspaceType == sRGBColorspace ||
573 colorspaceType == TransparentColorspace)
575 if (imageDepth == 8) {
576 while(! hiter.isDone())
578 TQ_UINT8 *ptr= hiter.rawData();
580 *(ptr++) = ScaleQuantumToChar(pp->blue);
581 *(ptr++) = ScaleQuantumToChar(pp->green);
582 *(ptr++) = ScaleQuantumToChar(pp->red);
583 *(ptr++) = OPACITY_OPAQUE - ScaleQuantumToChar(pp->opacity);
589 else if (imageDepth == 16) {
590 while(! hiter.isDone())
592 TQ_UINT16 *ptr =
reinterpret_cast<TQ_UINT16 *
>(hiter.rawData());
594 *(ptr++) = ScaleQuantumToShort(pp->blue);
595 *(ptr++) = ScaleQuantumToShort(pp->green);
596 *(ptr++) = ScaleQuantumToShort(pp->red);
597 *(ptr++) = 65535 - ScaleQuantumToShort(pp->opacity);
604 else if ( colorspaceType == GRAYColorspace) {
605 if (imageDepth == 8) {
606 while(! hiter.isDone())
608 TQ_UINT8 *ptr= hiter.rawData();
610 *(ptr++) = ScaleQuantumToChar(pp->blue);
611 *(ptr++) = OPACITY_OPAQUE - ScaleQuantumToChar(pp->opacity);
617 else if (imageDepth == 16) {
618 while(! hiter.isDone())
620 TQ_UINT16 *ptr =
reinterpret_cast<TQ_UINT16 *
>(hiter.rawData());
622 *(ptr++) = ScaleQuantumToShort(pp->blue);
623 *(ptr++) = 65535 - ScaleQuantumToShort(pp->opacity);
631 emit notifyProgress(y * 100 / image->rows);
636 DestroyImageList(images);
637 DestroyImageInfo(ii);
638 DestroyExceptionInfo(&ei);
640 return KisImageBuilder_RESULT_INTR;
643 m_img->addLayer(layer.data(), m_img->rootLayer());
644 layer->paintDevice()->move(x_offset, y_offset);
647 emit notifyProgressDone();
652 emit notifyProgressDone();
653 DestroyImageList(images);
654 DestroyImageInfo(ii);
655 DestroyExceptionInfo(&ei);
656 return KisImageBuilder_RESULT_OK;
659 KisImageBuilder_Result KisImageMagickConverter::buildImage(
const KURL& uri)
662 return KisImageBuilder_RESULT_NO_URI;
664 if (!TDEIO::NetAccess::exists(uri,
false, tqApp -> mainWidget())) {
665 return KisImageBuilder_RESULT_NOT_EXIST;
668 KisImageBuilder_Result result = KisImageBuilder_RESULT_FAILURE;
671 if (TDEIO::NetAccess::download(uri, tmpFile, tqApp -> mainWidget())) {
673 uriTF.setPath( tmpFile );
674 result = decode(uriTF,
false);
675 TDEIO::NetAccess::removeTempFile(tmpFile);
682 KisImageSP KisImageMagickConverter::image()
687 void KisImageMagickConverter::init(KisDoc *doc, KisUndoAdapter *adapter)
694 KisImageBuilder_Result KisImageMagickConverter::buildFile(
const KURL& uri, KisPaintLayerSP layer, vKisAnnotationSP_it annotationsStart, vKisAnnotationSP_it annotationsEnd)
701 return KisImageBuilder_RESULT_INVALID_ARG;
703 KisImageSP img = layer->image();
705 return KisImageBuilder_RESULT_EMPTY;
708 return KisImageBuilder_RESULT_NO_URI;
710 if (!uri.isLocalFile())
711 return KisImageBuilder_RESULT_NOT_LOCAL;
714 TQ_UINT32 layerBytesPerChannel = layer->paintDevice()->pixelSize() / layer->paintDevice()->nChannels();
716 GetExceptionInfo(&ei);
718 ii = CloneImageInfo(0);
720 tqstrncpy(ii -> filename, TQFile::encodeName(uri.path()), MaxTextExtent - 1);
722 if (ii -> filename[MaxTextExtent - 1]) {
723 emit notifyProgressError();
724 return KisImageBuilder_RESULT_PATH;
727 if (!img -> width() || !img -> height())
728 return KisImageBuilder_RESULT_EMPTY;
730 if (layerBytesPerChannel < 2) {
737 ii->colorspace = getColorTypeforColorSpace(layer->paintDevice()->colorSpace());
739 image = AllocateImage(ii);
741 image -> columns = img -> width();
742 image -> rows = img -> height();
744 kdDebug(41008) <<
"Saving with colorspace " << image->colorspace <<
", (" << layer->paintDevice()->colorSpace()->id().name() <<
")\n";
745 kdDebug(41008) <<
"IM Image thinks it has depth: " << image->depth <<
"\n";
749 image -> matte = MagickTrue;
754 image -> matte =
true;
757 TQ_INT32 y, height, width;
759 height = img -> height();
760 width = img -> width();
763 TQString ext = TQFileInfo(TQFile::encodeName(uri.path())).extension(
false).upper();
766 tqstrncpy(ii->magick,
"BMP2", MaxTextExtent - 1);
768 else if (ext ==
"RGB") {
769 tqstrncpy(ii->magick,
"SGI", MaxTextExtent - 1);
772 for (y = 0; y < height; y++) {
775 PixelPacket * pp = SetImagePixels(image, 0, y, width, 1);
778 DestroyExceptionInfo(&ei);
780 emit notifyProgressError();
781 return KisImageBuilder_RESULT_FAILURE;
785 KisHLineIterator it = layer->paintDevice()->createHLineIterator(0, y, width,
false);
787 SetImageType(image, TrueColorMatteType);
789 SetImageType(image, TrueColorType);
791 if (image->colorspace== CMYKColorspace) {
793 IndexPacket * indexes = GetIndexes(image);
795 if (layerBytesPerChannel == 2) {
796 while (!it.isDone()) {
798 const TQ_UINT16 *d =
reinterpret_cast<const TQ_UINT16 *
>(it.rawData());
799 pp -> red = ScaleShortToQuantum(d[PIXEL_CYAN]);
800 pp -> green = ScaleShortToQuantum(d[PIXEL_MAGENTA]);
801 pp -> blue = ScaleShortToQuantum(d[PIXEL_YELLOW]);
803 pp -> opacity = ScaleShortToQuantum(65535 - d[PIXEL_CMYK_ALPHA]);
804 indexes[x] = ScaleShortToQuantum(d[PIXEL_BLACK]);
811 while (!it.isDone()) {
813 TQ_UINT8 * d = it.rawData();
814 pp -> red = ScaleCharToQuantum(d[PIXEL_CYAN]);
815 pp -> green = ScaleCharToQuantum(d[PIXEL_MAGENTA]);
816 pp -> blue = ScaleCharToQuantum(d[PIXEL_YELLOW]);
818 pp -> opacity = ScaleCharToQuantum(OPACITY_OPAQUE - d[PIXEL_CMYK_ALPHA]);
819 indexes[x]= ScaleCharToQuantum(d[PIXEL_BLACK]);
827 else if (image->colorspace== RGBColorspace ||
828 image->colorspace == sRGBColorspace ||
829 image->colorspace == TransparentColorspace)
831 if (layerBytesPerChannel == 2) {
832 while (!it.isDone()) {
834 const TQ_UINT16 *d =
reinterpret_cast<const TQ_UINT16 *
>(it.rawData());
835 pp -> red = ScaleShortToQuantum(d[PIXEL_RED]);
836 pp -> green = ScaleShortToQuantum(d[PIXEL_GREEN]);
837 pp -> blue = ScaleShortToQuantum(d[PIXEL_BLUE]);
839 pp -> opacity = ScaleShortToQuantum(65535 - d[PIXEL_ALPHA]);
846 while (!it.isDone()) {
848 TQ_UINT8 * d = it.rawData();
849 pp -> red = ScaleCharToQuantum(d[PIXEL_RED]);
850 pp -> green = ScaleCharToQuantum(d[PIXEL_GREEN]);
851 pp -> blue = ScaleCharToQuantum(d[PIXEL_BLUE]);
853 pp -> opacity = ScaleCharToQuantum(OPACITY_OPAQUE - d[PIXEL_ALPHA]);
860 else if (image->colorspace == GRAYColorspace)
862 SetImageType(image, GrayscaleMatteType);
863 if (layerBytesPerChannel == 2) {
864 while (!it.isDone()) {
866 const TQ_UINT16 *d =
reinterpret_cast<const TQ_UINT16 *
>(it.rawData());
867 pp -> red = ScaleShortToQuantum(d[PIXEL_GRAY]);
868 pp -> green = ScaleShortToQuantum(d[PIXEL_GRAY]);
869 pp -> blue = ScaleShortToQuantum(d[PIXEL_GRAY]);
871 pp -> opacity = ScaleShortToQuantum(65535 - d[PIXEL_GRAY_ALPHA]);
878 while (!it.isDone()) {
879 TQ_UINT8 * d = it.rawData();
880 pp -> red = ScaleCharToQuantum(d[PIXEL_GRAY]);
881 pp -> green = ScaleCharToQuantum(d[PIXEL_GRAY]);
882 pp -> blue = ScaleCharToQuantum(d[PIXEL_GRAY]);
884 pp -> opacity = ScaleCharToQuantum(OPACITY_OPAQUE - d[PIXEL_GRAY_ALPHA]);
892 kdDebug(41008) <<
"Unsupported image format\n";
893 return KisImageBuilder_RESULT_INVALID_ARG;
896 emit notifyProgressStage(i18n(
"Saving..."), y * 100 / height);
899 if (SyncImagePixels(image) == MagickFalse)
900 kdDebug(41008) <<
"Syncing pixels failed\n";
902 if (!SyncImagePixels(image))
903 kdDebug(41008) <<
"Syncing pixels failed\n";
908 exportAnnotationsForImage(image, annotationsStart, annotationsEnd);
913 WriteImage(ii, image);
914 DestroyExceptionInfo(&ei);
916 emit notifyProgressDone();
917 return KisImageBuilder_RESULT_OK;
920 void KisImageMagickConverter::ioData(TDEIO::Job *job,
const TQByteArray& data)
922 if (data.isNull() || data.isEmpty()) {
923 emit notifyProgressStage(i18n(
"Loading..."), 0);
927 if (m_data.empty()) {
932 ii = CloneImageInfo(0);
933 GetExceptionInfo(&ei);
934 image = PingBlob(ii, data.data(), data.size(), &ei);
936 if (image == 0 || ei.severity == BlobError) {
937 DestroyExceptionInfo(&ei);
938 DestroyImageInfo(ii);
940 emit notifyProgressError();
945 DestroyExceptionInfo(&ei);
946 DestroyImageInfo(ii);
947 emit notifyProgressStage(i18n(
"Loading..."), 0);
950 Q_ASSERT(data.size() + m_data.size() <= m_size);
951 memcpy(&m_data[m_data.size()], data.data(), data.count());
952 m_data.resize(m_data.size() + data.count());
953 emit notifyProgressStage(i18n(
"Loading..."), m_data.size() * 100 / m_size);
959 void KisImageMagickConverter::ioResult(TDEIO::Job *job)
964 emit notifyProgressError();
966 decode(KURL(),
true);
969 void KisImageMagickConverter::ioTotalSize(TDEIO::Job * , TDEIO::filesize_t size)
972 m_data.reserve(size);
973 emit notifyProgressStage(i18n(
"Loading..."), 0);
976 void KisImageMagickConverter::cancel()
985 TQString KisImageMagickConverter::readFilters()
990 TQString description;
991 unsigned long matches;
1005 const MagickInfo *mi;
1007 GetExceptionInfo(&ei);
1008 mi = GetMagickInfo(
"*", &ei);
1009 DestroyExceptionInfo(&ei);
1035 for (; mi; mi =
reinterpret_cast<const MagickInfo*
>(mi -> next)) {
1038 if (mi -> decoder) {
1040 description = mi -> description;
1041 kdDebug(41008) <<
"Found import filter for: " << name <<
"\n";
1043 if (!description.isEmpty() && !description.contains(
'/')) {
1044 all +=
"*." + name.lower() +
" *." + name +
" ";
1045 s +=
"*." + name.lower() +
" *." + name +
"|";
1046 s += i18n(description.utf8());
1053 all +=
"|" + i18n(
"All Images");
1059 TQString KisImageMagickConverter::writeFilters()
1064 TQString description;
1065 unsigned long matches;
1079 const MagickInfo *mi;
1081 GetExceptionInfo(&ei);
1082 mi = GetMagickInfo(
"*", &ei);
1083 DestroyExceptionInfo(&ei);
1087 kdDebug(41008) <<
"Eek, no magick info!\n";
1112 for (; mi; mi =
reinterpret_cast<const MagickInfo*
>(mi -> next)) {
1113 kdDebug(41008) <<
"Found export filter for: " << mi -> name <<
"\n";
1117 if (mi -> encoder) {
1120 description = mi -> description;
1122 if (!description.isEmpty() && !description.contains(
'/')) {
1123 all +=
"*." + name.lower() +
" *." + name +
" ";
1124 s +=
"*." + name.lower() +
" *." + name +
"|";
1125 s += i18n(description.utf8());
1133 all +=
"|" + i18n(
"All Images");
1139#include "kis_image_magick_converter.moc"