Can't load image in qt android - android

I have an address to my mobile image like
/sdcard/DCIM/Camera/1.jpg
or
/storage/emulated/0/DCIM/Camera/1.jpg
I use QFile and QImage for read that
when read image with qfile, it can't open that but exist function return true
qimage also can't load image
I also use file:// before upper addresses but not worked.
I use qt 5.8 and api 23(android 6) and i make android manifest file and take permission for read and write to storage.

Your problem may be related to using too large resolution images. If you set the sourceSize property, it scales down youre image to the desired resolution.

Related

google map android - cannot set map icon from BitmapDescriptorFactory.fromAsset

I am trying to use custom marker using marker image that is provided as .bmp file. I am building cross platform application using Flutter and this is the native code for Android. The image is from the assets in pubspec.yaml in flutter project.
marker = map
.addMarker(MarkerOptions()
.position(annotation.coordinate)
.title(annotation.title)
.icon(BitmapDescriptorFactory.fromAsset("lib/green_circle.bmp")))
I got this error message for the code above:
com.google.maps.api.android.lib6.common.apiexception.b: Failed to
decode image. The provided image must be a Bitmap.
I checked the image, and it's bmp
There seems to be a problem with the way it handles the images. It does accept png, jpg and bmp, as I have tested with all of those, but I also had that same issue with some files of these formats (png and bmp).
What I did was open some of the files on another image editor, overwrite the files, and it worked. Weirdly, the files were normal png icons from Adobe Photoshop, and they didn't work.
If you have any issues or doubts, maybe try debugging with files from other sources, or editing it and saving it again.
I received the same error message for a different reason. My file was fine, but I provided an incorrect path to the file.
Make sure you get the directory and filename correct!

Why do I need to create a file on disk to get a full size image taken by the camera

I'm working with the camera in Android for the first time and am hung up on a few things that seem to be required. I've given the app Camera permissions and I can see the thumbnail image.
After searching I found this google example that states I must create a file to see the full size image. Why? Also, in creating a file I have to ask the user for permission to write to disk. I have no intention of saving the photos, however I need to create a file and and now need to worry about file cleanup.
Lastly, this full sized image has no EXIF data. I've found a way to create a bitmap with the file to rotate the image. Is this correct? It seems like a lot of work to just see a correctly oriented image that i've just taken.
After searching I found this google example that states I must create a file to see the full size image. Why?
A full-size photo is much larger than the 1MB limit for Intent contents.
I have no intention of saving the photos, however I need to create a file and and now need to worry about file cleanup.
Then do not use ACTION_IMAGE_CAPTURE. Use the camera APIs directly (android.hardware.Camera, android.hardware.camera2.*) or via a third-party wrapper (Fotoapparat, CameraKit-Android).
this full sized image has no EXIF data
With ACTION_IMAGE_CAPTURE, you are delegating to whatever camera app the user happens to choose. That will be one of hundreds of camera apps, whether pre-installed on the user's chosen device or installed by the user from the Play Store or elsewhere. The behavior of those camera apps, with respect to EXIF tags and anything else, is up to the developers of those camera apps.
It is also possible that you are not reading the EXIF tags correctly.
After searching I found this google example that states I must create a file to see the full size image.
That is a nonsense statement in that document. You do not have to create a file yourself. You only need to supply a file path in the intent so the used Camera app knows where to store the image.
Further i never saw a camera app that didnot include an exif header.

Displaying images from dataDirectory in ionic2

I'm working on an app, using ionic2.
I'm storing a set of images that I downloaded from the server in the dataDirectory to save mobile traffic when the app is used without wi-fi.
Now, I would like to display them inside my template.
Is there a recommended way how the image should best be inserted?
I tried giving the ion-img or img-tag
the complete path (file.dataDirectory + “myImg.jpg” -> "file:///data/user/0/io.ionic.starter/files/myImg.jpg”
(stored in my imgPath variable, the path is written after the platform.ready event), but only a broken image symbol is shown. When accessing images from my assets folder I do not encounter any problems, but how can I access the dataDirectory’s images?
<img width=“200” height=“200” [src]=“imgPath” *ngIf=“imgPath”>
Or do I have to read each image from the dataDirectory and store them in a local variable as a base64 string?
There are many reason for showing broken image in IONIC.
If you are using live reload then sometime images are shown as broken image. You can run directly to see if it resolves your issue.
If you want to use base64 image, either you can save it SQLite or in local variable which may resolve your issue.

capture camera image but not save a file

Is it possible to capture a camera image and use it in my code, but not have the image saved on the device? I need the image for sending to an API, but I have no need for the user to have the file afterwards. Can this be done?
This is not a good idea, as there is too much overhead when handling the full size image in RAM.
I would personally just create a scaled down preview to put in UI(if needed), then upload original(saved on SD) image and delete afterwards.
Some devices will force the images into the gallery.
This will help you with said problem
Here is my edited answer in regard to how i would do it.
Save image to disk and ensure it is encoded correctly for the API you are using.
Start upload service when network connection is available (if necessary).
Either delete image from service or schedule an Alarm to start service and deal with it later
if u r using native camera activity
capture the image on file
get the bitmap of the image from the file
delete the file
(u can save the image in hidden directory {{its name should start with dot .hidden_dir/myimg.jpg }} )

Phonegap camera getPhoto from file manager error on Android

I try to load an image file from the phone. And by using the example code (Camera.sourceType = Camera.PictureSourceType.PHOTOLIBRARY), when a button is pressed, a popup showing that I can select to open "Photo Library" OR "File Manager" (some names like that, may differ across phone models and languages). I can get the returned image file if I select it via Photo Library (as the code indicated?), but failed if I use "File Manager". The error is saying "Unable to load local resources - file://....". (In contrast, the returned value from Photo Library is of the content:// protocol).
Since users may randomly use one of the applications (and some images are not in photo library scope), how can I get it correct with both ways?
=======Update========
Just realize that the error is reported because I use the returned file handle to the image as the image source. And my phonegap app use a remote link as index.html, which is thus not allowed to load local resources (cross-domain issue).
So I need to upload it at background firstly and set the image source to the returned url instead...
Just as I updated, I use a remote page (e.g., http://domain.com/index.html) instead of a page in assets (e.g., index.html, in most PhoneGap documents and tutorials). So the file:// protocol will meet cross-domain restrictions and cannot be loaded by the remote page. While the content:// protocol has no such restrictions. I have to reorganize the architecture of my solution.

Categories

Resources