Recently, texturebrush in GDI + is used. However, when fillrectangle is used, there is always an offset problem, for example, the following:
The original video clip should be:
The following is my source generation. I will analyze the cause and solution of this problem step by step.
Image logo = image. fromfile ("your picture path ");
Texturebrush BR = new texturebrush (logo );
Graphics G = This. creategraphics ();
G. fillrectangle (BR, 22, 29, 20, 20 );
The cause is 22, 29 in G. fillrectangle (BR, 22, 29, 20, 20. Originally, I think 22 and 29 are used to determine the corresponding position (x, y) of the image to be displayed in the form, but when texturebrush is used (22, 29). The exact position is not specified, and the offset of the split is determined. If you convert it into another number, the offset of the video segment will change. Set G. fillrectangle (BR, 22, 29, 20, 20); change to G. fillrectangle (BR, 0, 0, 20, 20); The Cursor Image is normal, but its position is (0, 0 ), so I guess it is correct.
Solution:
Image logo = image. fromfile ("D: // epon_ EMS // image // green.png ");
Texturebrush BR = new texturebrush (logo );
BR. translatetransform (22, 29 );
Graphics G = liu1.creategraphics ();
G. fillrectangle (BR, 22, 29, 20, 20 );
Add a Br. translatetransform (22, 29); That's OK. translatetransform is used to offset the starting position of the original portrait, so that we offset it first, then, in fillrectangle, it was offset again, so the order was reached our goal.