Page 1 of 1

About API description!!

Posted: 2011-01-19T22:26:45-07:00
by diuming
About API description??

Re: About API description!!

Posted: 2011-01-19T22:44:41-07:00
by anthony
API just means "Application Programming Interface"

So the question becomes... What API are you refering to?

All the API's are listed on the offical website, though many just refer to another API for the function list.

Re: About API description!!

Posted: 2011-01-20T00:05:57-07:00
by diuming
Dear Master,

I know that about API.

I encountered a big problem When I using MagickCore and MagickWand's C API.
Sometimes I do not understand function and argument's descriptions (It's not clear), So I have to post a question again again again and again!!

For example, I try to compose 4 channel image (c.jpg, m.jpg, y.jpg, k.jpg) into signal file (result_cmyk.jpg), But I still not success.

.
.
MagickWand * srcImageC, * srcImageM, * srcImageY, * srcImageK, * destImage;

MagickWandGenesis();

/*
* Create the winds
*/
srcImageC = NewMagickWand();
srcImageM = NewMagickWand();
srcImageY = NewMagickWand();
srcImageK = NewMagickWand();
destImage = NewMagickWand();

MagickReadImage(srcImageC, "c.jpg");
MagickReadImage(srcImageM, "m.jpg");
MagickReadImage(srcImageY, "y.jpg");
MagickReadImage(srcImageK, "k.jpg");


MagickSetSizeOffset(destImage, columns, rows, 0);
MagickSetSize(destImage, columns, rows);
MagickSetColorspace(destImage, CMYKColorspace); // The result image file always RGB
MagickSetImageResolution(destImage, 360, 360);
MagickSetImageUnits(destImage, PixelsPerInchResolution);

MagickBooleanType status;
status = MagickCompositeImageChannel(destImage, CyanChannel , srcImageC, CopyOpacityCompositeOp , 0, 0); //false
status = MagickCompositeImageChannel(destImage, MagentaChannel , srcImageM, CopyOpacityCompositeOp , 0, 0); //false
status = MagickCompositeImageChannel(destImage, YellowChannel , srcImageY, CopyOpacityCompositeOp , 0, 0); //false
status = MagickCompositeImageChannel(destImage, BlackChannel , srcImageK, CopyOpacityCompositeOp , 0, 0); //false
//I try to use combine, but still false

NSLog(@"Status : %i", status); // always get MagickFalse
if (status == MagickFalse)
ThrowWandException(destImage);

MagickWriteImage(destImage, "result_cmyk.jpg"); ///No image output

/*
* tidy up
*/
if (srcImageC) srcImageC = DestroyMagickWand(srcImageC);
if (srcImageM) srcImageM = DestroyMagickWand(srcImageM);
if (srcImageY) srcImageY = DestroyMagickWand(srcImageY);
if (srcImageK) srcImageK = DestroyMagickWand(srcImageK);
if (destImage) destImage = DestroyMagickWand(destImage);

MagickWandTerminus();
.
.

Sorry about that, Maybe my composite concept is incorrect.

Thanks for ImageMagick provides useful image processing tool.
Thanks alot.

Diuming

Re: About API description!!

Posted: 2011-01-20T05:24:32-07:00
by anthony
diuming wrote:For example, I try to compose 4 channel image (c.jpg, m.jpg, y.jpg, k.jpg) into signal file (result_cmyk.jpg), But I still not success.
You can NOT store multiple files into a JPG file. The File format simply does not allow for it!
As such it will automatically save the image into seperate files with a number which starts with zero.

See IM Examples, File Handling, Writing a Multi-Image Sequence - Adjoin Techniques
http://www.imagemagick.org/Usage/files/#adjoin

However it appears by the code you are not wanting that, but want ot combine the images.

Lokking in the source for "wand/mogrify.c" (for command line API) I find that "combine" option calles the MagickCore library function

Code: Select all

image = CombineImages(*images,channel,exception)
A search for header "*.h" files in magick source sub-directory I find this function in "magick/image.h"
as such the function is defined in "magick/image.c"

Its documentation can thus be found in the MagickCore "Image Methods"
http://www.imagemagick.org/api/image.php#CombineImages

However creating a CMYK image (or any other non-RGB colorspace image) from RGB greyscale images requires you to first set the greyscale images to the right colorspace (the "image->type" structure element in the "Image" structure, just as you would when performing the same operation from the command line API.

That is as shown in -- Combining non-RGB image channels
http://www.imagemagick.org/Usage/channe ... bine_other

The exact code I can not give you, without doing EVERYTHING. But the method and order is the same as for the command line API, and the coding sequence is clear.

Re: About API description!!

Posted: 2011-01-20T06:11:00-07:00
by diuming
I got it. thanks!

Diuming