Photoshop multiply effect

The MagickWand interface is a new high-level C API interface to ImageMagick core methods. We discourage the use of the core methods and encourage the use of this API instead. Post MagickWand questions, bug reports, and suggestions to this forum.
Post Reply
gsalent
Posts: 1
Joined: 2012-04-26T11:13:10-07:00
Authentication code: 13

Photoshop multiply effect

Post by gsalent » 2012-04-26T11:21:21-07:00

Hi, i have a question...
i want replicate the Photoshp Multiply effect with image magick.
I use the image magick library (c++) on my iphone app.
For this my request i use this my example but I not see my goal..

Code: Select all

    CGImageRef srcCGImage = createStandardImage(aSourceImage.CGImage);
    int width = CGImageGetWidth(srcCGImage);
	int height = CGImageGetHeight(srcCGImage);
	// could use the image directly if it has 8/16 bits per component,
	// otherwise the image must be converted into something more common (such as images with 5-bits per component)
	// here we’ll be simple and always convert
	const char *map = MAP_FILTER_TYPE; // hard coded
	const StorageType inputStorage = CharPixel;
	CGImageRef standardized = createStandardImage(srcCGImage);
	NSData *srcData = (NSData *) CGDataProviderCopyData(CGImageGetDataProvider(standardized));
	CGImageRelease(standardized);
	const void *bytes = [srcData bytes];
    
    MagickWand *mw = NewMagickWand();
    MagickWandGenesis();
    MagickBooleanType status = MagickConstituteImage(mw, width, width, map, inputStorage, bytes);
    
    MagickWand *mwc = CloneMagickWand(mw);
	MagickWand *mwf = MagickFxImage(mwc,"A");
	MagickSetImageAlphaChannel(mwf,DeactivateAlphaChannel);
	MagickBlurImage(mwf,0,2);
	MagickShadeImage(mwf,MagickTrue,0,90);
	MagickNormalizeImage(mwf);
	MagickBlurImage(mwf,0,2);
	MagickNegateImage(mwf,MagickFalse);
	MagickEvaluateImage(mwf,MultiplyEvaluateOperator,1.0);
	MagickNegateImage(mwf,MagickFalse);
	MagickRollImage(mwf,-.5,-1);
	MagickCompositeImage(mwf,mw,MultiplyCompositeOp,0,0);
	MagickCompositeImage(mw,mwf,InCompositeOp,0,0);
	
    const int bitmapBytesPerRow = (width * strlen(map));
    const int bitmapByteCount = (bitmapBytesPerRow * height);
    CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
    char *trgt_image = malloc(bitmapByteCount);
    status = MagickExportImagePixels(mw, 0, 0, width, height, map, CharPixel, trgt_image);
    
    /*
     if (status == MagickFalse) {
     ThrowWandException(magick_wand_local);
     }
     */
    if(mw)mw = DestroyMagickWand(mw);
	if(mwc)mwc = DestroyMagickWand(mwc);
	if(mwf)mwf = DestroyMagickWand(mwf);
    MagickWandTerminus();
    CGContextRef context = CGBitmapContextCreate (trgt_image,
                                                  width,
                                                  height,
                                                  8, // bits per component
                                                  bitmapBytesPerRow,
                                                  colorSpace,
                                                  kCGImageAlphaPremultipliedFirst);
    
    CGColorSpaceRelease(colorSpace);
	CGImageRef cgimage = CGBitmapContextCreateImage(context);
	UIImage *image = [[UIImage alloc] initWithCGImage:cgimage];
	CGImageRelease(cgimage);
	CGContextRelease(context);
	[srcData release];
	free(trgt_image);
	return image;
What change i in my code?
Tnx to all!

User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Photoshop multiply effect

Post by anthony » 2012-05-08T21:08:14-07:00

What is a photoshop 'multiply' effect?

Sounds like the 'multipy' compose method, but I could be wrong.
We are not all photoshop users. I think I only used photoshop once - ever and not for any real length of time!
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/

Post Reply