import com.picture; import util.metaProperty; import com.interface; namespace com.interface; class IPicture{ ctor( ){ this = ..com.interface.IUnknown(); }; pointer get_Handle = "int(pointer &pHandle)"; pointer get_hPal = "int(pointer &phPal)"; pointer get_Type = "int(word &pType)"; pointer get_Width = "int(int &pWidth)"; pointer get_Height = "int(INT &pHeight)"; pointer Render = "int(int hDC,int x,int y, int cx,int cy, int xSrc, int ySrc, int cxSrc,int cySrc,struct pRcWBounds)"; pointer set_hPal = "int(POINTER hPal)"; pointer get_CurDC = "int(pointer &phDC)"; pointer SelectPicture = "int(pointer hDCIn,pointer &phDCOut,pointer &phBmpOut)"; pointer get_KeepOriginalFormat = "int(bool &pKeep)"; pointer put_KeepOriginalFormat = "int(bool keep)"; pointer PictureChanged = "int()"; pointer SaveAsFile = "int(pointer pStream,bool fSaveMemCopy,int &pCbSize)"; pointer get_Attributes = "int(INT &pDwAttr)"; } namespace IPicture{ IID = "{7BF80980-BF32-101A-8BBB-00AA00300CAB}"; Query = function(obj){ if(obj){ return { _object = ..com.interface(obj,..com.interface.IPicture); @_metaProperty; } } } Load = function(strfile){ return Query(..com.picture.load(strfile)); } self.PrintClient = function(hwnd,x,y,w,h){ return Query(..com.picture.printClient(hwnd,x,y,w,h)); } self.PrintWindow = function(hwnd,x=0,y=0,w,h,clientOnly) { return Query(..com.picture.printWindow(hwnd,x,y,w,h,clientOnly)); } self.SnapClient = function(hwnd,x,y,w,h){ return Query(..com.picture.snapClient(hwnd,x,y,w,h)); } Snap = function(hwnd,x=0,y=0,w,h,clientOnly) { return Query(..com.picture.snap(hwnd,x,y,w,h,clientOnly)); } _metaProperty = ..util.metaProperty( saveToBuffer = function(saveMemCopy){ if(saveMemCopy===null) saveMemCopy = true; var hr,pstream = ::CreateStreamOnHGlobal( , true ); owner._object.SaveAsFile(pstream,saveMemCopy,0); var hr,handle = ::GetHGlobalFromStream(pstream); var size = ::GlobalSize(handle); var ptr = ::GlobalLock(handle); var bytes = ..raw.buffer(size,ptr); ::GlobalUnlock(handle) ..com.Release(pstream); return bytes; }; saveAsFile = function(stream,saveMemCopy){ if(type.isString(stream)){ var buf = owner.saveToBuffer(saveMemCopy) return ..string.save(stream,buf) } if(saveMemCopy===null) saveMemCopy = true; var hr,size = owner._object.SaveAsFile(stream,saveMemCopy,0); if( hr>=0/*_SUCCEEDED*/ ) return size; }; pictureChanged = function(){ return owner._object.pictureChanged(); }; selectPicture = function(hDCIn){ var hr,phDCOut,phBmpOut = owner._object.SelectPicture(hDCIn); if( hr>=0/*_SUCCEEDED*/ ) return phDCOut,phBmpOut; }; render = function(hDC,x,y, cx,cy, xSrc, ySrc, cxSrc,cySrc,pRcWBounds){ pRcWBounds := {}; var hr = owner._object.Render(hDC,x,y, cx,cy, xSrc, ySrc, cxSrc,cySrc,pRcWBounds); if( hr>=0/*_SUCCEEDED*/ ) return true; }; handle = { _get = function(){ var hr,hd = owner._object.get_Handle(); if( hr>=0/*_SUCCEEDED*/ ) return hd; } }; hPal = { _get = function(){ var hr,hp = owner._object.get_hPal(); if( hr>=0/*_SUCCEEDED*/ ) return hp; } _set = function(v){ owner._object.set_hPal(v); } }; attributes = { _get = function(){ var hr,a = owner._object.get_Attributes(0); if( hr>=0/*_SUCCEEDED*/ ) return a; } }; keepOriginalFormat = { _get = function(){ var hr,f = owner._object.get_KeepOriginalFormat(0); if( hr>=0/*_SUCCEEDED*/ ) return f; } _set = function(v){ owner._object.put_KeepOriginalFormat(v); } }; type = { _get = function(){ var hr,t = owner._object.get_Type(0); if( hr>=0/*_SUCCEEDED*/ ) return t; } }; width = { _get = function(){ var hr,w = owner._object.get_Width(0); if( hr>=0/*_SUCCEEDED*/ ) return w; } }; height = { _get = function(){ var hr,w = owner._object.get_Height(0); if( hr>=0/*_SUCCEEDED*/ ) return w; } }; curDC = { _get = function(){ var hr,w = owner._object.get_CurDC(); if( hr>=0/*_SUCCEEDED*/ ) return w; } }; curDC = { _get = function(){ var hr,w = owner._object.get_CurDC(); if( hr>=0/*_SUCCEEDED*/ ) return w; } }; ) } /**intellisense(com.interface.IPicture) Query(.(IPicture对象) = 参数为com.picture 对象\n返回 com.interface.IPicture 接口对象 Load(__/*请输入文件路径*/) = 载入图像并返回 com.interface.IPicture 接口对象,\n参数也可以指定资源路径、或者图像的内存数据\n如果已经导入了inet.http,加载路径可以使用小写http,https开头的网址,网址长度必须小于1040字节 Snap(.(窗口句柄,左坐标,顶坐标,宽,高) = 自屏幕抓取窗口图象并返回 com.interface.IPicture 接口对象,\n截图结果会包含透明部分的背景图像,\n所有参数都是可选参数 SnapClient(.(窗口句柄,左坐标,顶坐标,宽,高) = 自屏幕抓取窗口客户区图像并返回 com.interface.IPicture 接口对象,\n截图结果会包含透明部分的背景图像,\n所有参数都是可选参数 PrintWindow(.(窗口句柄,左坐标,顶坐标,宽,高) = 后台抓取窗口图象并返回 com.interface.IPicture 接口对象\n所有参数都是可选参数 PrintClient(.(窗口句柄,左坐标,顶坐标,宽,高) = 后台抓取窗口客户区图像并返回 com.interface.IPicture 接口对象 \n所有参数都是可选参数 Query() = !RawIPicture. Load() = !RawIPicture. Snap() = !RawIPicture. SnapClient() = !RawIPicture. PrintWindow() = !RawIPicture. PrintClient() = !RawIPicture. end intellisense**/ /**intellisense() !RawIPicture.saveToBuffer(.(saveMemCopy) = 保存图像到 buffer 对象,只能保存为 bmp 格式,\nsaveMemCopy指定是否保存内存副本,默认为true !RawIPicture.saveAsFile(.(stream,saveMemCopy) = 保存图像,成功返回保存大小,\n只能保存为bmp格式,\nstream参数可以是 fsys.stream 对象或 *.bmp 文件路径,\naveMemCopy指定是否保存内存副本,默认为true !RawIPicture.pictureChanged() = 图像是否已被修改 !RawIPicture.selectPicture(.(hDCIn) = 选择绘图设备\n成功返回原设备,以及位图句柄 !RawIPicture.render(.(hDC,x,y, cx,cy, xSrc, ySrc, cxSrc,cySrc,pRcWBounds) = 绘图\nhdc 绘图设备句柄\nx,y 设备显示坐标\ncx,cy 显示长度和宽度\nxSrc,ySrc 源图像偏移坐标\ncxSrc,cySrc 源图像输出宽度和高度,注意位图在内存是倒过来的,cySrc要取负数 prcWBounds是指向目标图元设备环境句柄的指针,一般为NULL。 !RawIPicture.handle = 句柄 !RawIPicture.hPal = 调色板 !RawIPicture.attributes = 选项数值 !RawIPicture.keepOriginalFormat = 保持格式 !RawIPicture.type = 图像类型\n图标还是位图 !RawIPicture.width = 宽\n单位是0.01毫米而非像素 !RawIPicture.height = 高\n单位是0.01毫米而非像素 !RawIPicture.curDC = 当前绘图设备 end intellisense**/