[英]Split image into cells QML/QT
I was wondering if there was a way to split image into cells (ie 4*4 grid) in QML or C++? 我想知道是否有一种方法可以在QML或C ++中将图像拆分为单元格(即4 * 4网格)? So say I load an image in a window/rectangle and want to split it in a grid, to be later able to manipulate each cell separately. 所以说我将图像加载到窗口/矩形中并希望将其拆分为网格,以便以后能够分别处理每个单元格。 Thanks in advance. 提前致谢。
Also you can load an image into Image item with offset. 您也可以将图像加载到具有偏移的图像项中。 Since once loaded image is cached there will be no additional overhead. 由于一旦加载的图像被缓存,就不会有额外的开销。
Window {
visible: true
width: 600
height: 600
Component {
id: imgComponent
Item {
property int row: index / 3
property int col: index % 3
x: col * (200)
y: row * (200)
width: 200
height: 200
clip: true
Image {
x: col * (-200)
y: row * (-200)
width: 600
height: 600
fillMode: Image.Pad
source: "http://images.all-free-download.com/images/graphiclarge/green_homes_polar_coordinates_02_hd_picture_165795.jpg"
Component.onCompleted: console.log(row, col);
}
MouseArea {
anchors.fill: parent
drag.target: parent
}
}
}
Repeater {
model: 9
delegate: imgComponent
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.