Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. [SOLVED]Read Image from Android Storage in Qml
Forum Updated to NodeBB v4.3 + New Features

[SOLVED]Read Image from Android Storage in Qml

Scheduled Pinned Locked Moved QML and Qt Quick
7 Posts 4 Posters 5.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    beemaneni
    wrote on 1 Aug 2014, 10:07 last edited by
    #1

    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
    }@

    Bala B
    Infinite Computer systems
    Chennai

    1 Reply Last reply
    0
    • P Offline
      P Offline
      p3c0
      Moderators
      wrote on 1 Aug 2014, 10:14 last edited by
      #2

      You should prepend file:// to the path.

      157

      1 Reply Last reply
      0
      • B Offline
        B Offline
        beemaneni
        wrote on 1 Aug 2014, 11:09 last edited by
        #3

        hi
        thanks...it works fine..
        here is code..

        source: "file:///storage/sdcard0/DCIM/IMG_001.jpg"

        Thank u so much :-)

        Bala B
        Infinite Computer systems
        Chennai

        N 1 Reply Last reply 3 May 2019, 05:57
        0
        • Z Offline
          Z Offline
          zsb123
          wrote on 11 Aug 2014, 01:05 last edited by
          #4

          Hello.

          I'm trying to do exactly the same. However I get a totally black image back instead of my original image.

          Would you tell me if you had any similar problems, and if so, how you solved them?

          1 Reply Last reply
          0
          • B Offline
            B Offline
            beemaneni
            wrote on 11 Aug 2014, 12:09 last edited by
            #5

            Hi
            that should work absolutely fine...
            if not can u post ur code here...?

            Thanks

            Bala B
            Infinite Computer systems
            Chennai

            1 Reply Last reply
            0
            • Z Offline
              Z Offline
              zsb123
              wrote on 11 Aug 2014, 12:17 last edited by
              #6

              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!

              1 Reply Last reply
              0
              • B beemaneni
                1 Aug 2014, 11:09

                hi
                thanks...it works fine..
                here is code..

                source: "file:///storage/sdcard0/DCIM/IMG_001.jpg"

                Thank u so much :-)

                N Offline
                N Offline
                NoWhereMan1979
                wrote on 3 May 2019, 05:57 last edited by NoWhereMan1979 5 Apr 2019, 08:35
                #7

                @beemaneni be aware that some QML components like Canvas, save files into local paths, so you should subtract the "file://" part.

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved