Solved

How Do I Save A Portion Of A PictureBox?

Posted on 2009-03-29
5
238 Views
Last Modified: 2012-05-06
Hi experts, How Do I Save A Portion Of A PictureBox? Any examples?
0
Comment
Question by:KingSencat
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 86

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 86

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 86

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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying 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

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…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

734 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