Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.basic.visual.misc > #2453
| From | "Mayayana" <mayayana@invalid.nospam> |
|---|---|
| Newsgroups | comp.lang.basic.visual.misc, microsoft.public.vb.general.discussion |
| Subject | Re: VB6 Image Resizer |
| Date | 2020-03-31 17:41 -0400 |
| Organization | A noiseless patient Spider |
| Message-ID | <r60ddq$m65$1@dont-email.me> (permalink) |
| References | <r5mjl1$g3p$1@dont-email.me> |
Cross-posted to 2 groups.
Garry,
I spent most of the day fiddling with this, trying to
paste together old code without it taking a lot of
time. I just didn't want to get into mixing GDI and
GDI+ to make it work.
But here's another solution I came up with in a few
minutes. It's a button sub from a test program.
You need a reference to Windows Image Acquisition 2.
(It may need to be installed on XP. I don't remember.)
Then you need the button, a text box maned TTime,
and the declare. It will process a 10 MB JPG in about
1/3 second. In my other tests of painting an image it
wasn't quite as nice or quite as fast as GDI+, but it's
not far behind.
It might need a little work. One image kept erroring with
"the parameter is incorrect" on the ImProc.Apply line.
I don't know why. Others worked fine. A 12 MB image took
344 ms to load, resize, and save as a new file. Yet Irfan
View said it took 297 ms just to load the image. So I guess
344 isn't bad.
'------------------------------------------------
Private Declare Function GetTickCount Lib "kernel32" () As Long
Private Tick1 As Long, Tick2 As Long
Private Sub ButWIA2_Click()
Dim s1 As String
Dim W As Long, H As Long
Dim DestH As Long, DestW As Long, SrcW As Long, SrcH As Long, LSize As Long
Dim Img1 As ImageFile, Img2 As ImageFile
Dim ImProc As ImageProcess
TTime.Text = ""
Tick1 = GetTickCount
Set Img1 = New ImageFile
Set ImProc = New ImageProcess
Img1.LoadFile TPath.Text
LSize = 640
SrcW = Img1.Width
SrcH = Img1.Height
Debug.Print SrcW & " " & SrcH
If SrcW >= SrcH Then
DestW = LSize
DestH = SrcH * (DestW / SrcW)
Else
DestH = LSize
DestW = SrcW * (DestH / SrcH)
End If
While (ImProc.Filters.Count > 0)
ImProc.Filters.Remove 1
Wend
ImProc.Filters.Add ImProc.FilterInfos("Scale").FilterID
ImProc.Filters(1).Properties("MaximumWidth") = DestW
ImProc.Filters(1).Properties("MaximumHeight") = DestH
ImProc.Filters(1).Properties("PreserveAspectRatio") = True
Set Img1 = ImProc.Apply(Img1)
Dim s As String, Pt1 As Long
s = TPath.Text
Pt1 = InStrRev(s, ".")
s = Left$(s, (Pt1 - 1)) & "640.jpg"
Img1.SaveFile s
Set ImProc = Nothing
Set Img1 = Nothing
Tick2 = GetTickCount
TTime.Text = CStr(Tick2 - Tick1)
End Sub
Back to comp.lang.basic.visual.misc | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
VB6 Image Resizer GS <gs@v.invalid> - 2020-03-28 00:26 -0400
Re: VB6 Image Resizer "Mayayana" <mayayana@invalid.nospam> - 2020-03-28 10:04 -0400
Re: VB6 Image Resizer Arne Saknussemm <es215.10.wannabet@spamgourmet.com> - 2020-03-28 17:17 +0100
Re: VB6 Image Resizer "Mayayana" <mayayana@invalid.nospam> - 2020-03-28 14:12 -0400
Re: VB6 Image Resizer "Mayayana" <mayayana@invalid.nospam> - 2020-03-28 14:43 -0400
Re: VB6 Image Resizer Arne Saknussemm <es215.10.wannabet@spamgourmet.com> - 2020-03-29 15:48 +0200
Re: VB6 Image Resizer "Mayayana" <mayayana@invalid.nospam> - 2020-03-29 10:41 -0400
Re: VB6 Image Resizer GS <gs@v.invalid> - 2020-03-29 13:30 -0400
Re: VB6 Image Resizer GS <gs@v.invalid> - 2020-03-29 13:54 -0400
Re: VB6 Image Resizer "Mayayana" <mayayana@invalid.nospam> - 2020-03-29 15:36 -0400
Re: VB6 Image Resizer GS <gs@v.invalid> - 2020-03-29 16:19 -0400
Re: VB6 Image Resizer "Mayayana" <mayayana@invalid.nospam> - 2020-03-29 18:40 -0400
Re: VB6 Image Resizer GS <gs@v.invalid> - 2020-03-29 18:49 -0400
Re: VB6 Image Resizer "Mayayana" <mayayana@invalid.nospam> - 2020-03-29 23:17 -0400
Re: VB6 Image Resizer GS <gs@v.invalid> - 2020-03-30 07:44 -0400
Re: VB6 Image Resizer "Mayayana" <mayayana@invalid.nospam> - 2020-03-30 09:52 -0400
Re: VB6 Image Resizer GS <gs@v.invalid> - 2020-03-30 12:37 -0400
Re: VB6 Image Resizer GS <gs@v.invalid> - 2020-03-30 13:35 -0400
Re: VB6 Image Resizer GS <gs@v.invalid> - 2020-03-28 14:59 -0400
Re: VB6 Image Resizer "Mayayana" <mayayana@invalid.nospam> - 2020-03-28 16:39 -0400
Re: VB6 Image Resizer GS <gs@v.invalid> - 2020-03-28 17:57 -0400
Re: VB6 Image Resizer GS <gs@v.invalid> - 2020-03-28 18:44 -0400
Re: VB6 Image Resizer "Mayayana" <mayayana@invalid.nospam> - 2020-03-28 22:49 -0400
Re: VB6 Image Resizer GS <gs@v.invalid> - 2020-03-29 13:22 -0400
Re: VB6 Image Resizer "Peter T" <askmy@email.com> - 2020-03-30 17:29 +0100
Re: VB6 Image Resizer GS <gs@v.invalid> - 2020-03-30 12:34 -0400
Re: VB6 Image Resizer "Peter T" <askmy@email.com> - 2020-03-31 10:59 +0100
Re: VB6 Image Resizer GS <gs@v.invalid> - 2020-03-31 09:43 -0400
Re: VB6 Image Resizer GS <gs@v.invalid> - 2020-03-31 12:53 -0400
Re: VB6 Image Resizer "Mayayana" <mayayana@invalid.nospam> - 2020-03-30 18:20 -0400
Re: VB6 Image Resizer GS <gs@v.invalid> - 2020-03-30 18:50 -0400
Re: VB6 Image Resizer GS <gs@v.invalid> - 2020-03-30 18:56 -0400
Re: VB6 Image Resizer "Mayayana" <mayayana@invalid.nospam> - 2020-03-30 21:24 -0400
Re: VB6 Image Resizer GS <gs@v.invalid> - 2020-03-30 21:30 -0400
Re: VB6 Image Resizer "Mayayana" <mayayana@invalid.nospam> - 2020-03-30 22:01 -0400
Re: VB6 Image Resizer GS <gs@v.invalid> - 2020-03-30 22:11 -0400
Re: VB6 Image Resizer "Mayayana" <mayayana@invalid.nospam> - 2020-03-31 17:41 -0400
Re: VB6 Image Resizer GS <gs@v.invalid> - 2020-03-31 17:51 -0400
Re: VB6 Image Resizer "Mayayana" <mayayana@invalid.nospam> - 2020-03-31 21:08 -0400
Re: VB6 Image Resizer GS <gs@v.invalid> - 2020-03-31 21:14 -0400
csiph-web