In return, python rub goddess heat to help send the circle of friends. The avatar is divided into nine palaces in Java, and then the puzzle avatar is generated

preface:

In the evening, I brush a circle of friends. It's interesting to see such a circle of friends, as follows:

So, after I clicked the article, I probably read the meaning of the article. In fact, it is to divide a picture into nine palaces, that is, fragments of the puzzle. Since Python can be implemented, Java can also be implemented in response.

Then, for a moment, I sorted out my ideas. Immediately open the idea and start coding, and there is this article.

Implementation of a number:

Divide a complete picture into 9 small pictures and make them into pictures of the nine squares of the circle of friends, so as to expose different beauty in the circle of friends.

My additional implementation:

Will be divided into nine small pictures, in the generation of a jigsaw puzzle avatar picture.

Final effect:

Main ideas:

1. The length and width of a bufferedimage to be drawn are 1 / 3 of the original image

2. Using graphics, select the area of the original drawing by the offset

3. After drawing, you can output to a file

4. Draw all pictures of 9 positions through two-layer loop

5. Nine puzzle pieces will be generated for image synthesis

Implementation code:

1. Generate puzzle pieces

The specific example code is as follows:

2. Using the generated puzzle fragments to synthesize avatar pictures

The specific example code is as follows:

The whole process is divided into two parts:

1. Convert, cut, and save pictures

2. Cut picture to synthesize new picture

Experience:

Finally, we find a picture to test. For example, I put the source file in the picture folder on disk D, as shown below:

1. First, Mr. run into a jigsaw puzzle picture, that is, the fragments of the Jiugong grid. The results are shown in the figure below:

From the screenshot, we can see that our pictures are cut accurately and are square, so take this code and use it.

2. Synthesize nine jigsaw puzzles into a picture avatar, and run the second class in the. The results are as follows:

last

The above is a process of generating puzzle fragments and then generating puzzle avatars. Interested friends, don't you hurry to try?

If you like it, click "watching" and share it with more friends!

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
分享
二维码
< <上一篇
下一篇>>