用 imagemagick 进行负乘?

发布于 2024-12-09 14:14:18 字数 218 浏览 0 评论 0原文

有谁知道Photoshop图层合成模式是否可以“负乘”?

乘法是可能的,但我需要负的方式。

MagickBooleanType aStat = MagickCompositeImage(magick_wand_local, magick_wand_local_comp, MultiplyCompositeOp, 0, 0);   

谢谢

Does anyone know if it's possible to do the Photoshop layer composite mode "negative multiply"?

Multiply is possible, but i need the negative way.

MagickBooleanType aStat = MagickCompositeImage(magick_wand_local, magick_wand_local_comp, MultiplyCompositeOp, 0, 0);   

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

水水月牙 2024-12-16 14:14:18

好的。我自己找到的。

它被称为:ScreenCompositeOp

一些示例代码(未清理!):

    CGImageRef standardized = srcCGImage; //createStandardImage(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 = "ARGB"; // hard coded
    const StorageType inputStorage = CharPixel;

    NSData *srcData = (NSData *) CGDataProviderCopyData(CGImageGetDataProvider(standardized));

    const void *bytes = [srcData bytes];
    MagickWandGenesis();
    MagickWand * magick_wand_local= NewMagickWand();
    MagickBooleanType status = MagickConstituteImage(magick_wand_local, width, width, map, inputStorage, bytes);
    if (status == MagickFalse) {
        ThrowWandException(magick_wand_local);
    }    
    /*
     status = MagickOrderedPosterizeImage(magick_wand_local, "h8x8o");
     if (status == MagickFalse) {
     ThrowWandException(magick_wand_local);
     }
     */

    //status = MagickThresholdImage(magick_wand_local, 100.0);

    MagickWand * magick_wand_local_comp = NewMagickWand();
    NSString *file = @"winter_over.jpg";
    if(export == YES) {
        file = @"winter_over_large.jpg";
    }

    if(MagickReadImage(magick_wand_local_comp,[[[NSBundle mainBundle] pathForResource:file ofType:@""] UTF8String]) == MagickFalse) {
        ExceptionType severity;
        char *err = MagickGetException(magick_wand_local_comp, &severity);
        printf("%s\n",err);
        NSLog(@"error");
    }

    MagickBooleanType aStat = MagickCompositeImage(magick_wand_local, magick_wand_local_comp, ScreenCompositeOp, 0, 0);    
    if(aStat == MagickFalse) {
        NSLog(@"error");
    }

    status = MagickModulateImage(magick_wand_local, 100, 29, 100);



    if (status == MagickFalse) {
        ThrowWandException(magick_wand_local);
    }

    const int bitmapBytesPerRow = (width * strlen(map));
    const int bitmapByteCount = (bitmapBytesPerRow * height);
    CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
    char *trgt_image = malloc(bitmapByteCount);
    status = MagickExportImagePixels(magick_wand_local, 0, 0, width, height, map, CharPixel, trgt_image);
    if (status == MagickFalse) {
        ThrowWandException(magick_wand_local);
    }
    magick_wand_local = DestroyMagickWand(magick_wand_local);
    magick_wand_local_comp = DestroyMagickWand(magick_wand_local_comp);
    MagickWandTerminus();
    CGContextRef context = CGBitmapContextCreate (trgt_image,
                                                  width,
                                                  height,
                                                  8, // bits per component
                                                  bitmapBytesPerRow,
                                                  colorSpace,
                                                  kCGImageAlphaPremultipliedFirst);
    CGColorSpaceRelease(colorSpace);

Okay. Found it myself.

It's called: ScreenCompositeOp

Some sample code (not cleaned!):

    CGImageRef standardized = srcCGImage; //createStandardImage(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 = "ARGB"; // hard coded
    const StorageType inputStorage = CharPixel;

    NSData *srcData = (NSData *) CGDataProviderCopyData(CGImageGetDataProvider(standardized));

    const void *bytes = [srcData bytes];
    MagickWandGenesis();
    MagickWand * magick_wand_local= NewMagickWand();
    MagickBooleanType status = MagickConstituteImage(magick_wand_local, width, width, map, inputStorage, bytes);
    if (status == MagickFalse) {
        ThrowWandException(magick_wand_local);
    }    
    /*
     status = MagickOrderedPosterizeImage(magick_wand_local, "h8x8o");
     if (status == MagickFalse) {
     ThrowWandException(magick_wand_local);
     }
     */

    //status = MagickThresholdImage(magick_wand_local, 100.0);

    MagickWand * magick_wand_local_comp = NewMagickWand();
    NSString *file = @"winter_over.jpg";
    if(export == YES) {
        file = @"winter_over_large.jpg";
    }

    if(MagickReadImage(magick_wand_local_comp,[[[NSBundle mainBundle] pathForResource:file ofType:@""] UTF8String]) == MagickFalse) {
        ExceptionType severity;
        char *err = MagickGetException(magick_wand_local_comp, &severity);
        printf("%s\n",err);
        NSLog(@"error");
    }

    MagickBooleanType aStat = MagickCompositeImage(magick_wand_local, magick_wand_local_comp, ScreenCompositeOp, 0, 0);    
    if(aStat == MagickFalse) {
        NSLog(@"error");
    }

    status = MagickModulateImage(magick_wand_local, 100, 29, 100);



    if (status == MagickFalse) {
        ThrowWandException(magick_wand_local);
    }

    const int bitmapBytesPerRow = (width * strlen(map));
    const int bitmapByteCount = (bitmapBytesPerRow * height);
    CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
    char *trgt_image = malloc(bitmapByteCount);
    status = MagickExportImagePixels(magick_wand_local, 0, 0, width, height, map, CharPixel, trgt_image);
    if (status == MagickFalse) {
        ThrowWandException(magick_wand_local);
    }
    magick_wand_local = DestroyMagickWand(magick_wand_local);
    magick_wand_local_comp = DestroyMagickWand(magick_wand_local_comp);
    MagickWandTerminus();
    CGContextRef context = CGBitmapContextCreate (trgt_image,
                                                  width,
                                                  height,
                                                  8, // bits per component
                                                  bitmapBytesPerRow,
                                                  colorSpace,
                                                  kCGImageAlphaPremultipliedFirst);
    CGColorSpaceRelease(colorSpace);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文