Saving image with labels

silver_shot
01-26-2005, 12:25 PM
I have an image with several labels on top. I want to save the image with the text that's in the labels but want them over the image exactly as they are in the form... does anyone know what I can do?

Silver

passel
01-26-2005, 07:37 PM
What is the image in?

Assuming the image is in a picturebox, or on the Form, then if AutoRedraw is set to
False for the picturebox or Form, you could use bitblt to copy the image as it appears
on the screen into a hidden picturebox (with AutoRedraw set True). You could then
use SavePicture to save the .Image of the hidden picturebox to a file.

Gruff
01-26-2005, 08:15 PM
-Or-

You could simply use the draw functions (and text print) of the picturebox to recreate the labels in the image.

silver_shot
01-26-2005, 11:31 PM
Yeah labels over a picture box... thanks I'll research some more

Gruff
01-27-2005, 06:59 PM
Yeah labels over a picture box... thanks I'll research some more

The image on the right was created from the picturebox and label control on the left using the code below.


Option Explicit

Private Sub Command1_Click()
Picture1.AutoRedraw = True
With Label1
Picture1.Line (.Left, .Top)-(.Left + .Width, .Top + .Height), vbWhite, BF
Picture1.Line (.Left, .Top)-(.Left + .Width, .Top + .Height), vbBlack, B
Picture1.CurrentX = .Left + 20
Picture1.CurrentY = .Top + 20
Picture1.Print Label1.Caption
End With
Image1.Picture = Picture1.Image
End Sub



~T

shadowmaker
02-06-2005, 02:45 AM
i have having an issue with this. its working great, however the label is not showing when behind (since for some reason lables can't go ontop of picturebox's) so the line that is drawn is only like one pixel big...when the label is PLEANTY big about 1/4 of the picturebox sometimes. i am useing the code almost exact but for some reason its just not working... basically the user is positioning the label and then a hidpicbox comes up to 0,0 on top of the label and boom...its suppost to save, but doesn't the caption is printed, but not the white area...which is strange to me
this is what i have

For i = 1 To frmdir.filelst.ListCount
frmdir.filelst.ListIndex = i - 1
frmmain.hidpic.Picture = LoadPicture(frmdir.dirlst.Path & "\" & frmdir.filelst.FileName)
frmmain.hidpic.Move 0, 0
DoEvents

With lblremoved
frmmain.hidpic.Line (.Left, .Top)-(.Left + .Width, .Top + .Height), vbWhite, BF
frmmain.hidpic.Line (.Left, .Top)-(.Left + .Width, .Top + .Height), vbBlack, B
frmmain.hidpic.CurrentX = .Left + 20
frmmain.hidpic.CurrentY = .Top + 20
frmmain.hidpic.Print lblremoved.Caption
End With

frmpreview.Picture = frmmain.hidpic.Image

frmpreview.Show

SavePicture frmpreview.Picture, "c:\output\" & i - 1 & ".bmp"

next i

shadowmaker
02-06-2005, 02:53 AM
btw here are some screenshots of what i am talking about...

silver_shot
02-06-2005, 04:00 AM
I haven't been online enough to check this and thansk for all the replies. I would just like to comment on the first code which I tried. It works good but is there a way I can "add" an effect to it? For example a texture effect to the text like what you can do in photoshop? I might try a completely different method instead of what I'm saying now lol.

Thanks anyways.

Silver

shadowmaker
02-06-2005, 12:31 PM
well after playing with this for 5 or so hours, i found out the issue, i am going to post the fix just incase anyone has the same issue. basically it all comes down to scale mode. i had the form set as pixel but the picturebox as twip. hence the small block of white. so the answer i guess is make sure whenever you change one scale mode double check all your other controls to make sure they all have the same scale mode :) and so after feeling like a complete goober.... the program is finished... thanks guys

Gruff
02-06-2005, 02:57 PM
Shandowmaker,

Sounds like you have your form scalemode property set to pixels (Or another unit) and your picturebox scalemode property set to something different. They need to be the same for my code snippet to work.

The Print statement that writes the text uses the print statement inside the picturebox and takes its font size from the picturebox.

BTW you do not need the label control at all to just create a rectangle and some text in the picturebox. Just supply the location and size of the rectangle and location and string for the printed text.
(Don't know if that helps with what you are doing. :) )


~T

Gruff
02-06-2005, 03:05 PM
is there a way I can "add" an effect to it? For example a texture effect to the text like what you can do in photoshop? I might try a completely different method instead of what I'm saying now lol.
Silver

Visual Basic is a fully compatible Microsoft Windows Program. This means it understands many of the other MS program datatypes automatically.

You can for instance startup Microsoft word, create a fancy 3D font piece of text in wild colors. (Say text that follows an arc). Select it, press CTRL_C to copy it to the windows clipboard. Shift to Visual Basic select an image control and press CTRL-V to paste the fancy image into it. Now its no longer editable text but its still pretty cool. As a matter of fact any image you can get on the windows clipboard you can paste into a picture or image box.

Be sure Visual Basic is already running. When you start VB it clears the Windows clipboard. (Yeesh.)

Speaking of text. Any specialty font you can load into windows should be available to Visual Basic. Be aware though that you need a redistributable font. Otherwise when you make your setup package your font will not go with it.


~T

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum