Saving inside of rectangle in picturebox?

First new up a Bitmap with the right dimensions.

First new up a Bitmap with the right dimensions then you create a Graphics-object for this with Graphics. FromImage and then use the DrawImage method on the resulting Graphics-object to draw a section of your large image onto the bitmap. Finally save the bitmap-object with Save: public static void SaveBitmapPart(System.Drawing.

Image image, System.Drawing. RectangleF sourceRect, string pathToSave ) { using (var bmp = new System.Drawing. Bitmap((int)sourceRect.

Width, (int)sourceRect. Height)) { using (var graphics = System.Drawing.Graphics. FromImage(bmp)) { graphics.

DrawImage(image, 0.0f, 0.0f, sourceRect, System.Drawing.GraphicsUnit. Pixel); } bmp. Save(pathToSave); } } so just call it with: SaveBitmapPart(picturebox1.

Image, myRectangle, @"c:\Temp\Test. Bmp").

PS you can use the PictureBoxes-Image property as the "image" (first parameter) for this small function. – Carsten König Aug 23 at 10:23 Tnx, but I have still problem. When I select rectangle on my picturebox - 640x480, for example rectangle (300x300) then my saved picture is 300x300, but everything from inside rectangle is on top left corner and it's not stretched - just like micro img of inside of rectangle.

– Elfoc Aug 23 at 11:06 you didn't write nothing about stretching the image nor did your sample sugguest - anyhow it's rather easy - just change the DrawImage-Method to an overload that can handle image-stretching (just look at the MSDN docu - it's very good) - of course you have to the bitmap for your desiered size too) – Carsten König Aug 23 at 11:29 I didn't write about it because I didn't want to do this. I'll try to explain problem better ;) Your's solution work. I have selected rectangle 640x480 - it's size od picturebox1.

Which I get in result as picture1. Jpg with parameteres 640x480. Inside of it there's square 100x100 with my picture, and rest of picture is blank area.

This is 100x100 screen is from 640x480 but it's smaller.. like it's not proper scaled. – Elfoc Aug 23 at 12:09 Ok - problem was with System.Drawing. Bitmap resolution which by default is = 96 dpi.

– Elfoc Aug 23 at 14:08.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions