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
Printable View
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
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
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.
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 ?
Thank you DovyWeiss, my mistake. :sick:
I originally used
Picture1.CurrentX = 2000
Picture1.CurrentY = 2000
Then I thought lets put it in the centre but I didn't try it.
:wave:
Do Anybodu have an idea ?Quote:
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 !!!Quote:
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 ?
i need an answer.
Did you see madjon's post?Quote:
Originally posted by asi
help !!!
i need an answer.
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)
How do I use reference the dll I tried to add it as a reference - no luck. Tried to register it - no luck.
Well, you don't need to reference it, just have it in the app's path or Windows' System folder.
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.
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 :)
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'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.
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.
The scale is 0 - 100 :)
Can this dll be used in reverse mode, i.e., jpg 2 bmp? Just curious.Quote:
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]
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.Quote:
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 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.
Have you checked what App.Path is?
I hope this is a typo!
VB Code:
app.path & "\Bmp2Jpeg.sll"
Might want to try dll at the end
Always works for me!Quote:
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.
[QUOTE]Originally posted by ae_jester
[B]I hope this is a typo!
VB Code:
app.path & "\Bmp2Jpeg.sll"
It is...
Yes, it's correct.Quote:
Originally posted by Merri
Have you checked what App.Path is?
I have 2 folders in the desktop, each for a different project. For one of them it works but not for the other...!!!!????
Urgh, just place the DLL to system or system32 folder and you get no problems.
Also I've tried Dir(app.path & "\Bmp2Jpeg.dll") and it returns an empty string indicating not found.
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.Quote:
Originally posted by Merri
Urgh, just place the DLL to system or system32 folder and you get no problems.
Thanks! This is just what I needed and works like a champ :thumb:
Quote:
Originally Posted by ae_jester