| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 318 人关注过本帖
标题:请教用MyFll.Fll截取图片问题?
只看楼主 加入收藏
wxzd123
Rank: 2
等 级:论坛游民
帖 子:393
专家分:69
注 册:2012-9-6
结帖率:87.76%
收藏
已结贴  问题点数:20 回复次数:7 
请教用MyFll.Fll截取图片问题?
图片附件: 游客没有浏览图片的权限,请 登录注册

 截取表单上的图片
Set Library To myFll AddI
l=ThisForm.Image1.Left
t=ThisForm.Image1.top
w=ThisForm.Image1.Left+ThisForm.Image1.Width
h=ThisForm.Image1.top+ThisForm.Image1.Height
RectToBmp(l,t,w,h,"tp.bmp")
图片附件: 游客没有浏览图片的权限,请 登录注册

当100%时可以,125%时乘以这个系数也可以,但150%是再乘这个系数截取的就不对了?哪位老师知道是什么问题?谢谢
搜索更多相关主题的帖子: ThisForm top 截取 图片 系数 
2024-10-28 15:50
sych
Rank: 6Rank: 6
等 级:侠之大者
威 望:7
帖 子:317
专家分:448
注 册:2019-10-11
收藏
得分:0 
原生的windows窗口,菜单有自己的句柄
vfp的窗口不是纯粹的表单,还包括菜单栏,所以用窗口句柄获取的图像包括菜单和表单

2024-10-29 10:38
wxzd123
Rank: 2
等 级:论坛游民
帖 子:393
专家分:69
注 册:2012-9-6
收藏
得分:0 
sych老师您好,可是当100%截取没有问题,当125%时用125%当系数也没有问题,当150%时用150%当系数就不对了
2024-10-29 14:13
吹水佬
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:451
帖 子:10607
专家分:43186
注 册:2014-5-20
收藏
得分:0 
可能是VFP对系统显示的缩放设置兼容问题
2024-10-29 14:34
wxzd123
Rank: 2
等 级:论坛游民
帖 子:393
专家分:69
注 册:2012-9-6
收藏
得分:0 
谢谢
2024-10-29 21:39
sych
Rank: 6Rank: 6
等 级:侠之大者
威 望:7
帖 子:317
专家分:448
注 册:2019-10-11
收藏
得分:0 
是的,设置为150%时,我们在设计时拖放image控件就能发现,显示的虚框是不准确的

2024-10-31 10:52
sych
Rank: 6Rank: 6
等 级:侠之大者
威 望:7
帖 子:317
专家分:448
注 册:2019-10-11
收藏(2)
得分:20 
自己写一个,可以避免屏幕放大造成的困扰,而且屏幕被遮挡也可以正确截屏
PUBLIC oform1

oform1=NEWOBJECT("form1")
oform1.Show
RETURN

DEFINE CLASS form1 AS form


    ShowWindow = 2
    DoCreate = .T.
    Caption = "Form1"
    BackColor = RGB(240,240,0)
    Name = "Form1"


    ADD OBJECT image1 AS image WITH ;
        Picture = GETPICT(),;
        Stretch = 2, ;
        Height = 200, ;
        Left = 84, ;
        Top = 24, ;
        Width = 200, ;
        Name = "Image1"


    ADD OBJECT command1 AS commandbutton WITH ;
        Top = 108, ;
        Left = 324, ;
        Height = 25, ;
        Width = 60, ;
        Caption = "截图", ;
        Name = "Command1"


    PROCEDURE command1.Click
        thisformTitleBar=thisform.TitleBar
        thisformBorderStyle= thisform.BorderStyle
        thisform.TitleBar=0
        thisform.BorderStyle= 0

        hwnd=thisform.hwnd
        tcFile="c:\tp.bmp"
        lleft=thisform.image1.Left
        ltop=thisform.image1.Top
        lwidth=thisform.image1.Width
        lheight=thisform.image1.height
        DECLARE INTEGER GetDesktopWindow IN win32api
        DECLARE INTEGER GetDC IN win32api INTEGER hwnd
        Declare SHORT GetWindowRect IN user32 INTEGER hwnd, STRING @ lpRect
        DECLARE Long GetWindowDC IN WIN32API  Long hWnd
        DECLARE Long ReleaseDC IN WIN32API  Long hWnd, Long hDc
        DECLARE Long CreateCompatibleDC IN WIN32API  Long hDc
        DECLARE Long DeleteDC IN WIN32API  Long hDc
        DECLARE Long CreateCompatibleBitmap IN WIN32API  Long hDc, Long nWidth, Long nHeight
        DECLARE Long SelectObject IN WIN32API  Long hDc, Long hObject
        DECLARE Long DeleteObject IN WIN32API  Long hObject
        DECLARE Long GdiplusStartup IN gdiplus Long @ token, String @ inputbuf, Long @ outputbuf
        DECLARE Long GdiplusShutdown IN gdiplus  Long token
        DECLARE Long GdipCreateBitmapFromHBITMAP IN gdiplus  Long hbitmap, Long hpalette, Long @ hGpBitmap
        Declare Long GdipCreateBitmapFromScan0 in GdiPlus.dll ;
            Integer width, Integer height, Integer stride, Long format, Long scan0, Long @ bitmap
        Declare Long GdipGetImageGraphicsContext in GdiPlus.dll    Long image, Long @ graphics
        DECLARE LONG GdipDeleteGraphics IN GDIPLUS LONG graphics
        Declare Long GdipDrawImageRectI in GdiPlus.dll ;
            Long graphics, Long image, Integer x, Integer y, Integer width, Integer height

        DECLARE Long GdipDisposeImage IN gdiplus  Long image
        DECLARE Long GdipSaveImageToFile IN gdiplus Long nImage, String FileName,String @ clsIdEncoder, Long encoderParams
        DECLARE INTEGER CLSIDFromString IN ole32 STRING lpsz, STRING @pclsid
        DECLARE INTEGER PrintWindow IN win32api INTEGER,INTEGER ,INTEGER
        DECLARE INTEGER BitBlt IN gdi32;
        INTEGER hDestDC, INTEGER x, INTEGER y,;
        INTEGER nWidth, INTEGER nHeight, INTEGER hSrcDC,;
        INTEGER xSrc, INTEGER ySrc, INTEGER dwRop
        #define SRCCOPY 0x00CC0020
        LOCAL cFileExtName, cEncoder, iInputBuf, iResult, hDesktopDc, hVDc, hBitmap, hToken, hGdipBitmap,encoderClsid,lpRect,lnWidth,lnheight,abc
        m.cFileExtName =LOWER( JUSTEXT( m.tcFile ))
        m.hDesktopDc = GetDC( m.hWnd )
        m.hVdc = CreateCompatibleDC( m.hDesktopDc )
        lpRect = REPLI (Chr(0), 16)
        =GetWindowRect (m.hWnd, @lpRect)
        lnWidth=ctobin(SUBS(lpRect,9,4),'4rs')-ctobin(SUBS(lpRect,1,4),'4rs')
        lnHeight=ctobin(SUBS(lpRect,13,4),'4rs')-ctobin(SUBS(lpRect,5,4),'4rs')
        m.hBitmap = CreateCompatibleBitmap( m.hDesktopDc,lnWidth,lnHeight )
        ABC=SelectObject( m.hVdc, m.hBitmap )
        IF hwnd=GetDesktopWindow()
            =BitBlt(hvDC,0,0,lnwidth,lnHeight,hDesktopDc,0,0,SRCCOPY)
        else
            =PrintWindow(m.hWnd,m.hVdc,0)
        endif
        m.hToken = 0
        m.iInputBuf = PADR(CHR(1), 16, CHR(0))
        m.iResult = -1
        IF ( 0 == GdiplusStartup( @ m.hToken, @ m.iInputBuf, 0 ))
            m.hGdipBitmap = 0
            IF ( 0 == GdipCreateBitmapFromHBITMAP(m.hBitmap, 0, @ m.hGdipBitmap ))
                lnFormat=0x00021808
                graphics = 0
                resizedImage = 0
                =GdipCreateBitmapFromScan0(lwidth,lheight, 0, m.lnFormat, 0, @resizedImage)
                =GdipGetImageGraphicsContext(m.resizedImage, @graphics)
                =GdipDrawImageRectI(m.graphics, m.hGdipBitmap,-lleft,-ltop,lnwidth,lnheight)
                m.encoderClsid  = "{557CF40"+chr(47+(at(m.cFileExtName,"bmpjpggif      tifpng")+2)/3)+"-1A04-11D3-9A73-0000F81EF32E}"
                cEncoder= REPLICATE(CHR(0),16)
                CLSIDFromString(STRCONV(m.encoderClsid + CHR(0), 5), @cEncoder)
                m.iResult = GdipSaveImageToFile(m.resizedImage,STRCONV( m.tcFile+CHR(0), 5 ), @ m.cEncoder, 0 )
                GdipDeleteGraphics(graphics)
                GdipDisposeImage(m.resizedImage)
                GdipDisposeImage( m.hGdipBitmap )
            ENDIF
            GdiplusShutdown( m.hToken )
        ENDIF
        =DeleteObject( m.hBitmap )
        =DeleteDC( m.hVdc )
        =ReleaseDC( 0, m.hDesktopDc )
        thisform.TitleBar=thisformTitleBar
        thisform.BorderStyle=thisformBorderStyle
        RETURN
    ENDPROC


ENDDEFINE
2024-10-31 11:07
wxzd123
Rank: 2
等 级:论坛游民
帖 子:393
专家分:69
注 册:2012-9-6
收藏
得分:0 
sych老师太强了,能否编译成文件方便在程序中任何地方方便调用,截图是界面跳动,谢谢
2024-10-31 20:11
快速回复:请教用MyFll.Fll截取图片问题?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.024878 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved