Cut out image in shape of text

后端 未结 6 2065
小鲜肉
小鲜肉 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:57

    Use GlyphVector. Use Font class

    public GlyphVector layoutGlyphVector(FontRenderContext frc,
                                             char[] text,
                                             int start,
                                             int limit,
                                             int flags) {
    

    You can get outline Shape from glyph vector by public abstract Shape getOutline()

    Assign the outline Shape as a clip to your Graphics instance.

    Draw the image on the graphics.

    Only clipped shape will be filled.

提交回复
热议问题