【转oldbb的方法,供你参考】
**
** 图片拼接(左右)
**
DECLARE LONG GetDC IN user32 LONG
DECLARE LONG ReleaseDC IN user32 LONG, LONG
DECLARE LONG GdiplusStartup IN gdiplus LONG@, STRING@, LONG
DECLARE LONG GdiplusShutdown IN gdiplus LONG
DECLARE LONG GdipCreateBitmapFromScan0 IN gdiplus LONG, LONG, LONG, LONG, STRING@, LONG@
DECLARE LONG GdipGetImageGraphicsContext IN gdiplus LONG, LONG@
DECLARE LONG GdipCreateFromHDC IN gdiplus LONG, LONG@
DECLARE LONG GdipLoadImageFromFile IN gdiplus STRING@, LONG@
DECLARE LONG GdipGetImageWidth IN gdiplus LONG, LONG@
DECLARE LONG GdipGetImageHeight IN gdiplus LONG, LONG@
DECLARE LONG GdipSaveImageToFile IN gdiplus LONG, STRING@, STRING@, LONG
DECLARE LONG GdipDrawImageRectI IN gdiplus LONG, LONG, LONG, LONG, LONG, LONG
DECLARE LONG GdipDisposeImage IN gdiplus LONG
DECLARE LONG GdipDeleteGraphics IN gdiplus LONG
inFile1 = GETPICT("", "左边图片(&N):")
inFile2 = GETPICT("", "右边图片(&N):")
outFile = PUTFILE("保存为(&N):", "合成的图片", "bmp")
IF !FILE(inFile1) OR !FILE(inFile2) OR EMPTY(outFile)
RETURN
ENDIF
stGSI = 0h01000000000000000000000000000000
pGDI = 0
GdiplusStartup(@pGDI, @stGSI, 0)
pImage1 = 0
GdipLoadImageFromFile(STRCONV(inFile1+0h00,5), @pImage1)
nWidth1 = 0
GdipGetImageWidth(pImage1, @nWidth1)
nHeight1 = 0
GdipGetImageHeight(pImage1, @nHeight1)
pImage2 = 0
GdipLoadImageFromFile(STRCONV(inFile2+0h00,5), @pImage2)
nWidth2 = 0
GdipGetImageWidth(pImage2, @nWidth2)
nHeight2 = 0
GdipGetImageHeight(pImage2, @nHeight2)
nWidth = nWidth1 + nWidth2
nHeight = MAX(nHeight1, nHeight2)
PixelFormat_32bppARGB = 0x26200A
pBitmap = 0
GdipCreateBitmapFromScan0(nWidth, nHeight, 0, PixelFormat_32bppARGB, 0, @pBitmap)
pGraphics = 0
GdipGetImageGraphicsContext(pBitmap, @pGraphics)
GdipDrawImageRectI(pGraphics, pImage1, 0, 0, nWidth1, nHeight1)
GdipDrawImageRectI(pGraphics, pImage2, nWidth1, 0, nWidth2, nHeight2)
CLSID_BMP = 0h00F47C55041AD3119A730000F81EF32E
**CLSID_PNG = 0h06F47C55041AD3119A730000F81EF32E
GdipSaveImageToFile(pBitmap, STRCONV(outFile+0h00,5), CLSID_BMP, 0)
GdipDisposeImage(pImage1)
GdipDisposeImage(pImage2)
GdipDeleteGraphics(pGraphics)
GdipDisposeImage(pBitmap)
GdiplusShutdown(pGDI)
CLEAR
DrawImageWindowFromFile(_screen.hWnd, 10, 10, 500, 500*nHeight/nWidth, outFile)
CLEAR ALL
RETURN
FUNCTION DrawImageWindowFromFile(hWnd, nX, nY, nWidth, nHeight, cFileName)
LOCAL hDC, pImage, pGraphics
pImage = 0
GdipLoadImageFromFile(STRCONV(cFileName+0h00,5), @pImage)
hDC = GetDC(hWnd)
pGraphics = 0
GdipCreateFromHDC(hDC, @pGraphics)
GdipDrawImageRectI(pGraphics, pImage, nX, nY, nWidth, nHeight)
GdipDisposeImage(pImage)
GdipDeleteGraphics(pGraphics)
ReleaseDC(hWnd, hDC)
ENDFUNC