Bitmap - show a rectangle area only
-
I don't know whats the failure of this code:
Image src = Image.FromFile(@"C:\_sc\test.bmp"); Graphics gr = Graphics.FromImage(src); gr.DrawImageUnscaled(src, 10, 10, 50, 50); Bitmap bmp = new Bitmap(50, 50, gr); pcCuted.Image = bmp; pcCuted.Invalidate();
I load the test.bmp and redraw it new. So I make a new rectangle (50w,50h) and want to put only this area into the pcCuted Picturebox. Doesn't work. Any way to do it right? -
I don't know whats the failure of this code:
Image src = Image.FromFile(@"C:\_sc\test.bmp"); Graphics gr = Graphics.FromImage(src); gr.DrawImageUnscaled(src, 10, 10, 50, 50); Bitmap bmp = new Bitmap(50, 50, gr); pcCuted.Image = bmp; pcCuted.Invalidate();
I load the test.bmp and redraw it new. So I make a new rectangle (50w,50h) and want to put only this area into the pcCuted Picturebox. Doesn't work. Any way to do it right?You were redrawing back onto the same image as you were reading from
Image src = Image.FromFile(@"C:\_sc\test.bmp"); Bitmap bmp = new Bitmap(50,50); Graphics gr = Graphics.FromImage(bmp); gr.DrawImageUnscaled(src, 10, 10, 50, 50); pcCuted.Image = bmp; pcCuted.Invalidate();
-
You were redrawing back onto the same image as you were reading from
Image src = Image.FromFile(@"C:\_sc\test.bmp"); Bitmap bmp = new Bitmap(50,50); Graphics gr = Graphics.FromImage(bmp); gr.DrawImageUnscaled(src, 10, 10, 50, 50); pcCuted.Image = bmp; pcCuted.Invalidate();
-
ok, but this still doesn't work
Image src = Image.FromFile(@"C:\_sc\test.bmp"); Graphics gr = Graphics.FromImage(src); gr.DrawImageUnscaled(src, 10, 10, 50, 50); Bitmap bmp = new Bitmap(50, 50, gr); pcCuted.Image = bmp; pcCuted.Invalidate();
In english we use "Thankyou for your help, however i am still having difficulties" I took the time to actually type that code into a new windows project and tested it with an image locally, it did exactly what you asked for - draw a section (10,10,50,50) of the original image into the picture box. And the best you can give is "still doesnt work" X| I'll tell you what, if you tell me WHAT doesnt work, ill even have another try - that is as long as you're a little more polite this time :|
-
In english we use "Thankyou for your help, however i am still having difficulties" I took the time to actually type that code into a new windows project and tested it with an image locally, it did exactly what you asked for - draw a section (10,10,50,50) of the original image into the picture box. And the best you can give is "still doesnt work" X| I'll tell you what, if you tell me WHAT doesnt work, ill even have another try - that is as long as you're a little more polite this time :|
Hi, Either I thank you in advance, problem is solved or finally no solutin was found. I have now a solution, thank for your response and the tip (finally it was the right way). PS: Every tip is automatically accepted thanks. It's naturally. So why should people post their thanks in an extra thread and wasting space?
-
Hi, Either I thank you in advance, problem is solved or finally no solutin was found. I have now a solution, thank for your response and the tip (finally it was the right way). PS: Every tip is automatically accepted thanks. It's naturally. So why should people post their thanks in an extra thread and wasting space?
Seraphin wrote:
PS: Every tip is automatically accepted thanks. It's naturally. So why should people post their thanks in an extra thread and wasting space?
Because it gives the person who tried to help you a good feeling, and maybe he thinks (i know i do): 'hey that guy is nice, if he asks a question next time i will try to help him again!' And also it's just good manners... Pompiedompiedom... ;)
"..Commit yourself to quality from day one..it's better to do nothing at all than to do something badly.." -- Mark McCormick