Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
Posts: 36
Registered: ‎04-19-2012
My Device: Z30, Z10, Q10, Playbook
My Carrier: Virgin

Filepicker imageCropEnabled aspect ratio

When using the imageCropEnabled in filepicker, the crop feature still is only in square format...I know this was asked back in MAY 2013...has there been any change on how to make it work in 16:9 format?

 

FilePicker {
            id: picker1
            title: qsTr("Select a Picture")
            property string selectedFile
            mode: FilePickerMode.Picker
            type: FileType.Picture
            directories: [ "/accounts/1000/shared/camera" ]
            viewMode: FilePickerViewMode.GridView
            sortBy: FilePickerSortFlag.Date
            sortOrder: FilePickerSortOrder.Descending
            imageCropEnabled: true
            onFileSelected: {
                selectedFile = selectedFiles[0]
                imgView1.imageSource = "file://" + selectedFile
                imgView1.visible = true
                imgView1.scaleX = 1
                imgView1.scaleY = 1
                imgView1.rotationZ = 0
            }
        }

 

thx

Dpcanada

Simplify your Life...
BlackBerry Development Advisor
Posts: 57
Registered: ‎10-04-2012
My Device: developer
My Carrier: none

Re: Filepicker imageCropEnabled aspect ratio

Image crop in the file picker is limited. Instead, you can invoke the picture editor directly after a file is chosen.


Details on invoking the picture viewer can be found here: https://developer.blackberry.com/native/documentation/cascades/device_platform/invocation/picture_ed...

Developer
Posts: 824
Registered: ‎10-16-2012
My Device: Red Z10
My Carrier: Telus

Re: Filepicker imageCropEnabled aspect ratio

[ Edited ]

Probably won't be extremely useful for your case but I have noticed in the newer 10.2 releases that when you share an image the unbound-invocation card now shows a preview & has the option to edit the image... really nice touch!

Developer
Posts: 36
Registered: ‎04-19-2012
My Device: Z30, Z10, Q10, Playbook
My Carrier: Virgin

Re: Filepicker imageCropEnabled aspect ratio

 

 

Thanks so much for the reply...

 

I was able to connect the native PhotoEditor to filepicker...but once I am done editing my pic...I hit save and it does not show up in my imageView...filepicker works great when using the imagecropEnabled signal but the crop ratio is only 4:3 and I would like to have the editor start in filters rather than crop...so I would rather call the native PhotoEditor instead of using the imageCropEnabled signal....

 

Here is my code...It works perfectly until I want to bring it back into my imageView container...hitting save does nothing.

 

FilePicker {
                id: picker1
                title: qsTr("Select a Picture")
                property string selectedFile
                mode: FilePickerMode.Picker
                type: FileType.Picture
                directories: [ "/accounts/1000/shared" ]
                viewMode: FilePickerViewMode.GridView
                sortBy: FilePickerSortFlag.Date
                sortOrder: FilePickerSortOrder.Descending
                //imageCropEnabled: true
                onFileSelected: {
                    selectedFile = selectedFiles[0]
                    var filePath = selectedFile
                    _app.getPhotoEditor(filePath);
                    imgView1.imageSource = selectedFile
                    imgView1.visible = true
                    imgView1.scaleX = 1
                    imgView1.scaleY = 1
                    imgView1.rotationZ = 0
                   
                }
            }

 

 

Here is my App.cpp file too.

 

void App::getPhotoEditor(const QString fileName)
        {
                
            bb::system::InvokeManager manager;
            bb::system::InvokeRequest request;

 

            request.setUri(QUrl::fromLocalFile(fileName));
            request.setTarget("sys.pictureeditor.cardeditor");
            request.setAction("bb.action.EDIT");
            //cardRequest.setURI("file:///accounts/1000/shared/camera");
            InvokeTargetReply *targetReply = manager.invoke(request);

          manager.setParent(this);

            if (targetReply == NULL) {
                qDebug() << "InvokeTargetReply is NULL: targetReply = " << targetReply;
            } else {
                targetReply->setParent(this);
            }
        }

 

Thank you so much for the amazing support on this site...it is inspirational!!!

Dpcanada

Simplify your Life...
BlackBerry Development Advisor
Posts: 57
Registered: ‎10-04-2012
My Device: developer
My Carrier: none

Re: Filepicker imageCropEnabled aspect ratio

There are two things you are missing:

1. You need have one InvokeManager for the lifetime of your application, so that you can get a signal when the picture editor card is done. (store it in your App class) Currently it gets deleted at the end of getPhotoEditor so you can never get childCardDone signals from it.

2. You need to capture the new path of the edited picture (it will not replace the input photo, but store a new one in a tmp directory).
You need to connect to childCardDone on InvokeManager and if you are in picture editor mode, parse the resulting CardDoneMessage. dataType will be the mimeType of the picture, and data will be the path to the edited image (something like /tmp/myimage_edit1.jpg).
If you want the edited to replace the input image, then copy it over the input file.