Hi guys, I'm having problems converting .bmp to .jpg using vb6.
:icon_question:The idea is to convert .bmp to .jpg so i can import the saved image to a pdf file for email and/or printing.
I downloaded code that's supposed to convert .bmp to .jpg, but I get a compiler error saying I need to "specify user-type".
:)Any help would be appreciated.
---Here's the code---
Dim tmpimage As imagedes 'Image Descriptors
Dim tmp2image As imagedes
Dim rcode As Long
Dim quality As Long
Dim vbitcountcount As Long
Dim bdat As BITMAPINFOHEADER 'Reserve space for BMP struct
Dim bmp_fname As String
Dim jpg_fname As String
bmp_fname = "test.bmp"
jpg_fname = "test.jpg"
quality = 75
'get info on the file were going to load
rcode = bmpinfo(bmp_fname, bdat)
If (rcode <> NO_ERROR) Then
MsgBox "Cannot find file", 0, "Error encountered!"
Exit Sub
End If
''mr jelousy***************************
vbitcount = bdat.biBitCount
If (vbitcount >= 16) Then '16-,24- or 32-bit image is
'loaded into 24-bit buffer
vbitcount = 24
End If
'allocate space for an image
rcode = allocimage(tmpimage, bdat.biHeight, vbitcount)
If (rcode <> NO_ERROR) Then
MsgBox "Not enough Memory", 0, "Error encountered!"
Exit Sub
End If
'Load image
rcode = loadbmp(bmp_fname, tmpimage)
If (rcode <> NO_ERROR) Then
freeimage tmpimage ' Free image on Error
MsgBox "Cannot load file", 0, "Error encountered!"
Exit Sub
End If
If (vbitcount = 1) Then 'If we loaded a 1-bit image
',convert to 8-bit grayscale
'because jpeg only supports 8-bit
'grayscale or 24-bit color images
rcode = allocimage(tmp2image, bdat.biHeight, 8)
If (rcode = NO_ERROR) Then
rcode = convert1bitto8bit(tmpimage, tmp2image)
freeimage tmpimage 'replace 1-bit image with grayscale image
copyimgdes tmp2image, tmpimage
End If
End If
'save image
rcode = savejpg(jpg_fname, tmpimage, quality)
freeimage tmpimage
End Sub
:$I'm having problems understanding the code so even an explanation of the variables and functions would help alot.