参考示例
图片附件: 游客没有浏览图片的权限,请
登录 或
注册
图片附件: 游客没有浏览图片的权限,请
登录 或
注册
*** test.prg ***
DECLARE LONG GetDC IN user32 LONG
DECLARE LONG ReleaseDC IN user32 LONG, LONG
DECLARE LONG CreateCompatibleDC IN gdi32 LONG
DECLARE LONG DeleteDC IN gdi32 LONG
DECLARE LONG CreateCompatibleBitmap IN gdi32 LONG, LONG, LONG
DECLARE LONG SelectObject IN gdi32 LONG, LONG
DECLARE LONG DeleteObject IN gdi32 LONG
DECLARE LONG BitBlt IN gdi32 LONG, LONG, LONG, LONG, LONG, LONG, LONG, LONG, LONG
DECLARE LONG GdiplusStartup IN gdiplus LONG@, STRING@, LONG
DECLARE LONG GdiplusShutdown IN gdiplus LONG
DECLARE LONG GdipCreateBitmapFromHBITMAP IN gdiplus LONG, LONG, LONG@
DECLARE LONG GdipDisposeImage IN gdiplus LONG
DECLARE LONG GdipSaveImageToFile IN gdiplus LONG, STRING@, STRING@, LONG
of
= CREATEOBJECT("form1")
of.show(1)
RETURN
DEFINE CLASS form1 As Form
backcolor = 0xFF
ADD OBJECT cmd1 as commandbutton WITH top=10,left=10,height=22,caption="截图"
ADD OBJECT image1 as image WITH top=40,left=10,height=100,;
stretch=2,picture="C:\temp\白眼圈鸟.jpg"
ADD OBJECT image2 as image WITH top=145,left=10,height=100,stretch=1
PROCEDURE cmd1.click
LOCAL cOutFile, nX, nY, nWidth, nHeight,;
stGSI, pGDI, hDC, pDC, hBitmap, pBitmap, cGUID
cOutFile = "C:\temp\tmp.jpg"
nX = thisform.image1.left
nY = thisform.image1.top
nWidth
= thisform.image1.width
nHeight = thisform.image1.height
stGSI = 0h01000000000000000000000000000000
pGDI = 0
GdiplusStartup(@pGDI, @stGSI, 0)
hDC = GetDC(thisform.hWnd)
pDC = CreateCompatibleDC(hDC)
hBitmap = CreateCompatibleBitmap(hDC, nWidth, nHeight)
SelectObject(pDC, hBitmap)
BitBlt(pDC, 0, 0, nWidth, nHeight, hDC, nX, nY, 0xCC0020)
&& SRCCOPY
cGUID = 0h01F47C55041AD3119A730000F81EF32E && jpg
pBitmap = 0
GdipCreateBitmapFromHBITMAP(hBitmap, 2, @pBitmap)
GdipSaveImageToFile(pBitmap, STRCONV(cOutFile+0h00,5), @cGUID, 0)
GdipDisposeImage(pBitmap)
DeleteObject(hBitmap)
DeleteDC(pDC)
ReleaseDC(thisform.hWnd, hDC)
GdiplusShutdown(pGDI)
thisform.image2.picture = cOutFile
ENDPROC
ENDDEFINE