plus怎么实现切图效果
plus控件支持用GDI+任意扩展
import inet.http;var pngData = inet.http().get("http://www.baidu.com/img/baidu_logo.gif");var bitmap = gdip.bitmap( pngData )var bitmagNew = gdip.bitmap(50,50);bitmagNew.graphics.drawImageRectRect(bitmap,0,0,50,50,30,30,50,50)winform.plus.skin( background = { default = bitmagNew; })
关键代码就一句 bitmagNew.graphics.drawImageRectRect(bitmap,0,0,50,50,30,30,50,50)就算你不切图,你还是要指定一大堆坐标的
plus控件扩展是非常方便的,在winform.plus.onDrawBackground事件里,还可以自己用GDI+画,GDI+很方便刚才发的那个代码写复杂了,实际上用 bitmap.clone(30,30,50,50) 就可以了,本来想加个函数,发现已经有了
可以直接切分图像
winform.plus.skin( background = { default = gdip.bitmap( "你的图像路径" ).clone(30,30,50,50) ; })
jacen更新了bitmap库新增一个函数split,使切图更方便了.
import win.ui; /*DSG{{*/ var winform = win.form(text="aardio form";right=759;bottom=469) winform.add( button={cls="button";text="生成预览";left=512;top=368;right=760;bottom=468;z=3}; plus={cls="plus";left=135;top=107;right=405;bottom=335;bgcolor=15780518;z=1}; plus2={cls="plus";left=544;top=69;right=737;bottom=196;bgcolor=12639424;notify=1;repeat="center";z=2}; static={cls="static";text="行数";left=514;top=317;right=546;bottom=337;transparent=1;z=6}; static2={cls="static";text="列数";left=642;top=316;right=677;bottom=336;transparent=1;z=7}; 上={cls="edit";text="0";left=232;top=72;right=298;bottom=99;align="center";edge=1;multiline=1;z=8}; 下={cls="edit";text="0";left=225;top=341;right=291;bottom=368;align="center";edge=1;z=10}; 列数={cls="edit";text="4";left=691;top=314;right=757;bottom=341;align="center";edge=1;z=5}; 右={cls="edit";text="0";left=415;top=210;right=481;bottom=237;align="center";edge=1;z=9}; 左={cls="edit";text="0";left=57;top=209;right=123;bottom=236;align="center";edge=1;z=11}; 行数={cls="edit";text="1";left=554;top=314;right=620;bottom=341;align="center";edge=1;z=4} ) /*}}*/ var file = ""; import gdip.bitmap; winform.onDropFiles = function(files){ file = files[1]; winform.plus.background = file; } winform.button.oncommand = function(id,event){ var bitback = gdip.bitmap(file).split(winform.列数.text,winform.行数.text,winform.上.text,winform.右.text,winform.下.text,winform.左.text) winform.plus2.skin( background = { default = bitback[1]; hover = bitback[2]; active = bitback[3]; } ) } winform.plus2.oncommand = function(id,event){ } winform.show() win.loopMessage();
登录后方可回帖