图像自适应窗口控件显示,以窗口中心为基准
read_image (Image,'tooth_rim.png')
winWidth:=640
winHeight:=880
dev_resize_window_fit_size (0, 0, winWidth, winHeight, -1, -1)
get_image_size (Image, imgWidth, imgHeight)
ScaleWidth:=imgWidth/(winWidth*1.0)
ScaleHeight:=imgHeight/(winHeight*1.0)
if(ScaleWidth>=ScaleHeight)
row1:= -(1.0) * ((winHeight * ScaleWidth) - imgHeight) / 2
column1 := 0
row2 := row1 + winHeight * ScaleWidth
column2:= column1 + winWidth * ScaleWidth
else
row1:= 0
column1 := -(1.0) * ((winWidth * ScaleHeight) - imgWidth) / 2
row2 := row1 + winHeight * ScaleHeight
column2:= column1 + winWidth * ScaleHeight
endif
dev_clear_window ()
dev_set_part (row1, column1, row2, column2)
dev_display (Image)
&nb

本文介绍了一种图像在自适应窗口中显示的方法,确保图像以窗口中心为基准进行展示,并实现通过鼠标进行图像的缩放和平移功能。详细阐述了如何根据窗口大小调整图像显示区域,以及如何响应鼠标滚轮和拖动事件来改变图像的显示比例和位置。
最低0.47元/天 解锁文章
1823

被折叠的 条评论
为什么被折叠?



