Hi, I wonder how to use the SaveAs function to save the Picture as *.jpg?
Regards Bjorn
Using SavePicture, you can only save pictures (gif, jpg and bmp) as bitmaps
or icons as icons. You would need an ActiveX control or something to write
pictures in jpg format. There is a free one called PicFormat32 available
here:
The sample code worked great! I had to download the vic32.dll,
but after that there were no problems. I simply cut, pasted, and
changed the source.bmp and output.jpg names and it worked. Thanks so
much.
I had applied the source code and the vic32.dll.
When the program was excuted, the message showed "not enough memory"?
Why did the problem came up?
How much memory should I have?
I don't think you can download this for free. You will have to
pay for it. One place it can be bought from is Catenary
Systems. It isn't cheap at $499, however. For a free way
to save JPEG images, try PicFormat32.
From:
loopa chakraborty <red_rosemarry @ yahoo.co.in>
Date:
Saturday, October 11, 2003 at 15:56:11
Comments:
in the code given in the net and mentioned below where do i declare the following
[Declare Function bmpinfo Lib "VIC32.DLL" (ByVal Fname As String, bdat As BITMAPINFOHEADER) As Long]
etc.
Reply:
You put this code in the General Declarations section of your code.
From:
loopa chakraborty <red_rosemarry @ yahoo.co.in>
Date:
Friday, October 10, 2003 at 16:58:38
Comments:
to convert bmp files to jpg file i am usin vic32.dll
do i need to register this dll ?if so how to register it
while converting how do i load the bmp file and allocate workspace to convert to jpg
"The Victor Image Processing Library is an application developers' image toolkit, a collection of functions that allow you to create image applications. Victor gives your programs powerful image processing, color reduction, display, TWAIN scanning, printing, file handling, and converting capabilities.
"Create your applications in Visual Basic, VB.NET, C/C++, Java, or any other programming language and give them support for
BMP, GIF, JPEG, PCX, PNG, TGA, and TIFF image file formats."
I've tried it out and it works perfect, the only 'problem' is: it works with files on disk, so you have to save your picture temporarily as bmp, then use PicFormat to convert it, and then delete the temp bmp.
BMP to JPEG - the Visual Basic Source Code
Requires Victor Image Processing Library for 32-bit Windows v 5 or higher.
Private Sub mnuconvertBMPtoJPG_Click()
Dim tmpimage As imgdes
' Image descriptors
Dim tmp2image As imgdes
Dim rcode As Long
Dim quality As Long
Dim vbitcount 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 we're to load
rcode = bmpinfo(bmp_fname, bdat)
If (rcode <> NO_ERROR) Then
MsgBox "Cannot find file", 0, "Error encountered!"
Exit Sub
End If
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.biWidth, 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.biWidth, 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
.......... Add these defines and declarations to your Global module ...........
' Image descriptor
Type imgdes
ibuff As Long
stx As Long
sty As Long
endx As Long
endy As Long
buffwidth As Long
palette As Long
colors As Long
imgtype As Long
bmh As Long
hBitmap As Long
End Type
Type BITMAPINFOHEADER
biSize As Long
biWidth As Long
biHeight As Long
biPlanes As Integer
biBitCount As Integer
biCompression As Long
biSizeImage As Long
biXPelsPerMeter As Long
biYPelsPerMeter As Long
biClrUsed As Long
biClrImportant As Long
End Type
Declare Function bmpinfo Lib "VIC32.DLL" (ByVal Fname
As String, bdat As
BITMAPINFOHEADER)
As Long
Declare Function allocimage Lib "VIC32.DLL" (image
As imgdes, ByVal wid
As Long, ByVal leng
As Long, ByVal BPPixel
As Long) As Long
Declare Function loadbmp Lib "VIC32.DLL" (ByVal Fname
As String, desimg As
imgdes)
As Long
Declare Sub freeimage Lib "VIC32.DLL" (image
As imgdes)
Declare Function convert1bitto8bit Lib "VIC32.DLL"
(srcimg
As imgdes, desimg As
imgdes)
As Long
Declare Sub copyimgdes Lib "VIC32.DLL"
(srcimg
As imgdes, desimg As
imgdes)
Declare Function savejpg Lib "VIC32.DLL" (ByVal Fname
As String, srcimg As
imgdes,
ByVal quality As
Long) As Long
Martin Allen 1999 - 2011. Last updated
Tuesday 09 August 2011 08:07:08 PM +0100.