G
garethrichardadams
Hello all,
I've got a user control I've created called canvas. Doesn't do much at
the moment.
I've set the background image to a small bitmap using BackgroundImage
and I've set it to tiled using BackgroundImageLayout =
ImageLayout.Tiled.
It all works - I get a tiled image.
What I'd like to do now is save the tiled image (i.e. exactly what I
can see in the window) to disk. The closest I can get is to save the
non-tiled image by referring to BackgroundImage but this isn't much
help!!
Can anyone point me in the right direction? Thanks
gareth
Rectangle areaToSave = new Rectangle();
areaToSave = canCanvas.ClientRectangle;
Bitmap imageToSave = new Bitmap(areaToSave.Width, areaToSave.Height);
Graphics g = Graphics.FromImage(imageToSave);
g.DrawImage(canCanvas.BackgroundImage, areaToSave, areaToSave,
GraphicsUnit.Pixel);
imageToSave.Save(fileName, imageFormatToSave);
g.Dispose();
imageToSave.Dispose();
I've got a user control I've created called canvas. Doesn't do much at
the moment.
I've set the background image to a small bitmap using BackgroundImage
and I've set it to tiled using BackgroundImageLayout =
ImageLayout.Tiled.
It all works - I get a tiled image.
What I'd like to do now is save the tiled image (i.e. exactly what I
can see in the window) to disk. The closest I can get is to save the
non-tiled image by referring to BackgroundImage but this isn't much
help!!
Can anyone point me in the right direction? Thanks
gareth
Rectangle areaToSave = new Rectangle();
areaToSave = canCanvas.ClientRectangle;
Bitmap imageToSave = new Bitmap(areaToSave.Width, areaToSave.Height);
Graphics g = Graphics.FromImage(imageToSave);
g.DrawImage(canCanvas.BackgroundImage, areaToSave, areaToSave,
GraphicsUnit.Pixel);
imageToSave.Save(fileName, imageFormatToSave);
g.Dispose();
imageToSave.Dispose();