I did as you told me... but nothing changed
Code: Select all
int rotation = 0;
int w1 = (int)img.size.width;
int h1 = (int)img.size.height;
w1 = (w1%2) == 0?w1:w1+1;
h1 = (h1%2) == 0?h1:h1+1;
int cx = (int)floor((img.size.width + 1) / 2.0);
int cy = (int)floor((img.size.height + 1) / 2.0);
int d1 = MAX(w1, h1);
float fd1 = rotation * M_PI / d1;
float sinang = sin(rotation * M_PI / 180);
float cosang = cos(rotation * M_PI / 180);
float qnoise = 0.0;
char *input_image = strdup([[[NSBundle mainBundle] pathForResource:@"test" ofType:@"png"] UTF8String]);
char *output_image = strdup([[[NSBundle mainBundle] pathForResource:@"test_out" ofType:@"png"] UTF8String]);
char *tmp_img1 = strdup([[[NSBundle mainBundle] pathForResource:@"tmp_img1" ofType:@"png"] UTF8String]);
char size[32];
char tmp1[128];
char tmp2[32];
char tmp3[1024];
char tmp4[1024];
char tmp5[1024];
char tmp6[1024];
char tmp7[128];
sprintf(size, "%dx1", w1);
sprintf(tmp1, "\"zz=%f*(i-%d)*%f; zz?sin(zz)/(zz):1\"", fd1, cx, cosang);
sprintf(tmp2, "%dx%d!", w1, h1);
char *argv1[] = { "convert", "-size", size, "xc:", "-fx", tmp1, "-scale", tmp2, tmp_img1, NULL };
ImageInfo *imageInfo = AcquireImageInfo();
ExceptionInfo *exceptionInfo = AcquireExceptionInfo();
status = ConvertImageCommand(imageInfo, 9, argv1, NULL, exceptionInfo);
if (status == MagickFalse)
{
NSLog(@"Error in first call");
}
sprintf(tmp3, "(%s -alpha off +fft )", input_image);
sprintf(tmp4, "%f", qnoise);
sprintf(tmp5, "( -clone 0 %s -compose multiply -composite )", tmp_img1);
sprintf(tmp6, "( -clone 1 %s -compose multiply -composite )", tmp_img1);
sprintf(tmp7, "%dx%d+0+0", w1, h1);
char *argv2[] = { "convert", "(", input_image, "-alpha", "off", "+fft", ")",
"(", tmp_img1, tmp_img1, "-compose", "multiply", "-composite", "-evaluate", "add", tmp4, ")",
"(", "-clone", "0", tmp_img1, "-compose", "multiply", "-composite", ")",
"(", "-clone", "1", tmp_img1, "-compose", "multiply", "-composite", ")",
"(", "-clone", "3", "-clone", "2", "+swap", "-compose", "divide", "-composite", ")",
"(", "-clone", "4", "-clone", "2", "+swap", "-compose", "divide", "-composite", ")",
"-delete", "0-4", "+ift", "-crop", tmp7, "+repage", output_image, NULL };
status = ConvertImageCommand(imageInfo, 60, argv2, NULL, exceptionInfo);
So status is MagickFalse after both calls of ConvertImageCommand moreover original and final images still same.