From: Henning on

"Paul Clement" <UseAdddressAtEndofMessage(a)swspectrum.com> skrev i
meddelandet news:pshjo5l1gqv2h3ehjpms38qdov6oncslln(a)4ax.com...
> On Sat, 27 Feb 2010 09:02:01 -0800, Tony Girgenti
> <tony(nospam)@lakesideos.com>
> wrote:
>
> � Hello.
> �
> � I want to develop a VB6 program to convert a .TIF file to a .JPG file.
> �
> � Is that possible using VB6?
> �
> � Any help would be gratefully appreciated.
> �
> � Thanks,
> � Tony
>
> It's pretty easy to do in Visual Basic .NET but I'm not aware of any code
> solutions in Classic VB that don't implement a third-party component (and
> the
> Kodak Imaging libraries are no longer included in Windows).
>
> Paul
> ~~~~
> Microsoft MVP (Visual Basic)

I guess it's even easier done in PhotoShop or even ACDSee.

/Henning


From: Ralph on

"Paul Clement" <UseAdddressAtEndofMessage(a)swspectrum.com> wrote in message
news:pshjo5l1gqv2h3ehjpms38qdov6oncslln(a)4ax.com...
> On Sat, 27 Feb 2010 09:02:01 -0800, Tony Girgenti
<tony(nospam)@lakesideos.com>
>
> It's pretty easy to do in Visual Basic .NET but I'm not aware of any code
> solutions in Classic VB that don't implement a third-party component (and
the
> Kodak Imaging libraries are no longer included in Windows).
>

Equally easy to do with C# .Net Framework, Visual C++ .Net Framework,
Delphi, and probably several more development packages I can't think of at
the moment.

-ralph


From: mscir on
Tony Girgenti wrote:
> Hello.
>
> I want to develop a VB6 program to convert a .TIF file to a .JPG file.
>
> Is that possible using VB6?
>
> Any help would be gratefully appreciated.
>
> Thanks,
> Tony

It's possible in VB6, I can read a tiff into a picturebox, and use code
found on PlanetSourceCode to save it to a jpg. I sent a demo program to
your private email.

Mike

--- news://freenews.netfront.net/ - complaints: news(a)netfront.net ---
From: mscir on
On Feb 27, 6:16 pm, mscir <ms...(a)yahoo.com> wrote:
> Tony Girgenti wrote:
> > I want to develop a VB6 program to convert a .TIF file to a .JPG file.
> > Is that possible using VB6? Any help would be gratefully appreciated.
> > Thanks,
> > Tony

Here's the code,

=======================
in a module:
=======================

Option Explicit

Private Type GUID
Data1 As Long
Data2 As Integer
Data3 As Integer
Data4(0 To 7) As Byte
End Type

Private Type GdiplusStartupInput
GdiplusVersion As Long
DebugEventCallback As Long
SuppressBackgroundThread As Long
SuppressExternalCodecs As Long
End Type

Private Type EncoderParameter
GUID As GUID
NumberOfValues As Long
Type As Long
Value As Long
End Type

Private Type EncoderParameters
Count As Long
Parameter As EncoderParameter
End Type

Private Declare Function GdiplusStartup Lib "GDIPlus" ( _
token As Long, _
inputbuf As GdiplusStartupInput, _
Optional ByVal outputbuf As Long = 0) As Long

Private Declare Function GdiplusShutdown Lib "GDIPlus" ( _
ByVal token As Long) As Long

Private Declare Function GdipCreateBitmapFromHBITMAP Lib "GDIPlus" ( _
ByVal hbm As Long, _
ByVal hPal As Long, _
Bitmap As Long) As Long

Private Declare Function GdipDisposeImage Lib "GDIPlus" ( _
ByVal Image As Long) As Long

Private Declare Function GdipSaveImageToFile Lib "GDIPlus" ( _
ByVal Image As Long, _
ByVal filename As Long, _
clsidEncoder As GUID, _
encoderParams As Any) As Long

Private Declare Function CLSIDFromString Lib "ole32" ( _
ByVal str As Long, _
id As GUID) As Long


Public Sub SaveJPG(ByVal pict As StdPicture, ByVal filename As String,
Optional ByVal quality As Byte = 80)

Dim tSI As GdiplusStartupInput
Dim lRes As Long
Dim lGDIP As Long
Dim lBitmap As Long

' Initialize GDI+
tSI.GdiplusVersion = 1
lRes = GdiplusStartup(lGDIP, tSI)

If lRes = 0 Then

' Create the GDI+ bitmap
' from the image handle
lRes = GdipCreateBitmapFromHBITMAP(pict.Handle, 0, lBitmap)

If lRes = 0 Then
Dim tJpgEncoder As GUID
Dim tParams As EncoderParameters

' Initialize the encoder GUID
CLSIDFromString
StrPtr("{557CF401-1A04-11D3-9A73-0000F81EF32E}"), tJpgEncoder

' Initialize the encoder parameters
tParams.Count = 1
With tParams.Parameter ' Quality
' Set the Quality GUID
CLSIDFromString StrPtr("{1D5BE4B5-
FA4A-452D-9CDD-5DB35105E7EB}"), .GUID
.NumberOfValues = 1
.Type = 4
.Value = VarPtr(quality)
End With

' Save the image
lRes = GdipSaveImageToFile( _
lBitmap, _
StrPtr(filename), _
tJpgEncoder, _
tParams)

' Destroy the bitmap
GdipDisposeImage lBitmap

End If

' Shutdown GDI+
GdiplusShutdown lGDIP

End If

If lRes Then
Err.Raise 5, , "Cannot save the image. GDI+ Error:" & lRes
End If

End Sub

=======================
In a form:
=======================

Private Sub Command1_Click()
'save picture in picture box as a jpeg file
SaveJPG Picture1.Image, App.Path & "\look_at_me.jpg"
'confirm that file is saved
MsgBox "Image saved as '" & App.Path & "\look_at_me.jpg'"
End Sub

From: Shotgun Thom on
On Feb 27, 6:37 pm, Paul Clement
<UseAdddressAtEndofMess...(a)swspectrum.com> wrote:
> On Sat, 27 Feb 2010 09:02:01 -0800, Tony Girgenti <tony(nospam)@lakesideos.com>
> wrote:
>
> ¤ Hello.
> ¤
> ¤ I want to develop a VB6 program to convert a .TIF file to a .JPG file..
> ¤
> ¤ Is that possible using VB6?
> ¤
> ¤ Any help would be gratefully appreciated.
> ¤
> ¤ Thanks,
> ¤ Tony
>
> It's pretty easy to do in Visual Basic .NET but I'm not aware of any code
> solutions in Classic VB that don't implement a third-party component (and the
> Kodak Imaging libraries are no longer included in Windows).
>
> Paul

Frankly, nothing is easy to do in .NET. Paul obviously doesn't know,
or conveniently forgot, that Microsoft replaced Kodak with WIA
(Windows Image Acquisition Library). With WIA you can easily convert
between TIFF and JPEG (or png, bmp, etc.) and, btw, do lots of other
stuff like scan, print using photo print wizard, etc. all in VB6.

It's free. Download at:

http://www.microsoft.com/downloads/details.aspx?familyid=a332a77a-01b8-4de6-91c2-b7ea32537e29&displaylang=en