[DUG] Image Magick examples
Todd Martin
toddm at kol.co.nz
Thu Apr 20 07:55:03 NZST 2006
Hi Phil
I've only just started looking at Image Magic myself.
Try this :)
You'll need to add a correction and a function declaration to
"pixel_iterator.inc" as outlined below.
uses
magick_wand, ImageMagick;
procedure DrawDiagonalLine(AInputFileName, AOutputFileName : AnsiString);
var
Iterator : PPixelIterator;
PixelWands : PPPixelWand;
ImageWand : PMagickWand;
Status : MagickBooleanType;
RowIndex, WandCount : Cardinal;
begin
Iterator := nil;
ImageWand := nil;
try
ImageWand := NewMagickWand;
status := MagickReadImage(ImageWand,PChar(AInputFileName));
if (status = MagickTrue) then
begin
//use a pixel iterator to draw a diagonal line
Iterator:=NewPixelIterator(ImageWand);
if assigned(Iterator) then
begin
//return the next row as an array of pixel wands
PixelWands:=PixelGetNextIteratorRow(Iterator,WandCount);
RowIndex := 0;
while assigned(PixelWands) do
begin
inc(PixelWands,RowIndex); //move to the pixel wand at column=row
PixelSetColor(PixelWands^,'#224466');
PixelSyncIterator(Iterator);
PixelWands:=PixelGetNextIteratorRow(Iterator,WandCount);
inc(RowIndex);
end;
end;
MagickWriteImage(ImageWand,PChar(AOutputFileName));
end;
finally
DestroyPixelIterator(Iterator);
DestroyMagickWand(ImageWand);
end;
end;
initialization
MagickWandGenesis;
finalization
MagickWandTerminus;
....and put the following in pixel_iterator.inc
//****correction*****
function NewPixelIterator(wand: PMagickWand): PPixelIterator; cdecl; external
WandExport;
//****extra declaration****
function PixelGetNextIteratorRow(iterator: PPixeliterator; var columnCount :
Cardinal) : PPPixelWand; cdecl; external WandExport;
I compiled this in Kylix. Let me know if you have any problems.
Todd.
On Wednesday 19 Apr 2006 03:54, Phil Middlemiss wrote:
> Yeah, I've got the source and looked through the API.
>
> >From what I can see of the API though, it jumps straight down into the
> > fine details of documenting each method and doesn't have anything that
> > tells you "This is the general approach to use".
>
> For example, I see that there is a routine called MagickSetFirstIterator
> (among other iteration routines) but nowhere does it describe the way to
> set up an iteration, or even what you are iterating. There is a pixel wand
> too (and a pixel iterator), but I can't find anything that describes the
> overall method of using them.
>
> Have you got any examples (I don't care if they are not documented) that I
> could look at?
>
> Cheers,
> Phil.
>
> Todd Martin wrote:
> Hi Phil
>
> Have you looked at the API documents?
> {myInstallDirectoryForImageMagic}/share/doc/ImageMagick-6.2.6/www/api
>
> Are you running Windows or Linux? Do you have the ImageMagic source or just
> a binary download?
>
> Todd.
>
> On Wednesday 19 Apr 2006 02:39, Phil Middlemiss wrote:
>
>
> Hi all,
>
> I'm trying to understand Image Magick - I have got the Lazerus headers
> and compiled and run the sample app listed on the wiki page for it. All
> fine.
>
> Now when it comes to actually working out how to use the thing I'm not
> sure how to go about it. The documentation is a little different from
> the actual Lazerus files, and even if it were the same it is lacking the
> whole "This is the overview/paradigm" section.
>
> What I really need is a good example that does more than just read in an
> image and save it to another format. Does anyone has some
> examples/documentation that they are willing to share?
>
> Cheers,
> Phil.
>
>
> _______________________________________________
> Delphi mailing list
> Delphi at ns3.123.co.nz
> http://ns3.123.co.nz/mailman/listinfo/delphi
More information about the Delphi
mailing list