Solved

How Do I Save A Portion Of A PictureBox?

Posted on 2009-03-29
5
235 Views
Last Modified: 2012-05-06
Hi experts, How Do I Save A Portion Of A PictureBox? Any examples?
0
Comment
Question by:KingSencat
  • 3
  • 2
5 Comments
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 24013654
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?
0
 

Author Comment

by:KingSencat
ID: 24013724
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?
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 24013856
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.

0
 

Author Comment

by:KingSencat
ID: 24014047
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?
0
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 24014054
Instead of:

    Picture1.Picture

Try:

    Picture1.Image

You may need to set AutoRedraw for Picture1 to True as well.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now