Pb for converting bmp pic to Jpeg in Lotus Script

Hello,

i developped a scan function in lotus script with TWAIN dll.

Now, i would like to convert my bmp file into an Jpg File.

I wtire a function SaveAsJpg using the dll IMGDLL but it doens’t work.

I use Kernell32.dll functions (globallock, unlock, free) and maybe the problem is there…

If someone have already used this kind of functions, thanks for help.

I give you the code of my sub SaveAsJpg :


Sub SaveAsJpg(FileBmp As String,FileJpg As String)

Dim HpRgb As Long

Dim PRgb As Long

Dim widthr As Integer

Dim height As Integer

Dim var As Variant

Call ImgDLLStringInitDLL(“{4EF99980-8EAE-11d2-922D-00104B307E04}”)

HpRgb=ImgDLLReadRGBFromBMP(FileBmp,lWidth,lheight)

PRgb=GlobalLock(HpRgb) 'DLL KERNEL32.DLL

retour = ImgDLLSaveRGBToJPG(FileJpg,PRgb,width,height,75,1,0)

Var = GlobalUnlock(HpRgb) 'DLL KERNEL32.DLL

GlobalFree(HpRgb) 'DLL KERNEL32.DLL


→ here is the code of the declarations :

Declare Function GlobalLock Lib “Kernel32.dll” (Byval hMem As Long) As Long 'DLL KERNEL32.DLL

Declare Function GlobalUnlock Lib “Kernel32.dll” (Byval hMem As Long) As Long 'DLL KERNEL32.DLL

Declare Private Function GlobalFree Lib “Kernel32.dll” (Byval hMem As Long) As Long 'DLL KERNEL32.DLL

Declare Sub ImgDLLStringInitDLL Lib “IMGDLL.DLL” (initString As String )

Declare Function ImgDLLReadRGBFromBMP Lib “IMGDLL.DLL” (Byval fileName As String, Byval widths As Integer, Byval height As Integer) As Long

Declare Function ImgDLLSaveRGBToJPG Lib “IMGDLL.DLL” ( fileName As String, Byval pBuf As Long, uWidthPix As Integer, uHeight As Integer, uQuality As Integer, bColor As Integer, bProgressive As Integer) As Integer

Subject: pb for converting bmp pic to Jpeg in Lotus Script .

I suspect that your Declare statements for IMGDLL are wrong. Normally you always use Byval with a String, even though it seems to make no sense. I wonder if you also need Byval with some or all of the Integer arguments. Do you have the documentation or C headers for these functions?

Subject: RE: pb for converting bmp pic to Jpeg in Lotus Script .

Hi Rod,

Here is the C headers of the functions :

void IMGEXP ImgDLLStringInitDLL(const char * initString);

HGLOBAL IMGEXP ImgDLLReadRGBFromBMP(const char * fileName, UINT32 *width, UINT32 *height);

BOOL IMGEXP ImgDLLSaveRGBToJPG(const char * fileName,BYTE * pBuf,UINT32 uWidthPix,UINT32 uHeight,UINT32 uQuality,BOOL bColor,BOOL bProgressive);

Thanks for your help,

Stephane.

Subject: RE: pb for converting bmp pic to Jpeg in Lotus Script .

I think I would try these. I used Byval for each String and for any other data type that is not a pointer. I used Long for numbers that look as if they might contain 32 bits.Declare Sub ImgDLLStringInitDLL Lib “IMGDLL.DLL” _
( Byval initString As String )

Declare Function ImgDLLReadRGBFromBMP Lib “IMGDLL.DLL” _
( Byval fileName As String, width As Long, height As Long) As Long

Declare Function ImgDLLSaveRGBToJPG Lib “IMGDLL.DLL” _
( Byval fileName As String, Byval pBuf As Long, Byval uWidthPix As Long, Byval uHeight As Long _
, Byval uQuality As Long, Byval bColor As Integer, Byval bProgressive As Integer) As Integer