|
-
Jun 1st, 2004, 08:27 AM
#1
Thread Starter
Registered User
Making Picture With VB
Hello everybody!
I Want to know if there is a way to take a picture (jpg,gif) from VB and add Writing to that picture save it and have a new picture.
10x
-
Jun 1st, 2004, 01:51 PM
#2
Yes you can but it will save as a BMP.
VB Code:
Sub Form_Load()
Picture1.Picture = LoadPicture(App.Path & "\My Pic.jpg")
End Sub
Private Sub cmdAddText_Click()
Picture1.AutoRedraw = True
Picture1.CurrentX = Picture1.Height / 2 'X Position you want to print text
Picture1.CurrentY = Picture1.Width / 2 'Y Position you want to print text
Picture1.FontSize = 16
Picture1.ForeColor = vbRed
Picture1.Print "This is a sample"
End Sub
Private Sub cmdSave_Click()
SavePicture Picture1.Image, App.Path & "\Test.bmp" ' Save picture to file.
End Sub
Last edited by Keithuk; Dec 29th, 2004 at 05:45 PM.
Keith
I've been programming with VB for 25 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.
-
Jun 1st, 2004, 05:59 PM
#3
Hyperactive Member
In that example, it should be ScaleWidth and ScaleHeight, not Width and Height. (Because the ScaleMode of the PictureBox could be different than that of the parent Form.)
Also, if you're done, please add [Resolved] to the title...
And if you absolutely need to save as a jpg, there are free jpg libraries around.
-
Jun 2nd, 2004, 01:11 AM
#4
Thread Starter
Registered User
Thank you Keithuk!
DovyWeiss i have saved to a bmp and to jpg and it seems to be very big (bytes) where and what are Jpg libraries and where can i get them ?
-
Jun 2nd, 2004, 06:35 AM
#5
Thank you DovyWeiss, my mistake.
I originally used
Picture1.CurrentX = 2000
Picture1.CurrentY = 2000
Then I thought lets put it in the centre but I didn't try it.
Last edited by Keithuk; Dec 5th, 2004 at 09:23 AM.
Keith
I've been programming with VB for 25 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.
-
Jun 2nd, 2004, 06:51 AM
#6
Thread Starter
Registered User
Originally posted by asi
Thank you Keithuk!
DovyWeiss i have saved to a bmp and to jpg and it seems to be very big (bytes) where and what are Jpg libraries and where can i get them ?
Do Anybodu have an idea ?
-
Jun 2nd, 2004, 07:15 AM
#7
Addicted Member
-
Jun 9th, 2004, 08:27 AM
#8
Thread Starter
Registered User
Originally posted by asi
Thank you Keithuk!
DovyWeiss i have saved to a bmp and to jpg and it seems to be very big (bytes) where and what are Jpg libraries and where can i get them ?
help !!!
i need an answer.
-
Jun 9th, 2004, 12:26 PM
#9
Originally posted by asi
help !!!
i need an answer.
Did you see madjon's post?
-
Jun 9th, 2004, 01:04 PM
#10
Frenzied Member
I've attached a Bmp2Jpeg DLL which I use in many projects to convert images between bmp and jpg. Works great!
To use it:
VB Code:
Private Declare Function BmpToJpeg Lib "Bmp2Jpeg.dll" _
(ByVal bmpFileName As String, ByVal JpegFilename As String, _
ByVal CompressQuality As Integer) As Integer
'To convert an image
Call BmpToJpeg(strBmpFileName, strJpgFileName, 100) 'the last parameter is the picture quality (compression)
-
Jun 9th, 2004, 03:08 PM
#11
How do I use reference the dll I tried to add it as a reference - no luck. Tried to register it - no luck.
-
Jun 9th, 2004, 03:09 PM
#12
Well, you don't need to reference it, just have it in the app's path or Windows' System folder.
-
Jun 9th, 2004, 03:21 PM
#13
OK, it was in app.path and I didn't do anything except what I said and now it works. I guess it's just one of those mysteries.
-
Jun 9th, 2004, 03:35 PM
#14
A lot depends on current path, when VB starts, the current path is VB's path (the one defined in the shortcut icon). So once the current path changed to code path where the dll is, it started to work.
Just my guess
-
Jun 9th, 2004, 04:08 PM
#15
So Unbanned
Right... if you load a project from within VB, it probably won't work(as the current path is wrong, and the DLL won't be found unless it's in the system directory).
-
Jun 9th, 2004, 05:13 PM
#16
Frenzied Member
I'm not sure why registering the DLL doesnt work. I've tried that before and failed. But it seems to work as long as you have it in the directory where your app is running, so thats what I always do.
-
Jun 10th, 2004, 01:46 AM
#17
Thread Starter
Registered User
First of all Thank u !!
Now i use 100 for compression and i dont get a good quality,what is the best compression ?
even when i put 10000 i get bad quality so i don't understand how the compression works.
Last edited by asi; Jun 10th, 2004 at 01:49 AM.
-
Jun 10th, 2004, 02:47 AM
#18
The scale is 0 - 100
-
Jun 10th, 2004, 08:12 AM
#19
Originally posted by ae_jester
I've attached a Bmp2Jpeg DLL which I use in many projects to convert images between bmp and jpg. Works great!
[/Highlight]
Can this dll be used in reverse mode, i.e., jpg 2 bmp? Just curious.
Lottery is a tax on people who are bad at maths
If only mosquitoes sucked fat instead of blood...
To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)
-
Jun 11th, 2004, 02:46 AM
#20
Originally posted by DiGiTaIErRoR
Right... if you load a project from within VB, it probably won't work(as the current path is wrong, and the DLL won't be found unless it's in the system directory).
I've had the same problem trying to use this dll, sometimes it works, sometimes it doesn't. I start the project from its own folder where I have placed the dll. I don't understand why it wouldn't work at times.
Lottery is a tax on people who are bad at maths
If only mosquitoes sucked fat instead of blood...
To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)
-
Jun 11th, 2004, 08:09 AM
#21
Help!!!
I reference the dll by the string
app.path & "\Bmp2Jpeg.sll"
and I get this message: file Bmp2Jpeg.dll not found. But IT IS there, in the project folder.
Lottery is a tax on people who are bad at maths
If only mosquitoes sucked fat instead of blood...
To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)
-
Jun 11th, 2004, 09:17 AM
#22
Have you checked what App.Path is?
-
Jun 11th, 2004, 09:23 AM
#23
Frenzied Member
I hope this is a typo!
VB Code:
app.path & "\Bmp2Jpeg.sll"
Might want to try dll at the end
-
Jun 11th, 2004, 09:23 AM
#24
Frenzied Member
I've had the same problem trying to use this dll, sometimes it works, sometimes it doesn't. I start the project from its own folder where I have placed the dll. I don't understand why it wouldn't work at times.
Always works for me!
-
Jun 11th, 2004, 09:26 AM
#25
[QUOTE]Originally posted by ae_jester
[B]I hope this is a typo!
VB Code:
app.path & "\Bmp2Jpeg.sll"
It is...
Lottery is a tax on people who are bad at maths
If only mosquitoes sucked fat instead of blood...
To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)
-
Jun 11th, 2004, 09:39 AM
#26
Originally posted by Merri
Have you checked what App.Path is?
Yes, it's correct.
I have 2 folders in the desktop, each for a different project. For one of them it works but not for the other...!!!!????
Lottery is a tax on people who are bad at maths
If only mosquitoes sucked fat instead of blood...
To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)
-
Jun 11th, 2004, 09:56 AM
#27
Urgh, just place the DLL to system or system32 folder and you get no problems.
-
Jun 11th, 2004, 09:57 AM
#28
Also I've tried Dir(app.path & "\Bmp2Jpeg.dll") and it returns an empty string indicating not found.
Lottery is a tax on people who are bad at maths
If only mosquitoes sucked fat instead of blood...
To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)
-
Jun 11th, 2004, 11:30 AM
#29
Originally posted by Merri
Urgh, just place the DLL to system or system32 folder and you get no problems.
Yes it does work this way but I still don't see why it works sometimes in the app.path and sometimes it doesn't. I have reasons why I'd rather have the dll in the app folder.
Lottery is a tax on people who are bad at maths
If only mosquitoes sucked fat instead of blood...
To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)
-
Jul 11th, 2006, 10:01 AM
#30
Lively Member
Re: Making Picture With VB
Thanks! This is just what I needed and works like a champ
 Originally Posted by ae_jester
I've attached a Bmp2Jpeg DLL which I use in many projects to convert images between bmp and jpg. Works great!
To use it:
VB Code:
Private Declare Function BmpToJpeg Lib "Bmp2Jpeg.dll" _
(ByVal bmpFileName As String, ByVal JpegFilename As String, _
ByVal CompressQuality As Integer) As Integer
'To convert an image
Call BmpToJpeg(strBmpFileName, strJpgFileName, 100) 'the last parameter is the picture quality (compression)
Just an infant in VB years 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|