:( Hi all,
I need to save any image file ( *.bmp /*.jpg or gif file) as a jpg.
How to do it?
:(
If not ,how do i add a compression to it?
:(
I want to Reducxe the size of the image?
:( Can this be done without using any dlls or ocx?
Regards,
Laxmi
Printable View
:( Hi all,
I need to save any image file ( *.bmp /*.jpg or gif file) as a jpg.
How to do it?
:(
If not ,how do i add a compression to it?
:(
I want to Reducxe the size of the image?
:( Can this be done without using any dlls or ocx?
Regards,
Laxmi
plenderj posted some code recently on how to resize
i think you have to check www.planet-source-code.com for conversion examples :rolleyes:
hope it helps some ;)
have a look at this thread ;)
http://www.vbforums.com/showthread.php?s=&postid=701318
:) Thanks da_silvy . Actually i do know the savepicture ...
But what i want to know is how to reduce the size of the image.
Like if i choose a bitmap file of 1k the jpg image ( output of my program) has to be of a smaller size.
Can you help me?
Thanks again. :)
Regards,
Hi da_silvy,
Thanks for the site . I knew about it but your Keyword made a great diffrence to the answers i received.
:)
Regards,
-->Quote:
Originally posted by lxs
:) Thanks da_silvy . Actually i do know the savepicture ...
But what i want to know is how to reduce the size of the image.
Like if i choose a bitmap file of 1k the jpg image ( output of my program) has to be of a smaller size.
Can you help me?
Thanks again. :)
Regards,
http://www.vbforums.com/showthread.p...t=plenderleith
Quote:
Originally posted by plenderj
To resize you just use StretchBlt.
I've posted numerous examples on the forums. Here's one too ;
VB Code:
' By Jamie Plenderleith ' [email][email protected][/email] ' ' This code will stretch the 'background' picture of a form to the size of the form ' Change the picDc = GeneradeDC(..) line to point to an appropriate graphic ' Option Explicit Private picDc As Long Private picWidth As Long Private picHeight As Long Private Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As Long Private Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long Private Declare Function LoadImage Lib "user32" Alias "LoadImageA" (ByVal hInst As Long, ByVal lpsz As String, ByVal un1 As Long, ByVal n1 As Long, ByVal n2 As Long, ByVal un2 As Long) As Long Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long Private Declare Function StretchBlt Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal dwRop As Long) As Long Public Function GenerateDC(FileName As String) As Long Dim DC As Long, picTemp As IPictureDisp DC = CreateCompatibleDC(0) If DC < 1 Then Exit Function End If Set picTemp = LoadPicture(FileName) picWidth = ScaleX(picTemp.Width) picHeight = ScaleY(picTemp.Height) SelectObject DC, picTemp DeleteObject picTemp Set picTemp = Nothing GenerateDC = DC End Function Private Sub Form_Load() ScaleMode = 3 picDc = GenerateDC("c:\jamie\barrk.bmp") With Picture1 .AutoRedraw = True .Move 0, 0, ScaleWidth, ScaleHeight .ScaleMode = 3 End With doStretch End Sub Private Function doStretch() Debug.Print StretchBlt(Picture1.hdc, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight, picDc, 0, 0, picWidth, picHeight, vbSrcCopy) Picture1.Refresh End Function Private Sub Form_Resize() Picture1.Move 0, 0, ScaleWidth, ScaleHeight doStretch End Sub
:) Hi,
Thanks a lot!!! This was some help!
:) Very nice of you .
Regards,
LXS
no problems :D
Da_sily , You wont believe this. I made a program and the image that comes out of the above code is a bit not clear-slightly blured.
My boss is not happy-says he wanted a quality similar to the the photo editor jpeg conversions!!!!
Looks like a nightmare come true!
Is there a way i can get good qquality image /improve the resolution of the image?
Thanks and sorry to trouble again.
:) You've been of great help .
Regards,
LXS
Microsoft's way is not necessarily the best remember!
Add the following API declaration :
VB Code:
Declare Function SetStretchBltMode Lib "gdi32" Alias "SetStretchBltMode" (ByVal hdc As Long, ByVal nStretchMode As Long) As Long
with the following constants
VB Code:
Const BLACKONWHITE = 1 Const WHITEONBLACK = 2 Const COLORONCOLOR = 3 Const HALFTONE = 4
Now, before you do any stretching, try calling SetStretchBltlMode on the Picturebox in question, and pass one of the four above constants in as the second parameter. Experiment with them to see which gives the best results.
If that isn't good enough, then you'll have to write your own stretching routines (www.planetsourcecode.com might be of use here) or get a 3rd party control.
your code is great.
Please see attached file.
I wanted something like this...the problem is its too time consuming and large images dont fit in picture box..
Thanks ,
Regards,