Solved

How Do I Save A Portion Of A PictureBox?

Posted on 2009-03-29
5
234 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

760 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

23 Experts available now in Live!

Get 1:1 Help Now