gpt4 book ai didi

c++ - 将图像分割成单元格 QML/QT

转载 作者:行者123 更新时间:2023-11-30 03:35:08 29 4
gpt4 key购买 nike

我想知道是否有一种方法可以在 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
}
}

关于c++ - 将图像分割成单元格 QML/QT,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41473160/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com