Android implements the example code of generating pictures with text

This paper introduces the example code of Android to generate pictures with words, which is shared with you as follows:

design sketch

Let's take a look at the effect picture first. We can see that the following picture is spliced by "beauty" words of various colors to form a different picture.

principle

The principle of generating this kind of picture is very simple, but I couldn't understand it when looking at the open source project at that time, because I didn't learn python, but after careful study, I can finally slowly understand the source code of the open source project and rewrite it into the source code of Android platform. The main contents of the algorithm are described below. The general principle of the algorithm is as follows:

1. Create a blank picture according to the size of the original picture and the font size

2. Divide the original picture into several blocks according to the font size, and take the average value of the color of the pixels in each block

3. Draw the specified text in the average color on the new blank map

Related links

Referenced open source projects: https://github.com/xlzd/img2html

Complete Android Code: https://github.com/luoyesiqiu/textImg

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>