ImageMagick, for fancy billedbehandlig.
ImageMagick for Delphi & varianter ligger her:
http://sourceforge.net/project/showfiles.php?group_id=92177&package_id=174103&release_id=431432
Se også:
http://wiki.lazarus.freepascal.org/PascalMagick
Alle API kall ligger beskrevet her:
http://imagemagick.org/script/magick-wand.php
uses DFCreatorPilot3Lib_TLB, Magick_wand, ImageMagick; procedure ThrowWandException(wand: PMagickWand); var description : PChar; severity : ExceptionType; begin description:= MagickGetException(wand, @severity); MessageBox(Form1.Handle, PChar(Format('An error ocurred. Description: %s', [description])), 'ImageMagick', 0); MagickRelinquishMemory(description); end; var wand : PMagickWand; pixelwand : PPixelWand; status : MagickBooleanType; begin MagickWandGenesis; // Some bugs here... wand:= NewMagickWand; pixelwand:= NewPixelWand; PixelSetColor(pixelwand, 'white'); status:= MagickNewImage(wand, newwidth, newheight, pixelwand); if status = MagickFalse then ThrowWandException(wand); DestroyPixelWand(pixelwand); // Even more bugs here... MagickWandTerminus; end;
begin status:= MagickReadImage(wand, 'bilde.jpg'); if status = MagickFalse then ThrowWandException(wand); end;
begin status:= MagickCompositeImage(wand, tempwand, AtopCompositeOp, x-pos, y-pos); if status = MagickFalse then ThrowWandException(wand); end;
begin status:= MagickCropImage(wand, width, height, x-pos, y-pos); if status = MagickFalse then ThrowWandException(wand); end;
begin status:= MagickTrimImage(wand, 0); if status = MagickFalse then ThrowWandException(wand); end;
begin status:= MagickScaleImage(wand, new-width, new-height); if status = MagickFalse then ThrowWandException(wand); // Andre muligheter: // status:= MagickResizeImage(wand, new-width, new-height, LanczosFilter, 0); // status:= MagickSampleImage(wand, new-width, new-height); end;
begin if IsMagickWand(wand) = MagickTrue then DestroyMagickWand(wand); end;
http://www.colorpilot.com/pdflibrary.html
var wand : PMagickWand; status : MagickBooleanType; PDF : TPDFDocument3; // Not tested on TPDFDocument4, should be the same... t : integer; b : pointer; l : cardinal; begin status:= MagickSetImageFormat(wand, 'png'); if status = MagickFalse then ThrowWandException(wand); status:= MagickSetImageCompression(wand, NoCompression); if status = MagickFalse then ThrowWandException(wand); // Må legges til i magick_image.inc: // function MagickWriteImageBlob(wand: PMagickWand; var length: Cardinal): Pointer; cdecl; external WandExport; b:= MagickWriteImageBlob(wand, l); t:= PDF.AddImageFromMemory(b, l, itcJpeg); MagickRelinquishMemory(b); if t = -1 then 'Handle some PDF Creator Error!' else PDF.PDFPAGE_ShowImage(t, x-pos, y-pos, width, height, 0); end;
begin // cropwand:= NewMagickWand; cropwand:= CloneMagickWand(wand); if status = MagickFalse then ThrowWandException(cropwand); end;
begin status:= MagickSetImageCompressionQuality(wand, 50); if status = MagickFalse then ThrowWandException(wand); status:= MagickWriteImage(wand, PChar('nyttbilde.jpg')); if status = MagickFalse then ThrowWandException(wand); end;