Code: Select all
#streamtypeVIDEO = $73646976
#Lib = 0
Structure AVISTREAMINFO
fccType.l;
fccHandler.l;
dwFlags.l;
dwCaps.l;
wPriority.w;
wLanguage.w;
dwScale.l;
dwRate.l;
dwStart.l;
dwLength.l;
dwInitialFrames.l;
dwSuggestedBufferSize.l;
dwQuality.l;
dwSampleSize.l;
rcFrame.RECT;
dwEditCount.l;
dwFormatChangeCount.l;
szName.s[64];
EndStructure
Structure AVICOMPRESSOPTIONS
fccType.l;
fccHandler.l;
dwKeyFrameEvery.l;
dwQuality.l;
dwBytesPerSecond.l;
dwFlags.l;
lpFormat.l;
cbFormat.l;
lpParms.l;
cbParms.l;
dwInterleaveEvery.l;
EndStructure
If OpenLibrary ( #Lib , "AVIFIL32.DLL")
CallFunction ( #Lib, "AVIFileInit" )
avifile.s = SaveFileRequester ( "AVI File", "", "Video|*.avi", 0 )
If ReadFile(0, "image.bmp")
FileSeek(SizeOf(BITMAPFILEHEADER))
bmi.BITMAPINFO
ReadData(@bmi\bmiHeader, SizeOf(BITMAPINFOHEADER))
CloseFile(0)
Debug bmi\bmiHeader\biWidth
EndIf
Debug CallFunction( #Lib, "AVIFileOpen", @pAVIFile, @avifile.s, #OF_WRITE | #OF_CREATE, 0 )
strhdr.AVISTREAMINFO
strhdr\fccType = #streamtypeVIDEO
strhdr\fccHandler = 0
strhdr\dwScale = 1
strhdr\dwRate = 15
strhdr\dwSuggestedBufferSize = bmi\bmiHeader\biSize
SetRect_(@strhdr\rcFrame, 0, 0, bmi\bmiHeader\biWidth, bmi\bmiHeader\biHeight)
Debug CallFunction( #Lib, "AVIFileCreateStream", pAVIFile, @pAVIStream, @strhdr)
opts.AVICOMPRESSOPTIONS
Dim aopts(10)
aopts(0)=@opts
Debug CallFunction( #Lib, "AVISaveOptions", 0, 0, 1, @pAVIStream, @aopts(0))
Debug CallFunction( #Lib, "AVIMakeCompressedStream", @pAVICompressed, pAVIStream, @aopts(0), 0)
Debug CallCFunction( #Lib, "AVIStreamSetFormat", pAVICompressed, 0, @bmi,SizeOf(BITMAPINFO))
picl_X=bmi\bmiHeader\biWidth
picl_Y=bmi\bmiHeader\biHeight
size=picl_X*picl_Y*(bmi\bmiHeader\biBitCount/8)
*mem = AllocateMemory(1,Size)
LoadImage(0, "image.bmp")
hBmp = ImageID()
hDC = StartDrawing(ImageOutput())
GetDIBits_(hDC,hBmp,1,picl_Y,*mem,@bmi,#DIB_RGB_COLORS)
StopDrawing()
Debug CallCFunction( #Lib, "AVIStreamWrite", pAVICompressed, 0, 1, *mem , Size, $10, 0,0)
Debug CallFunction( #Lib, "AVIStreamClose", pAVIStream )
Debug CallFunction( #Lib, "AVIStreamClose",pAVICompressed)
Debug CallFunction( #Lib, "AVIFileClose",pAVIFile )
CallFunction( #Lib, "AVIFileExit" )
CloseLibrary( #Lib )
EndIf
