 |
|
 |
your code works great but I have this problem .. as I can do to save the image to zoom in on the hard drive?
Help me please...
|
|
|
|
 |
|
 |
Hello,
the control did not provide any function to save the image. To realize this functionality you have to implement your own function. In this function you can make use of the "Image.Save" method from the API, e.g. : pictureBox1.Image.Save(@"C:\Documents and Settings\jheiron\Desktop\test.jpg",ImageFormat.Jpeg);
Greetings
|
|
|
|
 |
|
 |
Iplease and sorry for the inconvenience.
|
|
|
|
 |
|
 |
Hello,
no problem, but i´m not sure if the example can help you. Anyway. Add the following code snippet to the PictureBox.cs class and recompile the code. This will add a new property to the control:
/// <summary>
/// Get the image from the picturebox
/// </summary>
public Image Image
{
get { return PicBox.Image; }
}
In the TestGUI add a button and on the button-click eventhandler add the following:
private void button4_Click(object sender, EventArgs e)
{
pb.Image.Save( System.IO.Path.Combine( Application.StartupPath, "imagesave.jpg"));
}
This will save the image from the picturebox, but remember it saves the image in its originally size !
Greetings
Alexander
|
|
|
|
 |
|
 |
I put the code works, but you're right does not save the image with the zoom but the original, you will know in some way to save the image with the zoom?
and do not think I want to do the work .. I was researching how to do the step
pardon for my bad English, I'm using the google translator jajajja :P
|
|
|
|
 |
|
 |
Your article is very useful for me. thanks
|
|
|
|
 |
|
 |
Nice control.
I was using this to display an image so that a user could decide where to move the file. When I went to move the file I received a "process cannot access the file because it is being used by another process" error message.
The solution was to replace the line:
PicBox.Image = Image.FromFile ( value );
With:
using (FileStream fs1 = new FileStream(value, FileMode.Open))
{
PicBox.Image = Image.FromStream(fs1);
}
|
|
|
|
 |
|
 |
Good solution! Thanks for sharing.
Greets Alex.
|
|
|
|
 |
|
 |
My image wich ussualy cant even fit the screen is very very small in your picturebox
|
|
|
|
 |
|
 |
Congratulations!
Best regards,
X3m
|
|
|
|
 |
|
 |
Hi Friends,
I am working with image. How can i zoom it on center of my screen. it should zoom in all the direction and how can i scroll by mouse wheel...
Plz help me oput... its very urgent.
Regards
V K Gupta
|
|
|
|
 |
|
 |
I used your sourcecode to create a new usercontrol, with a public Image property, allowing the user to set the PictureBox's Image property directly and not only from a string file location.
I also added code to the Image Set Property method to render the image in the centre of the panel and not in the top left corner, (as well as to the zoom methods).
Otherwise a very useful user control, thanks very much for making the source code available!!
Steve
|
|
|
|
 |
|
 |
That's exactly what I'm about to do. It would be cool if you posted your code...
|
|
|
|
 |
|
 |
Yes I would like to see that as well
Jer 29:11
|
|
|
|
 |
|
 |
If anyone would like to enhance this code so that you can drag around the picture like you are able to do in Acrobat Reader, add the following 2 handlers:
private void PicBox_MouseDown(object sender, MouseEventArgs e)
{
clickPosn.X = e.X;
clickPosn.Y = e.Y;
}
private void PicBox_MouseMove(object sender, MouseEventArgs e)
{
if(e.Button == MouseButtons.Left)
{
scrollPosn.X = scrollPosn.X + clickPosn.X - e.X;
scrollPosn.Y = scrollPosn.Y + clickPosn.Y - e.Y;
OuterPanel.AutoScrollPosition = scrollPosn;
}
}
Also add the declerations
private Point clickPosn;
private Point scrollPosn;
Lastly the register the new handlers
PicBox.MouseDown += new MouseEventHandler(PicBox_MouseDown);
PicBox.MouseMove += new MouseEventHandler(PicBox_MouseMove);
And that should do it.
|
|
|
|
 |
|
 |
Good stuff - works exactly as described first time! Thanks.
|
|
|
|
 |
|
 |
One side effect of this is that when the mouse enters the control again after losing focus, and subsequently having focus re-set in the PicBox_MouseEnter event with PicBox.Focus();, the image reverts to having its top left corner aligned with the top left corner of the Outer Panel. To alleviate this, Add the line of code OuterPanel.AutoScrollPosition = scrollPosn; in the PicBox_MouseEnter event so that it reads as follows:
private void PicBox_MouseEnter(object sender, EventArgs e)
{
if ( PicBox.Focused == false )
{
PicBox.Focus();
OuterPanel.AutoScrollPosition = scrollPosn;
}
}
Unfortunately this does result in a slight flicker of the image when the mouse re-enters this area, however I haven't been able to get rid of this, even with calls to .SuspendLayout()/.ResumeLayout() calls on either PicBox or OuterPanel.
|
|
|
|
 |
|
 |
in the PicBox_MouseMove I'd use something like this:
_scrollPosn.X = Math.Min(OuterPanel.Width, Math.Max(0, _scrollPosn.X + _clickPosn.X - e.X));
_scrollPosn.Y = Math.Min(OuterPanel.Height, Math.Max(0, _scrollPosn.Y + _clickPosn.Y - e.Y));
the moving itself looks better
life is study!!!
|
|
|
|
 |
|
 |
First of all, thanks for this usefull and well realized component
I've got just a little suggestion.
I think it could be very usefull if you make the control able to display generic infos about the displayed image (H, W, size and so on) in some ways like (i.e.) a semi-transparent hint-box that appears automatically when the mouse goes over the control (or in other programatic-controlled ways).
--
NinjaCross
www.ninjacross.com
-- modified at 8:37 Wednesday 14th September, 2005
|
|
|
|
 |
|
 |
Hi,
okay this is a good idea. I´ll try to find a solution asap.
Alex.
-- modified at 1:44 Thursday 15th September, 2005
|
|
|
|
 |
|
 |
Hi,
I created my owm project and tried to create the pictureBox in my Toolbox by inserting the DLL as explained above. The pictureBox object appear in the toolbox but looks like disabled. If I try to use it nothing happen. Does anyone
would have an idea about what is happening ?
Thanks a lot
|
|
|
|
 |
|
 |
I found the problem, I created a MFC project instead of 'Windows control library' project but I still would like to use this picturebox Dll in my MFC project, would it be an easy way to do that ?
Thanks
|
|
|
|
 |
|
 |
Hi Alex,
Nice Control. Excellent work.
DO you have any restrictions on using your control? Can I just copy and paste it in my project?
|
|
|
|
 |
|
 |
Hey, there are no restriction from my side. Have fun.
Alex.
|
|
|
|
 |
|
 |
Thank you. Great work. Hope for more people like you.
Good luck!!
|
|
|
|
 |