[SOLVED]Read Image from Android Storage in Qml
-
Hi
I need to read an image from(ex: "/storage/sdcard0/DCIM/IMG_001.jpg") internal storage of android mobile to qml image source..I tried various ways..I could not do this.Please help me with ur ideas
@Image{
id: image
source: "/storage/sdcard0/DCIM/IMG_001.jpg" //doesnt work
}@ -
You should prepend file:// to the path.
-
Thank you for your help.
-I'm trying to set the source of the Image Element like that: @"file:///storage/emulated/0/Download/image.png"@ and the result is an absolutely black image.
I have also tried using QQuickImageProvider rendering the image like that @ QPixmap pixmap("/storage/emulated/0/Download/image.png");@ but the same problem occurs.
To my mainfest.xml I have this line added: <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
EDIT:
Oh, it seems like I figured it out. It works absolutely fine, but unfortunatelly not with the Download folder. I don't know what the problem is, there might be some extra permission reuired to acces the Download folder on Android. Or I don't know. -EDIT 2:
This solution is perfect. My problem was originated from trying to use images with a too large resolution. If I set the sourceSize property, it scales down my image to the desired resolution, and it works perfectly. Thank you! -
hi
thanks...it works fine..
here is code..source: "file:///storage/sdcard0/DCIM/IMG_001.jpg"
Thank u so much :-)
@beemaneni be aware that some QML components like Canvas, save files into local paths, so you should subtract the "file://" part.