[英]Split image into cells QML/QT
我想知道是否有一種方法可以在QML或C ++中將圖像拆分為單元格(即4 * 4網格)? 所以說我將圖像加載到窗口/矩形中並希望將其拆分為網格,以便以后能夠分別處理每個單元格。 提前致謝。
您也可以將圖像加載到具有偏移的圖像項中。 由於一旦加載的圖像被緩存,就不會有額外的開銷。
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.