It could be due to the transformation.
Here is a simple solution to do what you want.
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
pictureBox1.MaximumSize = pictureBox1.Size;
LoadBitmap();
}
private void LoadBitmap()
{
bitmap = new Bitmap("test image.jpg");
pictureBox1.Image = bitmap;
}
private Bitmap bitmap;
public Bitmap RotateImage(Bitmap bmp)
{
bmp.RotateFlip(RotateFlipType.Rotate90FlipNone);
return new Bitmap(bmp);
}
private void OnRotateClick(object sender, EventArgs e)
{
bitmap = RotateImage(bitmap);
pictureBox1.Image = bitmap;
}
private void OnAddTextClick(object sender, EventArgs e)
{
string txt = "test text";
Font fnt = DefaultFont;
SolidBrush myBrush = new(Color.AliceBlue);
PointF pnt = new(5f, bitmap.Height - fnt.Height - 5f);
Graphics g = Graphics.FromImage(bitmap);
g.DrawString(txt, fnt, myBrush, pnt.X, pnt.Y);
pictureBox1.Image = bitmap;
}
}
NOTES:
* I am keeping a base reference to the loaded image and working with that. The PictureBox is given a reference to it.
* After I rotate the image, I return a copy, removing any transformation information. If I don't the text won't print at 90-degree & 270-degree angles.