nashuald
asked on
Save the content from a picturebox in a jpeg, bmp or gif file.
Have a nice day.
I don't use speak english, but I gonna try.
I want to know how can I save the content inside a picturebox in a jpeg, bmp or gif file.
By example, in a picturebox I have 2 Textboxes, 1 usercontrol and 1 shape.
How can I create a image file (any format) including those controls inside the image?
Thanks!
I don't use speak english, but I gonna try.
I want to know how can I save the content inside a picturebox in a jpeg, bmp or gif file.
By example, in a picturebox I have 2 Textboxes, 1 usercontrol and 1 shape.
How can I create a image file (any format) including those controls inside the image?
Thanks!
ASKER
Thanks vb_elmar, but I believe I did not explain myself very well.
I have two textboxes, an usercontrol and one shape inside a picturebox.
I would to know how to convert this arraingement into ain image file.
+------------------------- ---------- ---------- ---------- ---------- --
| ___________________ _________________ |
| | TextBox1 | | UserControl1 | |
| -------------------------- - ------------------------ | <--- PictureBox
| ___________________ |
| | TextBox2 | |
| | | |
| -------------------------- - |
| |
| |
| -------------------------- ------- <-- Line (Shape control)
| |
+------------------------- ---------- ---------- ---------- ---------- --
Thanks again.
I have two textboxes, an usercontrol and one shape inside a picturebox.
I would to know how to convert this arraingement into ain image file.
+-------------------------
| ___________________ _________________ |
| | TextBox1 | | UserControl1 | |
| --------------------------
| ___________________ |
| | TextBox2 | |
| | | |
| --------------------------
| |
| |
| --------------------------
| |
+-------------------------
Thanks again.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you very much vb_elmar!
The code works very well, but I have noticed the following:
If, inside the picturebox, the size of a control is bigger than picturebox's height or picturebox's width, the control don't appear entirely into image file.
How can I look for all the objects inside the picturebox and include them in the image file, even if they aren't in the visible region of the picturebox?
Look the drawing:
+------------------------- ---------- ---------- ---------- ---------- --
| ___________________ _________________ |
| | TextBox1 | | UserControl1 | |
| -------------------------- - ------------------------ | <--- PictureBox
| ___________________ |
| | TextBox2 | |
| | | |
| -------------------------- - |
| |
| |
| -------------------------- ------- <-- Line (Shape control)
| |
| -------------------|------ --------
| | | |
+------------------------- ---------- ---------- --|------- ---------- -- |
| | <-- Another control.
| |
| |
-------------------------- ---------
The code works very well, but I have noticed the following:
If, inside the picturebox, the size of a control is bigger than picturebox's height or picturebox's width, the control don't appear entirely into image file.
How can I look for all the objects inside the picturebox and include them in the image file, even if they aren't in the visible region of the picturebox?
Look the drawing:
+-------------------------
| ___________________ _________________ |
| | TextBox1 | | UserControl1 | |
| --------------------------
| ___________________ |
| | TextBox2 | |
| | | |
| --------------------------
| |
| |
| --------------------------
| |
| -------------------|------
| | | |
+-------------------------
| | <-- Another control.
| |
| |
--------------------------
BitBlt works with hdc's (picture1.hdc etc.). Hdc's are for visible regions only. That means that you have to resize the picbox
until all controls in the picbox are visible.
until all controls in the picbox are visible.
===============
Needs a Picturebox:
===============
ScaleMode = 3
Picture1.ScaleMode = 3: Picture1.DrawWidth = 3
Picture1.BorderStyle = 0: Picture1.BackColor = vbRed
Picture1.Picture = LoadPicture("C:\WINDOWS\De
Picture1.AutoRedraw = True
Picture1.Width = 100: Picture1.Height = 100 'saved pic will be 100x100
Picture1.Line (0, 0)-(90, 90), vbGreen, B 'draw a 91x91 frame
Picture1.CurrentX = 0: Picture1.CurrentY = 0
Picture1.FontSize = 22: Picture1.Font = "Arial"
Picture1.CurrentX = 3: Picture1.CurrentY = 30
Picture1.Print "Hello" 'print 'Hello' to pos x,y
SavePicture Picture1.Image, "c:\windows\desktop\9Lmick