Qt Quick Shared Image Provider
요약
이 모듈은 여러 Qt Quick 애플리케이션이 동일한 로컬 이미지 파일을 사용하는 사용 사례에서 메모리를 절약하는 기능을 제공합니다. 이 모듈은 디코딩된 QImage 데이터를 공유 시스템 메모리에 배치하여 모든 프로세스에서 액세스할 수 있도록 합니다( QSharedMemory 참조).
이 모듈은 CPU 메모리만 공유합니다. GPU 메모리나 텍스처 공유는 제공하지 않습니다.
사용 방법
이 모듈을 사용하려면 다음과 같이 임포트하세요:
import Qt.labs.sharedimage
공유 기능은 QQuickImageProvider 을 통해 제공됩니다. 이미지의 URL 소스에 "image:" 구문을 사용하고 그 뒤에 공유 식별자, 그 뒤에 이미지 파일 경로를 사용합니다. 예를 들어
Image { source: "image://shared/usr/share/wallpapers/mybackground.jpg" }
이 경우 /usr/share/wallpapers/mybackground.jpg 파일을 찾습니다. 이 작업을 수행하는 첫 번째 프로세스는 일반적인 Qt 이미지 로딩을 사용하여 이미지 파일을 읽습니다. 그런 다음 디코딩된 이미지 데이터는 전체 파일 경로를 키로 사용하여 공유 메모리에 배치됩니다. 이후 동일한 이미지를 요청하는 프로세스는 공유 메모리에 이미 데이터가 있다는 것을 알게 됩니다. 그러면 이미지 파일을 다시 로드하는 대신 이를 사용합니다.
공유 이미지 데이터는 마지막 프로세스가 공유 이미지에 대한 마지막 참조를 삭제할 때까지 계속 사용할 수 있으며, 그 시점에 공유 이미지 데이터는 자동으로 해제됩니다.
시스템 메모리 공유를 사용할 수 없는 경우 공유 이미지 제공업체는 공유되지 않은 일반 이미지 로딩으로 돌아갑니다.
파일 경로는 절대 경로여야 합니다. 상대 경로를 사용하려면 Qt.resolvedUrl()을 사용하여 절대 경로로 만들고 URL 체계를 바꾸세요. 예를 들어
... property string imagePrefix: Qt.resolvedUrl("../myimages/").replace("file://", "image://shared/") Image { source: imagePrefix + "myimage.png" }
공유 이미지 모듈은 직접 사용할 수 있는 QML 유형을 제공하지 않습니다.
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.