Cut out image in shape of text

后端 未结 6 2070
小鲜肉
小鲜肉 2020-11-22 11:15

I need to cut out an image in the shape of the text in another image. I think it\'s best shown in images.

This is a photo of a cat:

6条回答
  •  一个人的身影
    2020-11-22 11:59

    You can do it in Java with just a few lines of source code, using Marvin Framework

    enter image description here

    source code:

    public class CutAndFill {
        public static void main(String[] args) {
            // 1. Load images
            MarvinImage catImage = MarvinImageIO.loadImage("./res/catImage.jpg");
            MarvinImage catText = MarvinImageIO.loadImage("./res/catText.png");
    
            // 2. Load plug-in, set parameters and process de image
            MarvinImagePlugin combine = MarvinPluginLoader.loadImagePlugin("org.marvinproject.image.combine.combineByMask");
            combine.setAttribute("combinationImage", catImage);
            combine.setAttribute("colorMask", Color.black);
            combine.process(catText.clone(), catText);
    
            // 3. Save the output image.
            MarvinImageIO.saveImage(catText, "./res/catOut.jpg");
        }
    }
    

提交回复
热议问题