Solved

How Do I Save A Portion Of A PictureBox?

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VBA error replacing data 6 40
MS Acccess - Update Field in Table when report is printed 6 47
VBA: Select SQL query based on a config Sheet v2 11 49
Child Form in front 4 49
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

830 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