The Transform
property of a graphics object is exactly that, a property. It does not take any action but only tells the graphics object how it should draw images.
So what you want to do is set the Transform
property on the graphics object that you are drawing onto - in this case it should be applied to your gBackground
object, like so...
gBackground.Transform = matrix;
then when you come round to calling the DrawImage
method on the gBackground
object, it will take into account the Transform
property that you have applied.
Keep in mind that this property change will persist through all subsequent DrawImage
calls so you may need to reset it or change the value before doing any more drawing (if you even need to)
To be extra clear, your final code should look like this...
// Just need one graphics
var gBackground = Graphics.FromImage(b);
// Apply transform to object to draw on
var matrix = new Matrix();
matrix.Rotate(30);
gBackground.Transform = matrix;
// Write the first in the second
gBackground.DrawImage(h, 200, 0, 170, 170);