|
-
Dec 15th, 2001, 02:49 AM
#1
Thread Starter
Member
-
Dec 15th, 2001, 11:14 AM
#2
Conquistador
plenderj posted some code recently on how to resize
i think you have to check www.planet-source-code.com for conversion examples 
hope it helps some
-
Dec 15th, 2001, 11:22 AM
#3
Conquistador
-
Dec 16th, 2001, 07:21 AM
#4
Thread Starter
Member
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,
-
Dec 16th, 2001, 07:27 AM
#5
Thread Starter
Member
Hi da_silvy,
Thanks for the site . I knew about it but your Keyword made a great diffrence to the answers i received.

Regards,
-
Dec 16th, 2001, 04:21 PM
#6
Conquistador
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
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
'
' 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
-
Dec 17th, 2001, 05:51 AM
#7
Thread Starter
Member
Hi,
Thanks a lot!!! This was some help!
Very nice of you .
Regards,
LXS
-
Dec 21st, 2001, 03:08 AM
#8
Conquistador
no problems
-
Dec 22nd, 2001, 03:48 AM
#9
Thread Starter
Member
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
-
Jan 2nd, 2002, 04:13 AM
#10
Retired VBF Adm1nistrator
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.
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
-
Jan 4th, 2002, 12:06 AM
#11
Thread Starter
Member
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,
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
|