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 BackgroundImage Layout =
ImageLayout.Til ed.
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.Clien tRectangle;
Bitmap imageToSave = new Bitmap(areaToSa ve.Width, areaToSave.Heig ht);
Graphics g = Graphics.FromIm age(imageToSave );
g.DrawImage(can Canvas.Backgrou ndImage, areaToSave, areaToSave,
GraphicsUnit.Pi xel);
imageToSave.Sav e(fileName, imageFormatToSa ve);
g.Dispose();
imageToSave.Dis pose();
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 BackgroundImage Layout =
ImageLayout.Til ed.
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.Clien tRectangle;
Bitmap imageToSave = new Bitmap(areaToSa ve.Width, areaToSave.Heig ht);
Graphics g = Graphics.FromIm age(imageToSave );
g.DrawImage(can Canvas.Backgrou ndImage, areaToSave, areaToSave,
GraphicsUnit.Pi xel);
imageToSave.Sav e(fileName, imageFormatToSa ve);
g.Dispose();
imageToSave.Dis pose();
Comment