Link to home
Start Free TrialLog in
Avatar of KingSencat
KingSencat

asked on

How Do I Save A Portion Of A PictureBox?

Hi experts, How Do I Save A Portion Of A PictureBox? Any examples?
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

VB6 or VB.Net?  (If .net, which version?)

Is ALL of the "picture" in the Image/Picture Property?...or is some of it being rendered "on top" in the Paint() Event?
Avatar of KingSencat
KingSencat

ASKER

VB6 or VB.Net?  (If .net, which version?)
- I use VB6.0

Is ALL of the "picture" in the Image/Picture Property?...or is some of it being rendered "on top" in the Paint() Event?
- Didn't understand what your trying to say.

Lets say that i loaded a picture into the picturebox1. Now all i want to do is to take a portion of that picture and save it on a second picturebox or to a .bmp file. How can i accomplish that?
You want the PaintPicture() method:
http://msdn.microsoft.com/en-us/library/aa244140(VS.60).aspx

Something like:

    Picture2.PaintPicture Picture1.Picture, 0, 0, 50, 50, 100, 10, 50, 50

That would take the 50x50 portion at (100, 10) in Picture1 and paint it at (0, 0) in Picture2 within a 50x50 box.  Since the sizes are the same, this would be a straight copy and no stretching would occur.

I try to use
Picture2.PaintPicture Picture1.Picture, 0, 0, 50, 50, 100, 10, 50, 50

And i get invalid picture error message, why? Do i have to declare anything?
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial