Page 1 of 1

Magickwand and Delphi 2009

Posted: 2009-05-03T09:50:55-07:00
by firstfriday
Hello,
has anybody used delphi2009 and Magickwand? I cannot get it working.
The MagickReadImage function return 0 and the error description returns just unreadable characters.
Has somebody an idea?
Thanks
edgar

Code: Select all

//uses  ImageMagick,magick_wand,
// wrapper from http://sourceforge.net/project/showfiles.php?group_id=92177&package_id=174103&release_id=431432

procedure TfrmPicDialog.aclTestExecute(Sender: TObject);
var
  status: MagickBooleanType;
  wand: PMagickWand;

  procedure ThrowWandException(wand: PMagickWand);
  var
    description: PChar;
    severity: ExceptionType;
  begin
    description := MagickGetException(wand, @severity);
    showmessage(Format('An error ocurred. Description: %s', [description]));
    description := MagickRelinquishMemory(description);
    Abort;
  end;

begin
  MagickWandGenesis;
  wand := NewMagickWand;
  try
    status := MagickReadImage(wand,'image.png');
    if (status = MagickFalse) then ThrowWandException(wand);
    MagickResetIterator(wand);
    while (MagickNextImage(wand) <> MagickFalse) do
     MagickResizeImage(wand, 106, 80, LanczosFilter, 1.0);
    status := MagickWriteImages(wand, 'image.jpg', MagickTrue);
    if (status = MagickFalse) then ThrowWandException(wand);
  finally
    wand := DestroyMagickWand(wand);
    MagickWandTerminus;
  end;
end;

Re: Magickwand and Delphi 2009

Posted: 2009-05-03T10:44:07-07:00
by firstfriday
Found out myself. the wrapper works with char since d2009 works with widechar by default all calls must be ansichar.