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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Developer
Posts: 676
Registered: ‎05-06-2012
My Device: Dev Alpha & PlayBook
My Carrier: wifi

Using ImageConverter

 

Trying to use the imageConverter class.

 

bb::utility::imageConverter().encode("JPEG",qImage);

 

What would the proper syntax to do this be?

_________________________________________________________
co-founder of Diaree | BB Dev for PictureThis
Retired
Posts: 749
Registered: ‎12-16-2008
My Device: BlackBerry Z30
My Carrier: Bell

Re: Using ImageConverter

What data are you trying to encode? You would need an ImageData that has a pixel buffer of some known format it it. Then when you do encode, you specify the mime type, like "image/jpeg".

Paul Bernhardt
Application Development Consultant
BlackBerry
@PBernhardt

Did this answer your question? Please accept this post as the solution.
Found a bug? Report it to the Developer Issue Tracker
Developer
Posts: 676
Registered: ‎05-06-2012
My Device: Dev Alpha & PlayBook
My Carrier: wifi

Re: Using ImageConverter

I'm just using which ever image file is chosen by a user through the file picker.

 

FilePicker {
            id: picker
            type: FileType.Picture
            filter: [ "*.jpeg"] // , "*.jpg", "*.png" 
            onFileSelected: {
                app.savePicture(selectedFiles[0],app.getTempPath()+"/temp.jpeg")
            }
        }

 The c++ functin savePicture()

bool ApplicationUI::savePicture(const QString &fromPath,
		const QString &toPath) {
	QImage qImage;
	if (qImage.load(fromPath)) {
		qImage = checkRotation(qImage, fromPath);
		QFile outFile(toPath);
		if (outFile.open(QIODevice::WriteOnly)) {
			qImage.save(&outFile, "JPEG");
			outFile.close();

			return true;
		} else {
			qDebug() << "Saving Failed";
			return false;
		}
	} else {
		qDebug() << "Can't find image";
		return false;
	}
}

 

_________________________________________________________
co-founder of Diaree | BB Dev for PictureThis
Retired
Posts: 749
Registered: ‎12-16-2008
My Device: BlackBerry Z30
My Carrier: Bell

Re: Using ImageConverter

Ah, yes, if you are using QImage you don't need to use our imageconverter class as QImage has it built in. I believe QImage also just takes a type like you have ("JPG"). Also, I believe you can save directly to a file name rather than opening and closing the file yourself.

 

Your code looks reasonable at first glance though. What sort of problem are you having?

Paul Bernhardt
Application Development Consultant
BlackBerry
@PBernhardt

Did this answer your question? Please accept this post as the solution.
Found a bug? Report it to the Developer Issue Tracker